API Documentation
Read and write your customers, jobs, invoices and services, subscribe to webhooks, and capture leads from your website with the Smarfle API.
Before you start
API Key Auth
Create a key in Company Settings, Integrations, API keys. Send it asAuthorization: Bearer smk_...Each key only sees your business.
Webhook Events
Receive real-time notifications when events happen in your account. Configure endpoints in settings.
Rate Limited
120 calls a minute per key. Reads and webhooks are free; each call that adds or changes a record is billed at $0.003 from your wallet.
REST API v1
Base address https://www.smarfle.com/api/v1. JSON in and out. A read-only key can call every GET; a read and write key can also add and change. The full machine-readable description is at /api/v1/openapi.json (OpenAPI 3.1, imports into Postman).
| Method | Path | What it does | Key |
|---|---|---|---|
| GET | /api/v1/me | The business and key behind this API key. Use it to test a connection. | Read |
| GET | /api/v1/customers | Customers, newest first. Filters: email, phone, status, q (name, email, phone or company contains), created_since, updated_since. | Read |
| POST | /api/v1/customers | Add a customer. Same rules as in Smarfle: plan limit, one customer per email (409 with existing_id), webhooks and workflows run. | Write |
| GET | /api/v1/customers/{id} | One customer. | Read |
| PATCH | /api/v1/customers/{id} | Change a customer. Only the fields you send change; an empty string clears a field. | Write |
| GET | /api/v1/jobs | Jobs, newest first. Filters: status, customer_id, scheduled_from, scheduled_to, created_since, updated_since. | Read |
| POST | /api/v1/jobs | Add a job request (status requested), like an online booking. The office confirms and schedules it in Smarfle; the API never messages a customer. | Write |
| GET | /api/v1/jobs/{id} | One job. | Read |
| GET | /api/v1/invoices | Invoices, newest first. Filters: status, customer_id, job_id, created_since, updated_since. | Read |
| GET | /api/v1/invoices/{id} | One invoice with its line items. | Read |
| GET | /api/v1/services | Your services and prices. Filter: active. | Read |
| GET | /api/v1/webhooks | Webhook subscriptions made through the API. | Read |
| POST | /api/v1/webhooks | Subscribe a public https address to events. The answer includes the signing secret once. | Write |
| DELETE | /api/v1/webhooks/{id} | Unsubscribe. | Write |
Examples
# Customers changed since November 1
curl "https://www.smarfle.com/api/v1/customers?updated_since=2026-11-01T00:00:00Z&limit=50" \
-H "Authorization: Bearer smk_your_key"
# Add a customer
curl -X POST https://www.smarfle.com/api/v1/customers \
-H "Authorization: Bearer smk_your_key" -H "Content-Type: application/json" \
-d '{"first_name":"Jane","last_name":"Doe","email":"jane@example.com","phone":"407-555-0100"}'
# Add a job request for that customer
curl -X POST https://www.smarfle.com/api/v1/jobs \
-H "Authorization: Bearer smk_your_key" -H "Content-Type: application/json" \
-d '{"customer_id":"CUSTOMER_ID","title":"Quarterly pest control","preferred_date":"2026-12-02"}'
# Get told when an invoice is paid
curl -X POST https://www.smarfle.com/api/v1/webhooks \
-H "Authorization: Bearer smk_your_key" -H "Content-Type: application/json" \
-d '{"url":"https://hooks.example.com/smarfle","events":["invoice.paid"]}'Paging
Lists come newest first as { "data": [...], "has_more": true, "next_cursor": "..." }. Ask for the next page with ?cursor= and the next_cursor value. limit is 1 to 100 (default 25).
Errors
Every error is { "error": { "code": "...", "message": "..." } }.
| 400 invalid_request | A field is missing or wrong; the message names it. Unknown fields are refused too. |
| 401 unauthorized | No key, a wrong key, or a revoked key. |
| 402 plan_required | The trial or plan has ended, or the customer limit of the plan is reached. |
| 403 forbidden | A read-only key tried to change something. |
| 404 not_found | No record with this id in your business. Another business's ids always answer 404. |
| 409 conflict | A customer with this email already exists; error.existing_id is that customer. |
| 429 rate_limited | More than 120 calls a minute for the key (600 for the business). Retry after a minute. |
Security
- Each key belongs to one business and only ever reads or changes that business's records. Ids from another business answer 404.
- Smarfle stores only a hash of each key and shows the key once. The owner gets an email for every new key and can revoke a key at once.
- Only the owner can create keys. A read-only key cannot change anything.
- Webhooks go only to public https addresses and are signed (see Verifying a webhook below).
Lead capture endpoints
/api/webhook/leadsAll plansCreate a lead from your own site's server. API key goes in the x-api-key header. The request (message, page, answers) shows at the top of the client page, and owners and managers get a bell, push and email.
Auth: x-api-key header
/api/webhook/leads/{api_key}All plansSame endpoint with the key in the URL, for form builders that cannot set custom headers. Name, email, phone, address and message fields are recognized; every other field shows in the Request card and fills a custom field with the same name.
Auth: Key in path
Example: Create a lead (no SMS)
curl -X POST https://www.smarfle.com/api/webhook/leads \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{
"first_name": "John",
"last_name": "Smith",
"email": "john@example.com",
"phone": "(407) 555-0123",
"address": "12 Oak St, Orlando, FL 32801",
"message": "Water heater is leaking. Can someone come this week?",
"source_page": "https://acme-plumbing.com/water-heater-repair/",
"page_title": "Water Heater Repair",
"custom_fields": { "Service needed": "Water heater repair" },
"details": { "Preferred time": "Mornings", "Referrer": "google.com" }
}'⚠️ SMS Consent (A2P 10DLC compliance)
Lead phones imported via this endpoint default to sms_consent: false. The Smarfle outbound-SMS engine will refuse to text any client whose sms_consent is not true, even if the org owner triggers a campaign or workflow against them. This protects every Smarfle business from TCPA + carrier-policy violations.
To mark the lead as SMS-opted-in, you must:
- Have collected explicit, unchecked-by-default consent on your form (and retain proof — Twilio may request it during a campaign audit)
- Send
sms_consent: truein the request body - Include a
sms_consent_sourcedescribing where consent was collected (e.g."ACME website /quote form, unchecked checkbox, IP 1.2.3.4")
Example: Create a lead WITH SMS consent
curl -X POST https://www.smarfle.com/api/webhook/leads \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{
"first_name": "John",
"last_name": "Smith",
"email": "john@example.com",
"phone": "(407) 555-0123",
"sms_consent": true,
"sms_consent_source": "https://acme.com/quote — checkbox unchecked by default, IP captured"
}'Request body
JSON. Two fields are required and the rest are optional. Anything not listed here is ignored rather than rejected.
Required
first_namestring1 to 200 characters.last_namestring1 to 200 characters.Optional
emailstringValid address, max 320. A duplicate returns 409 with the existing client_id; the request is saved as a note on that client.phonestringUS number: 10 digits, or 11 starting with 1. Any other number returns 400. Stored as digits.company_namestringMax 200. The client's company.messagestringMax 5000. What the visitor wrote; shown first in the Request card on the client page.source_pagestringMax 500. The page the form was sent from (full URL).page_titlestringMax 200. That page's name, e.g. "SEO in Orlando".custom_fieldsobjectUp to 30 { "Field name": value }. Fills the business's custom field with the same name (case ignored; a list field takes only one of its options). Every value also shows in the Request card.detailsobjectUp to 20 { "Label": value } rows shown in the Request card: answers, calculator values, referrer, ad click ids.addressstringMax 300. One-line address ("12 Oak St, Orlando, FL 32801"), split into street, city, state and ZIP when the parts are not sent.address_streetstringMax 500.address_unitstringMax 100. Apartment, suite or unit.address_citystringMax 200.address_statestringMax 100.address_zipstringMax 20.notesstringMax 5000. Free text, shown in the Request card. Prefer message + details.sms_consentbooleanDefaults to FALSE. Send true only if you collected consent yourself.sms_consent_sourcestringWhere that consent was collected. Appears in the consent evidence export.utm_sourcestringFirst-touch attribution, flat field.utm_mediumstringFirst-touch attribution, flat field.utm_campaignstringFirst-touch attribution, flat field.branch_iduuidMust belong to your organization and be active, or the call is rejected.Responses
200{ "success": true, "client_id": "uuid" }Client created.
400{ "error": "..." }Validation failed, client limit reached for the plan, or branch_id is not yours.
401{ "error": "Missing x-api-key header" }No key sent, or the key does not match an organization.
409{ "error": "A client with this email already exists", "client_id": "uuid", "request_saved": true }Duplicate email. The new request is saved as a note on the existing client and the business is alerted; the existing id is returned.
429{ "error": "Too many requests..." }Rate limited. Back off and retry.
500{ "error": "An unexpected error occurred" }Our side. Safe to retry.
Verifying a webhook
Every outgoing webhook carries an X-Webhook-Signature header, an HMAC-SHA256 of the raw body using the endpoint secret shown when you created it. Compare it against the body before trusting the payload, and compare in constant time.
import crypto from "crypto";
// body must be the RAW string, not a re-serialised object
function isValid(rawBody, signature, secret) {
const expected = crypto
.createHmac("sha256", secret)
.update(rawBody)
.digest("hex");
return crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(signature)
);
}The payload envelope is the same for every event.
{
"event": "invoice.paid",
"timestamp": "2026-09-29T14:05:00.000Z",
"data": { }
}Webhook Events
Configure a webhook URL in your organization settings to receive POST requests when these events occur.
| Event | Description |
|---|---|
client.created | Client Created |
client.updated | Client Updated |
work_order.created | Work Order Created |
work_order.status_changed | Work Order Status Changed |
invoice.created | Invoice Created |
invoice.sent | Invoice Sent |
invoice.paid | Invoice Paid |
estimate.created | Estimate Created |
estimate.sent | Estimate Sent |
estimate.accepted | Estimate Accepted |
estimate.rejected | Estimate Rejected |
estimate.converted | Estimate Converted |
Getting Started
Create an API key
Company Settings, Integrations, API keys, Create API key. Pick read only or read and write, and copy the key: Smarfle shows it once.
Test the connection
GET /api/v1/me with Authorization: Bearer and your key. It answers with your business name and the key's scope.
Read and write
List customers, jobs and invoices, add customers and job requests. Every call only sees your business.
Subscribe to webhooks
POST /api/v1/webhooks with your https address and the events you want, or add it in Company Settings, Integrations, Webhooks.
Ready to integrate?
API access is included on every plan. Start your free trial to get your API key.