v3.4

API reference

The Texts API is a JSON-over-HTTPS API. All requests go to https://api.texts.tg/v3 and all timestamps are RFC 3339 in UTC.

Authentication

Send your secret key as a bearer token. Requests without a valid key return 401.

Authorization: Bearer tx_live_9d03e1c6b2f84a57

Keys are scoped to one workspace and one environment. Sandbox keys (tx_test_) can only reach verified test recipients.

Messages

Send a message

POST /v3/messages
FieldTypeDescription
tostringRecipient: an E.164 phone number, an e-mail address or an inbox user ID (usr_…).
bodystringMessage body in Texts markup. Required unless template is set.
templatestringTemplate ID or slug to render instead of body.
variablesobjectValues for {{placeholders}}. Missing variables render as empty strings unless strict is true.
channelstringsms, email or inbox. Inferred from to when omitted.
send_attimestampSchedule delivery up to 30 days ahead.
strictbooleanReject the request if any variable is missing. Default false.
POST /v3/messages
Content-Type: application/json
Idempotency-Key: 7b1e5c80-order-10482

{
  "to": "+15555550123",
  "template": "order-shipped",
  "variables": { "name": "Dana", "order": "10482" }
}

Response 201 Created:

{
  "id": "msg_01HV8M3Q2W7Z5K",
  "status": "queued",
  "channel": "sms",
  "segments": 1,
  "rendered": "Hi Dana, your order #10482 has shipped.",
  "created_at": "2026-11-18T09:42:11Z"
}

Retrieve a message

GET /v3/messages/{id}

Returns the message object, including status, sent_at, delivered_at and, for failed messages, an error object.

List messages

GET /v3/messages?status=failed&limit=50

Results are ordered newest first. Use the next_cursor value from the response as cursor to fetch the following page.

Cancel a scheduled message

DELETE /v3/messages/{id}

Only messages with status scheduled can be cancelled. Others return 409 Conflict.

Templates

POST /v3/templates
{
  "slug": "order-shipped",
  "body": "Hi {{name}}, your order *#{{order}}* has shipped.",
  "fallback_locale": "en",
  "locales": {
    "de": "Hallo {{name}}, deine Bestellung *#{{order}}* ist unterwegs."
  }
}

Set locale on a message to pick a translation. If the locale is missing, fallback_locale is used.

POST /v3/templates/{slug}/preview

Renders a template with sample variables for every channel without sending anything. Useful in CI to catch broken placeholders.

Formatting

MarkupEmail / inboxSMS
*bold*boldplain text
_italic_italicplain text
[label](url)linklabel: url
- itembulleted listlines prefixed with “•”
{{name|upper}}variable with a filter: upper, lower, title, truncate:20

SMS bodies are split into 160-character segments (70 when the text contains characters outside GSM-7). The segments field in the response tells you how many were billed.

Rate limits

Each workspace may make 100 requests per second; bursts up to 300 are allowed. Every response carries X-RateLimit-Remaining and X-RateLimit-Reset. When you exceed the limit you get 429 with a Retry-After header in seconds.

Errors

Errors use standard HTTP status codes and a consistent body:

{
  "error": {
    "type": "invalid_request",
    "code": "missing_variable",
    "message": "Variable 'order' is required by template 'order-shipped'.",
    "param": "variables.order"
  }
}
StatusMeaning
400The request is malformed or a field failed validation.
401Missing or revoked API key.
404The message or template does not exist in this workspace.
409The object is in a state that does not allow the operation.
422The recipient is unreachable on the selected channel or has opted out.
429Rate limit exceeded.
5xxSomething went wrong on our side. Retrying with the same Idempotency-Key is safe.