By the end of this module, you can
- Create an API key and know what a test key really does
- Send a message with curl or the TypeScript SDK
- Read a 202 response, its status and why a message is held
- Retry a send without ever sending it twice
You do not need much to send a first message: an account, a line and an API key. The call itself is short. What separates a demo from something you can run for a year is the detail around it, so this module spends as long on the response and on retries as on the send.
Lesson 1 of 4Before you call: an account, a line and a key
- An account. Sign up at platform.isnap.ai. The Starter plan is $0 and needs no credit card.
- A line. Every send names the line it leaves from (module 2). To practise for free, the Starter plan uses a trial: you text a short pairing code from your own phone to a test line, and you can then send to that one phone. For anyone else, you need a line of your own.
- An API key. Create keys in the dashboard. A key starts with
isnap_live_orisnap_test_, is shown once, does not expire, and stops working on the next request after you revoke it. You can have as many as you like, so give each system its own.
A test key is not a sandbox
This catches people out. isnap_test_ keys use the same account, lines and billing as live keys, and they send real messages to real phones, with real webhooks. iSnap has no test environment and no simulated send. Test against your own phone number.
Keep the key on a server
The API does not accept calls from web pages on other sites: call it from your server. Keep the key in an environment variable (the docs use ISNAP_API_KEY) and send it on every request as a bearer token, Authorization: Bearer $ISNAP_API_KEY. The base URL is https://api.isnap.ai, and every operation lives under /v1/.
Find your line’s id
The first useful call lists your lines, with each line’s id, kind and status:
curl -sS https://api.isnap.ai/v1/lines/my \
-H "Authorization: Bearer $ISNAP_API_KEY"From the iSnap docs: Quickstart, make a first call
Copy the id of a line whose status is active. That is the line_id every send needs.
Lesson 2 of 4Send the message
A send names three things: the line it leaves from, the phone number it goes to, and the text.
IDEMPOTENCY_KEY=$(uuidgen) # Store it with your record of the message: reuse it to retry.
curl -sS https://api.isnap.ai/v1/messages \
-H "Authorization: Bearer $ISNAP_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{
"line_id": "line_8Xk2mQ4vTn7Bw9Rz3Lc6Yp1Hd",
"to": "+14155550123",
"body": "Hello from iSnap"
}'From the iSnap docs: Quickstart, send a message
The same call with the TypeScript SDK, @isnap/sdk (install it with npm install @isnap/sdk; it runs on Node.js 20 or later, or Bun, on a server):
import { randomUUID } from 'node:crypto'
import { APIError, ISnapClient } from '@isnap/sdk'
const client = new ISnapClient({ apiKey: process.env.ISNAP_API_KEY ?? '', maxRetries: 2 })
const idempotencyKey = randomUUID() // Store it with your record of the message: reuse it to retry.
try {
const message = await client.messages.send(
{
line_id: 'line_8Xk2mQ4vTn7Bw9Rz3Lc6Yp1Hd',
to: '+14155550123',
body: 'Hello from iSnap'
},
{ idempotencyKey }
)
console.log(message.id, message.status, message.scheduled_for, message.schedule_reason)
} catch (err) {
if (!(err instanceof APIError)) throw err
console.error(err.status, err.code, err.message, `trace_id=${err.traceId}`, `request_id=${err.requestId}`)
process.exitCode = 1
}From the iSnap docs: Quickstart, send a message
From Python, call the API over plain HTTP with requests: there is no Python SDK, and the quickstart has the Python version of this send.
The fields
line_id: the line it leaves from. Required.to: one phone number in E.164, such as+14155550123. A number without a country code is read as a US number. Phone numbers only: no email addresses, and no groups.body: the text, up to 5,000 characters (measured in UTF-16 units). A message can also carry a file; the device sends one attachment per message.use_typing_indicator: on by default. On iMessage the line shows typing for a moment before the text lands, timed to its length, except before a first message to a new contact (module 4).metadata: up to 20 keys of your own, such as your CRM’s record id, kept with the message.
Lesson 3 of 4Read what came back
A successful send returns 202 Accepted, not 200. It means iSnap has accepted the message for the line, never that it has gone out yet:
{
"success": true,
"data": {
"id": "msg_3Lc6Yp1Hd8Xk2mQ4vTn7Bw9Rz",
"line_id": "line_8Xk2mQ4vTn7Bw9Rz3Lc6Yp1Hd",
"direction": "outbound",
"to": "+14155550123",
"from": "+14155550124",
"body": "Hello from iSnap",
"status": "queued",
"service": null,
"queued_at": "2026-10-08T14:22:57.392Z",
"scheduled_for": "2026-10-08T14:22:57.392Z",
"schedule_reason": null
},
"trace_id": "0af7651916cd43dd8448eb211c80319c",
"request_id": "req_4Tn7Bw9Rz3Lc6Yp1Hd8Xk2mQv"
}From the iSnap docs: Quickstart, send a message
statusisqueuedwhen the message is waiting its turn, orscheduledwhen iSnap is holding it.servicestaysnulluntil the device sends the message; then it says which service it used.scheduled_forandschedule_reasonsay when a held message will go and why: a sending limit is reached, or it is outside quiet hours in the recipient’s time zone (module 5).
The life of a message
| Status | What it means |
|---|---|
queued | Accepted, waiting for the device. |
scheduled | Held by a sending limit or quiet hours; it goes when allowed. A message still held after 48 hours fails. |
sent | The device sent it. |
delivered | Apple reported it delivered. iMessage only. |
read | The person read it and shares read receipts. iMessage only. |
failed | It could not be sent; error_code says why. |
cancelled | You cancelled it before the device took it. |
On SMS, iSnap reports no delivery and no read, so a sent SMS stays sent. To check a message yourself, read it back:
import { ISnapClient } from '@isnap/sdk'
const client = new ISnapClient({ apiKey: process.env.ISNAP_API_KEY ?? '', maxRetries: 2 })
const message = await client.messages.get('msg_3Lc6Yp1Hd8Xk2mQ4vTn7Bw9Rz')
console.log(message.status, message.service, message.sent_at, message.delivered_at, message.error_code)From the iSnap docs: Quickstart, read its status
In production, don’t poll. Subscribe to webhooks and let each change come to you as an event, such as message.delivered or message.failed: that is module 4. And to stop a message that has not left, DELETE /v1/messages/{id} cancels it while it is queued or held. Once the device has taken it, the call answers 409 too_late_to_cancel.
Lesson 4 of 4Retry without sending twice
Networks fail at the worst moment. Your request reaches iSnap, iSnap accepts the message, and the response never makes it back. Retry blindly and the person gets the same text twice. The fix is an idempotency key.
- Generate one key per message (a UUID), store it with your record of the message, and send it in the
Idempotency-Keyheader. Both samples above do exactly this. - Retry with the same key, and iSnap returns the message it already accepted instead of creating a new one. Repeats are recognised for at least 72 hours.
- The SDK adds a key to every write on its own, but pass your own as the sample does, so a retry from another process, or after a restart, reuses it.
When to retry
| Answer | What to do |
|---|---|
429 rate_limit_exceeded | Wait for the Retry-After header, then retry. |
500 or 503 | Retry up to 2 times, with a growing pause. |
Any other 4xx | Do not retry: fix the request. |
| No response at all | Retry with the same idempotency key. Never retry a write without one. |
How fast you can call
The API takes 100 requests per rolling 60 seconds from one network address, across every operation, and 60 per 60 seconds on sending and listing messages (POST and GET /v1/messages together). Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. These cap your server’s request rate. A line’s own sending limits are separate, and module 5 covers them.
When something fails
Errors share one shape: error.status, error.code (a short string such as rate_limit_exceeded) and error.message, with a trace_id and a request_id on every response. Log both ids. They are what support@isnap.ai needs to find your request.
Before you go live
- The key lives in an environment variable on a server, never in a web page or a repository.
- Every send names the id of an
activeline. - Every message has its own idempotency key, stored with it.
- Your code treats
202withscheduledas held, not failed. - A webhook subscription reports what happens next (module 4).
- You have tested on your own number, because test keys send real messages.
Key terms
- API key
- isnap_live_ or isnap_test_ followed by 64 characters. Shown once, never expires, revoked in the dashboard.
- Test key
- An isnap_test_ key. Same account, lines and billing as a live key: it sends real messages.
- Bearer token
- How a key travels: the Authorization header, as Bearer and the key.
- line_id
- The id of the line a message leaves from, such as line_8Xk2mQ4vTn7Bw9Rz3Lc6Yp1Hd. Required on every send.
- E.164
- The international phone number format: a plus sign, the country code, the number. +14155550123.
- 202 Accepted
- iSnap has taken the message for the line. It does not mean sent.
- Held message
- A message with status scheduled: waiting for a limit to free or quiet hours to end. It fails after 48 hours.
- Idempotency key
- A value you choose per write, sent as Idempotency-Key, so a retry returns the first result instead of repeating it.
- trace_id, request_id
- Ids on every response. Log them; support uses them to find your request.
Check yourself
Answer each question in your head first, then open it to compare.
You send with an isnap_test_ key to a colleague’s number. Does their phone get a real text?
Yes. Test keys use the same account, lines and billing as live keys and send real messages. iSnap has no sandbox, so test on your own number.
The response is 202 with status “scheduled”. Did the send fail?
No. iSnap accepted it and is holding it: a sending limit is reached, or it is outside quiet hours in the recipient’s time zone. scheduled_for says when it will go and schedule_reason says why. It fails only if it is still held after 48 hours.
Your send request times out and you never see a response. Is it safe to send again?
Yes, with the same idempotency key. If iSnap accepted the first request, the retry returns that same message instead of sending a second one. Without a key, don’t retry a write at all.
Back to the course, or go deeper in the iSnap API docs.