Skip to content
CaptiFi Connect

SMS API

SMS API for sending and receiving UK texts

A plain REST API for sending texts to UK mobiles and getting replies and delivery reports back. JSON in and out with a Bearer key, plus test keys you can use the day you sign up.

What is an SMS API?

An SMS API lets your own software send and receive text messages over HTTP. The CaptiFi Connect API is REST at /api/v1 with a Bearer key and JSON bodies. You send with POST /messages, get delivery reports and replies as signed webhooks, and can build against test keys that cost nothing and simulate delivery before your account is approved.

How the API is put together

Everything lives under /api/v1. Put your API key in the Authorization header as a Bearer token and send JSON bodies of up to 1 MB. Successful responses all come back in the same envelope: data holds the result and meta holds anything about it, such as the cursor for the next page. Errors have one shape too, an error object with a code, a message and details, so you can handle them in one place.

Lists use cursor pagination and come back newest first. The whole API is described in an OpenAPI 3.1 document at /api/v1/openapi.json, which you can load into your usual tools or generate a client from.

Our own dashboard runs on the same API, so whatever you can do with messages and contacts in the browser, you can do from code.

What you can do with it

The API covers messages, contacts and everything around them:

  • Send to one number or many with POST /messages, by number, contact or list, with an optional sender name, schedule time, template and your own client_ref.
  • Price a send before making it: POST /messages/quote returns the encoding, parts and credits.
  • Cancel a scheduled text and get the credits back with POST /messages/{id}/cancel.
  • Read conversations, and manage contacts, lists, templates, campaigns, opt-outs and sender name requests.
  • Check your balance, and pull the sent, delivered and reply figures the dashboard shows from the stats endpoints.
  • Register webhooks, fire a test delivery at them and read the delivery log.

Retries, rate limits and the rules that apply

Connections drop, and a send you retry after a timeout shouldn't go out twice. Add an Idempotency-Key header to POST /messages (any unique string per send works; a UUID is typical) and a repeat of the same request returns the original result without sending again.

Every API key, live or test, is limited to 20 requests a second, with bursts up to 40. Test keys send nothing and cost nothing, and they're also capped at 50 numbers a request and 300 numbers an hour.

The API texts UK mobiles only, including Guernsey, Jersey and the Isle of Man. Numbers it can't text come back in the rejected list with a reason code (not_mobile for a landline, unsupported_destination for another country), and they're never charged. Live sending starts once we've checked your account.

Webhooks

There are five events: message.sent, message.delivered, message.failed, message.received and opt_out.created. Each is a JSON POST signed with HMAC SHA-256. The signature header carries t=<unix time>,v1=<hex>, worked out over the timestamp, a full stop and the raw body using your webhook's signing secret.

Answer with any 2xx within 8 seconds. If you don't, we retry after 1, 5, 30, 120, 360 and 720 minutes, and the delivery ID header stays the same on every attempt so you can drop duplicates. A webhook that fails 100 times in a row is switched off until you turn it back on.

Test keys

Test keys work from the moment you sign up, before we've approved your account. A test send goes nowhere: each text is marked sent, then delivered a few seconds later, and the message.sent and message.delivered webhooks fire. Nobody can reply to a test text, so message.received and opt_out.created only ever come from a live key. You can run the sending side end to end without spending anything or texting anyone, then swap in a live key when you're ready.

Your first text through the API

  1. 1

    Create an account

    Sign up, then make a test key under Developers. Keys are shown once, so copy it somewhere safe.

  2. 2

    Send a test text

    POST /api/v1/messages with to and body, the key as a Bearer token and an Idempotency-Key header.

  3. 3

    Add a webhook

    Point it at your endpoint, pick the events you want and check the signature on every delivery.

  4. 4

    Go live

    Once your account is approved and has credit, swap the test key for a live one. Your code stays the same.

Questions people ask

Is there an SMS API sandbox?

Yes. Test keys work as a sandbox: texts are never sent, each one is marked sent and then delivered a few seconds later, the sent and delivered webhooks fire, and nothing is charged. They're capped at 50 numbers a request and 300 numbers an hour.

How do I stop a retry sending twice?

Send an Idempotency-Key header with POST /messages. A repeated request with the same key returns the original result and won't send the texts again.

Which programming languages can I use?

Any language that can make an HTTPS request with a JSON body. There's no SDK to install. If you'd like a typed client, generate one from the OpenAPI 3.1 file at /api/v1/openapi.json.

How do I verify a webhook signature?

Take the timestamp from t= in the signature header, join it to the raw request body with a full stop, compute an HMAC SHA-256 with your signing secret and compare the hex with v1=. Use the body exactly as it arrived; parsing and re-serialising the JSON first can change it.

What are the API rate limits?

Every key, live or test, allows 20 requests a second with bursts up to 40. Test keys are also limited to 50 numbers a request and 300 numbers an hour.

Can I send international SMS through the API?

No. The API sends to UK mobiles only, including Guernsey, Jersey and the Isle of Man, and refuses other numbers with a reason code at no charge.

How are API sends billed?

The same as the dashboard: one credit per SMS part to a UK mobile, replies free, refused numbers never charged, and texts that fail before leaving refunded. Packs start at £25 for 500 credits (5p a text) and fall to 3.5p on the biggest pack, plus VAT; the pricing page has the table.

Send your first text this week

Set up your account and contacts now; we check every new account before it can send.