Want an AI assistant such as Claude or ChatGPT to send texts for you? The CallNode MCP server sends them under the same rules as this API.
Send a message
/api/v1/messageshttps://api.callnode.io. Requests are signed with the same X-Api-Key / X-Timestamp / X-Signature HMAC scheme as the Outbound Calls API — a single API key works for both. See Authentication.cn_test_ key to build without sending real messages or being charged. Every compliance check still runs, and you receive a simulated, signed delivery webhook. See Test Mode.Signing example
// Same HMAC scheme as the Outbound Calls API — one API key works for both.
const crypto = require('crypto');
const body = JSON.stringify(payload); // exact bytes you send
const ts = Math.floor(Date.now() / 1000).toString();
const sig = crypto.createHmac('sha256', apiSecret)
.update(ts + '\n' + body)
.digest('hex');
// Headers: X-Api-Key, X-Timestamp: ts, X-Signature: sig,
// X-Idempotency-Key: <uuid>, Content-Type: application/jsonRequest body
| Field | Type | Required | Description |
|---|---|---|---|
to | string (E.164) | Required | Recipient. Plus sign followed by 7–15 digits. |
from | string (E.164) | Required | A messaging-enabled DID you own with an approved 10DLC campaign. |
body | string | Optional | Message text. Required unless media is provided. SMS segments are billed (160 GSM-7 / 70 Unicode chars each). |
media | string[] | Optional | Presence makes the message an MMS. Each entry is either a public URL or the file itself as a base64 data URL (data:image/png;base64,…). JPG, PNG, GIF, WebP, MP4 and PDF; up to 5 MB each. CallNode stores a copy and delivers from its own URL, so a short-lived link or a file you cannot host (an image a model just generated) both work. |
statusWebhookUrl | string | Optional | We POST message.delivered / message.failed events here. Must be a public http:// or https:// address: a loopback, private or internal address is refused with 400 blocked_destination and the message is not sent. |
tcpaOverride | boolean | Optional | Bypass the 8a–9p quiet-hours check (audited). Use only for transactional / relationship messages. |
metadata | object | Optional | Opaque JSON, echoed back on retrieval and status webhooks. |
Example request body
{
"to": "+16135551234",
"from": "+15145550199",
"body": "Your demo is confirmed for Wednesday at 10am.",
"media": [],
"statusWebhookUrl": "https://yourcrm.example.com/sms/events",
"tcpaOverride": false,
"metadata": { "leadId": "lead_abc123" }
}Success response — 202 Accepted
{
"id": "cmpt5ec0w00022hb2etd67258",
"status": "sent",
"cost": 0.01,
"segments": 1,
"idempotencyReplay": false
}Reusing an X-Idempotency-Key returns the original message withidempotencyReplay: true and does not send or charge twice.
Get message status
/api/v1/messages/:id{
"id": "cmpt5ec0w00022hb2etd67258",
"status": "delivered",
"from": "+15145550199",
"to": "+16135551234",
"messageType": "sms",
"segments": 1,
"cost": 0.01,
"errorCode": null,
"errorMessage": null,
"deliveredAt": "2026-05-31T18:04:11.221Z",
"createdAt": "2026-05-31T18:04:08.004Z",
"metadata": { "leadId": "lead_abc123" }
}Delivery states
| Status | Terminal | Description |
|---|---|---|
sent | no | Carrier accepted the message; awaiting a delivery receipt. |
delivered | yes | Carrier confirmed delivery to the handset. |
failed | yes | Delivery failed. See errorCode / errorMessage. |
Status webhooks
Set statusWebhookUrl on a send and we POST a signed event to it when the message reaches a terminal state. Only delivered andfailed fire — sent is not terminal, so it does not trigger a callback. Your metadata is echoed back verbatim.
message.delivered
{
"event": "message.delivered",
"id": "cmpt5ec0w00022hb2etd67258",
"messageId": "1785606116131zibvh2ezw4jaut4q",
"from": "+15145550199",
"to": "+16135551234",
"status": "delivered",
"timestamp": "2026-05-31T18:04:11.221Z",
"errorCode": null,
"deliveredAt": "2026-05-31T18:04:11.221Z",
"metadata": { "leadId": "lead_abc123" }
}message.failed
{
"event": "message.failed",
"id": "cmpt5ec0w00022hb2etd67258",
"messageId": "1785606116131zibvh2ezw4jaut4q",
"from": "+15145550199",
"to": "+16135551234",
"status": "failed",
"timestamp": "2026-05-31T18:04:12.880Z",
"errorCode": "4406",
"deliveredAt": null,
"metadata": { "leadId": "lead_abc123" }
}messageId is the carrier's id; id is the CallNode id you received from the send and can use with GET /api/v1/messages/:id.
Delivery headers
| Header | Value / Purpose |
|---|---|
Content-Type | application/json |
X-Timestamp | Unix seconds at delivery time. Use this when verifying. |
X-Signature | hex-encoded HMAC-SHA256(yourSecret, ts + "\n" + body), signed with the secret of the API key that sent the message. |
X-Event-Source | Always callnode-outbound. Use to disambiguate from other webhook sources sharing the URL. |
Verify the signature
// Verify before trusting the payload. Use the RAW body, not a re-serialised object.
const expected = crypto
.createHmac('sha256', apiSecret)
.update(req.headers['x-timestamp'] + '\n' + rawBody)
.digest('hex');
const ok = crypto.timingSafeEqual(
Buffer.from(req.headers['x-signature']),
Buffer.from(expected)
);
if (!ok) return res.status(401).json({ error: 'bad signature' });express.json({ verify }) before the body is parsed.Messages sent from the dashboard rather than the API arrive unsigned, because there is no API key to sign with. If your endpoint rejects unsigned requests, send via the API.
Compliance (enforced automatically)
STOP / opt-out. When a recipient texts STOP (or UNSUBSCRIBE, CANCEL, END, QUIT) to your number, they are suppressed; further sends to them return 403 recipient_opted_out. START re-enables them. This cannot be overridden.
TCPA quiet hours. Messages are blocked with403 tcpa_window_violationoutside 8 AM–9 PM at the recipient's local time (NPA-NXX → IANA timezone, DST-aware). Set tcpaOverride: truefor permissible transactional messages. Numbers in your Phone Book (your own office, home or family lines, certified once in the dashboard) are not subject to the window; STOP and 10DLC still apply to them.
10DLC registration. The from number must be associated with an approved 10DLC campaign, or the send returns403 campaign_not_registered. This cannot be overridden.
HTTP response codes
| Status | Meaning |
|---|---|
| 200 | Idempotency replay. Original message returned. |
| 202 | Accepted. Message handed to the carrier. |
| 400 | Body malformed (missing to, or no body/media), or invalid_media: an inline file of an unsupported type or over 5 MB. |
| 401 | Auth failed (invalid signature, clock skew, revoked key). |
| 402 | Wallet balance below the message cost. |
| 403 | from_not_owned, recipient_opted_out, tcpa_window_violation, or campaign_not_registered. |
| 404 | Message not found. |
| 429 | Rate limit exceeded. |
| 502 | Carrier rejected the message. |