SmarticBot/Developers
Developer reference · v1

Build with the SmarticBot API

Send messages from a QR-connected WhatsApp phone, schedule campaigns, verify one-time codes, and talk to an assistant.

QR-connected phones · Public API v1

Quickstart

  1. Connect a phone by QR code in Channels and activate a plan.
  2. In Developer access, create a public phone API key. Copy it once and store it securely. Creating another key revokes the previous one; the provider connection is unaffected.
  3. Send a request with x-api-key. Use an assistant key only for /chat.
curl -X POST https://smarticbot.com/api/v1/send-message \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -H 'Idempotency-Key: order-2026-001' \
  -H 'Content-Type: application/json' \
  -d '{"number":"967771234567","message":"Hello from SmarticBot"}'

The example numbers are illustrative: Yemen uses +967 and Saudi Arabia uses +966. Replace them with your intended recipients before sending.

Accepted sends return HTTP 202 and an ID you can query at GET /messages/{id}. Acceptance does not guarantee delivery.

Before you integrate

QR WhatsApp setup guide · Official WhatsApp Business setup guide

Numbers use international digits (8–15 digits), optionally with a leading +. JSON endpoints require Content-Type: application/json; media uses multipart/form-data and accepts JPEG, PNG, WebP or MP4 up to 10 MiB.

Rate limits: 60 v1 requests per minute per API key (or IP without a key). OTP issue is additionally limited to five requests per number per 10 minutes and 30 per device per hour. Campaign messages consume quota when each recipient is sent.

Message states are pending, accepted, sent, delivered, read, failed or unknown. Providers may skip intermediate states; status never moves backward. An unknown outcome may still be delivered.

Supply Idempotency-Key on sends, OTP issue, campaigns, and chat. Repeating the same payload returns the original result for 24 hours. A changed payload or pending request returns 409. A timeout can mean the provider accepted the send: do not automatically retry with a new key.

OTP is a device-and-number-bound, single-use code valid for five minutes with at most five verification attempts. It does not log users into SmarticBot.

Customer webhooks

Available for paid phone plans. Enable a webhook URL in phone settings, then create a signing secret in Developer access. Each delivery includes X-Webhook-ID, X-Webhook-Timestamp, X-Webhook-Key-Version and X-Webhook-Signature. Verify the hex HMAC-SHA256 signature over timestamp + "." + the exact raw JSON body. Deduplicate by event ID. Retries preserve the body and signing version.

expected = 'sha256=' + HMAC_SHA256(secret, timestamp + '.' + raw_body)

Events include device_status_updated and message_status_updated. Provider callbacks are private; there is no public status-update endpoint.

Responses & errors

Success has success=true and a data object. Errors have success=false with error.code, error.message and error.details (an object, empty when there is nothing to add). Branch on error.code, not on the message text. Every request is limited to 60 per minute per API key.

Error codes

HTTPerror.codeWhen it happensWhat to do
401unauthorizedThe x-api-key header is missing, invalid, expired or revoked. A phone key cannot call /chat.Do not retry. Fix the key.
402credits_exhaustedThe assistant has no credits left (POST /chat).Do not retry. Top up or renew, then retry.
403plan_unavailable · device_inactive · assistant_disabledNo active device plan, the device is inactive, or the assistant is switched off.Do not retry. Fix the account state first.
404not_foundThe message or campaign ID does not exist for this key.Do not retry. Check the ID.
409device_disconnectedThe QR-connected device is not connected.Reconnect it in Channels, then retry.
409idempotency_conflictThis Idempotency-Key was already used with a different request.Use a new key for a new request. Never change the payload under the same key.
409idempotency_in_progressThe original request with this key is still running, or its outcome is unknown.Wait, then retry with the same key. Do not send it again with a new key.
409conversation_busyPOST /chat: this session is still processing another turn.Retry after the Retry-After header (2 seconds). details.retryable is true.
422validation_errorA field is missing or breaks a rule from the field tables. details lists every failing field.Do not retry unchanged. Fix the fields.
422otp_invalidThe code is wrong, expired, already used, or has had five attempts.Issue a new code with POST /send-otp.
429rate_limitedMore than 60 requests per minute for this key, or too many OTP requests for one number or device.Wait for the Retry-After header when present, then retry.
429message_quota_exceededThe account message quota for the current period is used up. All phones on the account share it.Do not retry in a loop. Wait for the next period or upgrade the plan.
502provider_rejectedThe provider definitely rejected the send or the OTP.Do not retry unchanged. Check the number and content.
503retry_queue_fullSmarticBot has no space for this send in the retry queue.Wait, then retry with the same idempotency key.
503delivery_uncertainThe send outcome is unknown. details.message_id identifies it. For OTP, a code that arrives can still be verified.Never retry with a new key. Check GET /messages/{id}, or retry with the same key.
503chat_unavailablePOST /chat: the assistant could not complete this turn. Failed turns add no history.Retry later with backoff, using the same key.

Error examples

Redacted examples. Real responses carry your own values.

422 · validation_error

{
    "success": false,
    "error": {
        "code": "validation_error",
        "message": "The request contains invalid fields.",
        "details": {
            "number": [
                "The number field format is invalid."
            ]
        }
    }
}

401 · unauthorized

{
    "success": false,
    "error": {
        "code": "unauthorized",
        "message": "Invalid or expired API key.",
        "details": {}
    }
}

402 · credits_exhausted

{
    "success": false,
    "error": {
        "code": "credits_exhausted",
        "message": "Assistant credits are exhausted.",
        "details": {}
    }
}

409 · idempotency_conflict

{
    "success": false,
    "error": {
        "code": "idempotency_conflict",
        "message": "This key was used with a different request.",
        "details": {}
    }
}

409 · conversation_busy (Retry-After: 2)

{
    "success": false,
    "error": {
        "code": "conversation_busy",
        "message": "This conversation is processing another turn. Retry this request.",
        "details": {
            "retryable": true,
            "retry_after": 2
        }
    }
}

429 · rate_limited (Retry-After when present)

{
    "success": false,
    "error": {
        "code": "rate_limited",
        "message": "Too many requests.",
        "details": {}
    }
}

503 · delivery_uncertain

{
    "success": false,
    "error": {
        "code": "delivery_uncertain",
        "message": "The send outcome is unknown. Do not retry with a new idempotency key.",
        "details": {
            "message_id": "01J..."
        }
    }
}

Retries and idempotency

  • For text, media and polls, HTTP 202 with queued means SmarticBot will retry the saved request automatically for up to 24 hours. Use GET /messages/{id} to track it. A new send request may create a duplicate.
  • Safe to retry: 429 (after the wait), 409 conversation_busy, 503 chat_unavailable, 409 idempotency_in_progress, and network timeouts. Use exponential backoff with jitter, for example about 1 s, 2 s, 4 s, up to five tries.
  • Send an Idempotency-Key on every send, OTP issue, campaign creation and chat turn. Create a new unique value (a UUID works) for each new operation, and reuse it only to retry that same request. Keys are scoped to your key and the operation, and remembered for 24 hours.
  • A replayed response is the original response with the header Idempotency-Replayed: true. The same key with a different payload returns 409 idempotency_conflict.
  • After a timeout or a 503 on a send, do not send it again with a new key: the message may already have gone out. Check GET /messages/{id} (the id is in details.message_id), or retry with the same key.

Changelog

  • 2026-11-26 — Documentation: field tables now show every constraint in the OpenAPI file (lengths, item limits, uniqueness, enums, file limits) and each endpoint lists its headers and path parameters. Added the error catalogue, examples and retry guidance.
  • 2026-11-13 — Legacy keys tied to provider identities stopped working. Use public keys created in Developer access.
  • 2026-10-22 — Public API v1 reworked: idempotent sends, message quota reservation, signed customer webhooks and verifiable OTP codes (five minutes, five attempts, single use). Campaign recipients are a JSON array of 1–500 unique numbers and scheduled_at must include a timezone offset. The public device and message status-update endpoints were removed, and request_id is no longer used.

Messages

Send text

POST/api/v1/send-message

Parameters

NameInRequiredTypeRules
Idempotency-KeyheaderNostring1–128 characters · Replay the same principal, operation and payload for 24 hours. Changed or pending requests return 409.

Request fields

FieldTypeRequiredRules
numberstringYesmatches ^\+?[1-9][0-9]{7,14}$ · International digits with optional leading +. Example is an illustrative Yemeni mobile number; replace it with your intended recipient.
messagestringYes1–4096 characters

Possible HTTP statuses

202401409422429502503

Response data fields

FieldTypeRequiredRules
idstringYesPublic message ID for GET /messages/{id}
statusstringYesone of: accepted, queued · Accepted by WhatsApp or stored for automatic retry for up to 24 hours. Poll the message ID for the current status.
provider_message_idstring | nullYes

Request

curl -X POST https://smarticbot.com/api/v1/send-message \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "number": "967771234567",
    "message": "Hello from SmarticBot"
}'

Success response

{
    "success": true,
    "data": {
        "id": "01J...",
        "status": "accepted",
        "provider_message_id": "ABCD"
    }
}

Send image or video

POST/api/v1/send-media

Parameters

NameInRequiredTypeRules
Idempotency-KeyheaderNostring1–128 characters · Replay the same principal, operation and payload for 24 hours. Changed or pending requests return 409.

Request fields (multipart/form-data)

FieldTypeRequiredRules
numberstringYesmatches ^\+?[1-9][0-9]{7,14}$ · International digits with optional leading +. Example is an illustrative Yemeni mobile number; replace it with your intended recipient.
mediafileYesJPEG, PNG, WebP or MP4; 10 MiB maximum
captionstringNoup to 3500 characters

Possible HTTP statuses

202401409422429502503

Response data fields

FieldTypeRequiredRules
idstringYesPublic message ID for GET /messages/{id}
statusstringYesone of: accepted, queued · Accepted by WhatsApp or stored for automatic retry for up to 24 hours. Poll the message ID for the current status.
provider_message_idstring | nullYes

Request

curl -X POST https://smarticbot.com/api/v1/send-media \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -F 'number=967771234567' \
  -F '[email protected]'

Success response

{
    "success": true,
    "data": {
        "id": "01J...",
        "status": "accepted",
        "provider_message_id": "ABCD"
    }
}

Send poll

POST/api/v1/send-poll-message

Parameters

NameInRequiredTypeRules
Idempotency-KeyheaderNostring1–128 characters · Replay the same principal, operation and payload for 24 hours. Changed or pending requests return 409.

Request fields

FieldTypeRequiredRules
numberstringYesmatches ^\+?[1-9][0-9]{7,14}$ · International digits with optional leading +. Example is an illustrative Yemeni mobile number; replace it with your intended recipient.
poll_questionstringYes1–255 characters
poll_optionsarray of stringYes2–12 items · unique · each item: 1–255 characters
allow_multiple_answersbooleanNodefault: false

Possible HTTP statuses

202401409422429502503

Response data fields

FieldTypeRequiredRules
idstringYesPublic message ID for GET /messages/{id}
statusstringYesone of: accepted, queued · Accepted by WhatsApp or stored for automatic retry for up to 24 hours. Poll the message ID for the current status.
provider_message_idstring | nullYes

Request

curl -X POST https://smarticbot.com/api/v1/send-poll-message \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "number": "967771234567",
    "poll_question": "Which day?",
    "poll_options": [
        "Monday",
        "Tuesday"
    ],
    "allow_multiple_answers": false
}'

Success response

{
    "success": true,
    "data": {
        "id": "01J...",
        "status": "accepted",
        "provider_message_id": "ABCD"
    }
}

Get message delivery status

GET/api/v1/messages/{id}

Parameters

NameInRequiredTypeRules
idpathYesstring

Possible HTTP statuses

200401404

Response data fields

FieldTypeRequiredRules
idstringYes
typestringYesone of: text, media, poll
statusstringYesone of: queued, pending, accepted, sent, delivered, read, failed, unknown
provider_message_idstring | nullYes
sent_atstring | nullYesISO 8601 date-time
delivered_atstring | nullYesISO 8601 date-time
read_atstring | nullYesISO 8601 date-time
last_errorstring | nullNoMost recent failure code, if any
retry_atstring | nullNoISO 8601 date-time · Next eligible automatic attempt for a queued message

Request

curl -X GET https://smarticbot.com/api/v1/messages/{id} \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY'

Success response

{
    "success": true,
    "data": {
        "id": "01J...",
        "type": "text",
        "status": "delivered",
        "provider_message_id": "ABCD",
        "sent_at": "2026-10-14T10:00:00Z",
        "delivered_at": "2026-10-14T10:00:03Z",
        "read_at": null
    }
}

Verification codes

Issue a six-digit verification code

POST/api/v1/send-otp

Parameters

NameInRequiredTypeRules
Idempotency-KeyheaderNostring1–128 characters · Replay the same principal, operation and payload for 24 hours. Changed or pending requests return 409.

Request fields

FieldTypeRequiredRules
numberstringYesmatches ^\+?[1-9][0-9]{7,14}$ · International digits with optional leading +. Example is an illustrative Yemeni mobile number; replace it with your intended recipient.

Possible HTTP statuses

202401409422429502503

Response data fields

FieldTypeRequiredRules
expires_in_secondsintegerYesalways 300

Request

curl -X POST https://smarticbot.com/api/v1/send-otp \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "number": "967771234567"
}'

Success response

{
    "success": true,
    "data": {
        "expires_in_seconds": 300
    }
}

Verify and consume a code

POST/api/v1/verify-otp

Request fields

FieldTypeRequiredRules
numberstringYesmatches ^\+?[1-9][0-9]{7,14}$ · International digits with optional leading +. Example is an illustrative Yemeni mobile number; replace it with your intended recipient.
codestringYesmatches ^[0-9]{6}$

Possible HTTP statuses

200401422

Response data fields

FieldTypeRequiredRules
verifiedbooleanYesalways true

Request

curl -X POST https://smarticbot.com/api/v1/verify-otp \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "number": "967771234567",
    "code": "123456"
}'

Success response

{
    "success": true,
    "data": {
        "verified": true
    }
}

Campaigns

Schedule a campaign

POST/api/v1/create-campaign
The example scheduled_at is generated seven days from page load. Replace it with your desired future time and timezone offset.

Parameters

NameInRequiredTypeRules
Idempotency-KeyheaderNostring1–128 characters · Replay the same principal, operation and payload for 24 hours. Changed or pending requests return 409.

Request fields

FieldTypeRequiredRules
campaign_namestringYes1–255 characters
campaign_descstringNoup to 255 characters
messagestringYes1–4096 characters
recipientsarray of stringYes1–500 items · unique · each item: matches ^\+?[1-9][0-9]{7,14}$
scheduled_atstringYesISO 8601 date-time · Future timestamp with UTC offset

Possible HTTP statuses

201401409422429

Response data fields

FieldTypeRequiredRules
idintegerYes
statusstringYesalways 'scheduled'
scheduled_atstringYesISO 8601 date-time
recipient_countintegerYes1–500

Request

curl -X POST https://smarticbot.com/api/v1/create-campaign \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "campaign_name": "Scheduled update",
    "message": "Hello!",
    "recipients": [
        "967771234567",
        "966501234567"
    ],
    "scheduled_at": "2026-12-13T06:06:59+00:00"
}'

Success response

{
    "success": true,
    "data": {
        "id": 123,
        "status": "scheduled",
        "scheduled_at": "2026-12-13T06:06:59+00:00",
        "recipient_count": 2
    }
}

Get campaign progress

GET/api/v1/campaigns/{id}

Parameters

NameInRequiredTypeRules
idpathYesinteger

Possible HTTP statuses

200401404

Response data fields

FieldTypeRequiredRules
idintegerYes
statusstringYesone of: draft, scheduled, running, completed, paused, cancelled, failed
scheduled_atstring | nullYesISO 8601 date-time
sent_countintegerYesat least 0
failed_countintegerYesat least 0
delivered_countintegerYesat least 0
read_countintegerYesat least 0

Request

curl -X GET https://smarticbot.com/api/v1/campaigns/{id} \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY'

Success response

{
    "success": true,
    "data": {
        "id": 123,
        "status": "running",
        "sent_count": 20,
        "failed_count": 0,
        "delivered_count": 17,
        "read_count": 9
    }
}

Devices

Get QR-connected device information

GET/api/v1/device/info

Possible HTTP statuses

200401

Response data fields

FieldTypeRequiredRules
idintegerYes
namestringYes
phone_numberstringYes
statusstringYes
is_activebooleanYes
last_seen_atstring | nullYesISO 8601 date-time

Request

curl -X GET https://smarticbot.com/api/v1/device/info \
  -H 'x-api-key: YOUR_PUBLIC_PHONE_KEY'

Success response

{
    "success": true,
    "data": {
        "id": 1,
        "name": "Sales",
        "phone_number": "967771234567",
        "status": "connected",
        "is_active": true,
        "last_seen_at": "2026-10-14T10:00:00Z"
    }
}

Assistant

Send a turn to an assistant using an assistant key

POST/api/v1/chat
Each assistant has its own API key. The key in x-api-key selects that assistant. Reuse session_id for follow-up turns: the last 10 successful turns from this assistant and session in the previous 30 days are sent as context. Use a new value for a new conversation; send turns for one session sequentially. Prior context consumes input tokens and may increase credits used. A phone key cannot call this endpoint.

Parameters

NameInRequiredTypeRules
Idempotency-KeyheaderNostring1–128 characters · Replay the same principal, operation and payload for 24 hours. Changed or pending requests return 409.

Request fields

FieldTypeRequiredRules
session_idstringYes1–128 characters · Caller-chosen conversation identifier, scoped to this assistant. Reuse it for follow-up turns; use a new value for a new conversation.
messagestringYes1–4096 characters

Possible HTTP statuses

200401402403409422503

Response data fields

FieldTypeRequiredRules
replystringYes
tokensintegerYesat least 0
credits_usedintegerYesat least 0

Request

curl -X POST https://smarticbot.com/api/v1/chat \
  -H 'x-api-key: YOUR_PUBLIC_ASSISTANT_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "session_id": "customer-42",
    "message": "What are your opening hours?"
}'

Success response

{
    "success": true,
    "data": {
        "reply": "We are open 9–5.",
        "tokens": 120,
        "credits_used": 2
    }
}