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
| Field | Type | Description |
|---|---|---|
to | string | Recipient: an E.164 phone number, an e-mail address or an inbox user ID (usr_…). |
body | string | Message body in Texts markup. Required unless template is set. |
template | string | Template ID or slug to render instead of body. |
variables | object | Values for {{placeholders}}. Missing variables render as empty strings unless strict is true. |
channel | string | sms, email or inbox. Inferred from to when omitted. |
send_at | timestamp | Schedule delivery up to 30 days ahead. |
strict | boolean | Reject 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
Returns the message object, including status, sent_at, delivered_at and, for failed messages, an error object.
List messages
Results are ordered newest first. Use the next_cursor value from the response as cursor to fetch the following page.
Cancel a scheduled message
Only messages with status scheduled can be cancelled. Others return 409 Conflict.
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.
Renders a template with sample variables for every channel without sending anything. Useful in CI to catch broken placeholders.
Formatting
| Markup | Email / inbox | SMS |
|---|---|---|
*bold* | bold | plain text |
_italic_ | italic | plain text |
[label](url) | link | label: url |
- item | bulleted list | lines 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"
}
}
| Status | Meaning |
|---|---|
400 | The request is malformed or a field failed validation. |
401 | Missing or revoked API key. |
404 | The message or template does not exist in this workspace. |
409 | The object is in a state that does not allow the operation. |
422 | The recipient is unreachable on the selected channel or has opted out. |
429 | Rate limit exceeded. |
5xx | Something went wrong on our side. Retrying with the same Idempotency-Key is safe. |