Skip to content
CaptiFi Connect

Developer docs

Test keys: build against the SMS API for free

A test key behaves like a live one from your code's point of view, except that nothing leaves us and nothing is charged. Use it to build and test the whole flow, webhooks included.

What a test key does

Create one in the dashboard under Developers, API keys, with the mode set to Test. It starts cc_test_. Requests made with it go through the same checks as live ones: the body is validated, numbers are checked and de-duplicated, opted-out numbers are refused, and you get the same response shapes back. The difference is that every message has test set to true, uses no credit, and never reaches a phone.

POST /messages with a test key
{
  "data": {
    "batch_id": "bat_01J9Z8X7W6V5T4S3R2Q1P0N9M7",
    "messages": [{ "id": "msg_01J9Z8X7W6V5T4S3R2Q1P0N9M8", "status": "queued", "credits": 0, "test": true }],
    "rejected": []
  },
  "meta": { "credits": 0, "replayed": false, "test": true }
}

A test key can send test texts to numbers you type (POST /messages with to, and POST /messages/bulk), price a send with POST /messages/quote, check a number with POST /lookup, read and cancel the test texts and batches it sent, and set up webhooks. Test keys work while your account is still waiting to be checked, so you don't have to wait for approval to start building.

What a test key cannot see

Test keys often end up in places live keys don't: a laptop, a test server, a CI job, a contractor's project. So since 7 November 2026 a test key can't read anything about real people. Contacts, lists, opt-outs, conversations, tracked link clicks and live texts all answer 403 with test_key_live_data, and so does a send that names contact_ids or a list_id, because the texts would carry your contacts' details back in the response.

For the same reason a test text is never matched to a contact, so merge fields such as {first_name} are left empty. Put the values in the text, or pass them as vars on each item of a bulk send. GET /messages with a test key lists only the test texts that key sent, and the simulated replies to them; asking for a live text by id answers test_key_live_data.

A test key can't change anything either, beyond its own test texts and webhooks: contacts, lists, keywords, opt-outs, templates, sender names and campaigns are refused with 403 test_mode_not_supported. That includes creating a campaign draft. Test the text itself with POST /messages instead.

The simulated timeline

About a second after you send, each test text moves to sent, and about two seconds after that to delivered. Each step records a timeline entry and fires message.sent and then message.delivered to your webhooks, signed exactly as live events are, so your signature check gets a proper workout.

Test texts show in the dashboard's message history with a test label, which keeps them easy to tell apart from real ones.

Numbers that act out other outcomes

Ofcom keeps 07700 900000 to 07700 900999 for drama and never gives those numbers to a real phone. With a test key you can send to any of them, and four of them do something on purpose, so you can write your failure, reply and opt-out handling against real events. A live key refuses the whole range as invalid_number.

NumberWhat happens
07700 900001Delivered, about three seconds after you send. Every other number does the same.
07700 900002Comes back undelivered: status undelivered, error_code undelivered, and message.failed to your webhooks.
07700 900003Delivered, then a few seconds later a reply, "Thanks, see you then", which raises message.received.
07700 900004Delivered, then a reply of STOP, which raises message.received and opt_out.created with test set to true.

The replies are test texts like any other: they show up in GET /messages for the key that sent the original, with direction inbound. The STOP reply never touches your real opt-out list, so later test texts to 07700 900004 still go.

Webhooks in test mode

A webhook created with a test key is marked test_only. It only ever receives events about test texts, never live ones, so pointing it at a test server can't leak a real customer's reply. A test key only sees, changes and deletes its own test webhooks; endpoints you set up in the dashboard or with a live key are invisible to it and receive every event, test ones included.

The webhook test button (or POST /webhooks/{id}/test) sends a signed webhook.test event straight away, which shows your endpoint is reachable and checks its signature code. The webhooks guide shows every payload.

Limits

Test texts are free, so they're capped: up to 50 numbers in one request and 300 texts an hour per account. Go over the hourly figure and you get a 429 with a Retry-After header, the same as the live rate limit.

Test keyLive key
Key prefixcc_test_cc_live_
Texts actually sentNoYes
Credits usedNoneOne per SMS part
Works before your account is approvedYesYes, but each text waits for our check (pending_review)
Number checks, opt-outs and rejectionsSame as liveYes
Send to typed numbers, bulk sends, quotes and lookupsYesYes
Send to contacts or a listNo (403 test_key_live_data)Yes
Read textsOnly the test texts this key sentAll of them
Read contacts, lists, opt-outs, conversations and link clicksNo (403 test_key_live_data)Yes
WebhooksIts own, which get test events onlyEvery event, test ones included
CampaignsNo: creating, sending and cancelling all need a live keyYes
Recipients per requestUp to 50Up to 1,000 typed numbers, plus contacts and lists
Numbers per hourUp to 300Set by your rate limit and balance

Switching to live

Once your account is approved and has credit, create a live key and swap it in. Test and live Idempotency-Key values are kept apart, so a key you used in testing can't make a live request return an old test answer. The quickstart walks through the whole thing.