Needs keys Sends one text message (or MMS when you include media_urls) from one of your numbers through Telnyx and stores it. Real delivery needs TELNYX_API_KEY. Without it, mock mode records the request in List telephony operations and marks the message sent. For a two-way conversation with an agent, use an SMS chat instead.
Request#
| Field | Type | Required | Description |
|---|---|---|---|
from_number |
string | Yes | A number in your workspace, in E.164. |
to_number |
string | Yes | Recipient in E.164. |
content |
string | Conditional | Message text, up to 1600 characters. Required unless you send media_urls. Default "". |
media_urls |
string[] | Conditional | Up to 10 http(s) URLs to attach as MMS. Required unless you send content. |
If the recipient is a contact marked do-not-contact, nothing is sent: the message is stored with status failed and error Recipient opted out (do-not-contact).
Example request#
curl -X POST https://api.tried.com.au/send-sms \
-H "Authorization: Bearer $TRIED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_number": "+14155550123",
"to_number": "+14155559876",
"content": "Your appointment is confirmed for Tuesday at 10:30 am."
}'const res = await fetch("https://api.tried.com.au/send-sms", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TRIED_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from_number: "+14155550123",
to_number: "+14155559876",
content: "Your appointment is confirmed for Tuesday at 10:30 am.",
}),
});
const message = await res.json();import os, requests
res = requests.post(
"https://api.tried.com.au/send-sms",
headers={"Authorization": f"Bearer {os.environ['TRIED_API_KEY']}"},
json={
"from_number": "+14155550123",
"to_number": "+14155559876",
"content": "Your appointment is confirmed for Tuesday at 10:30 am.",
},
)
message = res.json()Response#
201 Created
{
"message_id": "sms_9c4e1a7b3d052f86a1c0e9b4",
"chat_id": null,
"call_id": null,
"direction": "outbound",
"from_number": "+14155550123",
"to_number": "+14155559876",
"content": "Your appointment is confirmed for Tuesday at 10:30 am.",
"status": "queued",
"provider_message_id": "40318f6c-8a2b-4d7e-b951-2e6c0a3f7d14",
"error": null,
"created_timestamp": 1792396800000
}| Field | Type | Description |
|---|---|---|
message_id |
string | Message ID, sms_ plus 24 hex characters. |
chat_id |
string or null | The SMS chat the message belongs to. null for messages sent with this endpoint. |
call_id |
string or null | The call that sent it, for messages sent by an agent during a call. |
direction |
string | outbound or inbound. |
status |
string | queued, sent, delivered, failed or received. Telnyx delivery reports later move it to sent, delivered or failed. |
provider_message_id |
string or null | The Telnyx message ID. |
error |
string or null | Why the message failed, up to 500 characters. |
media_urls |
string[] | MMS attachments. Left out when there are none. |
created_timestamp |
integer | Unix ms. |
A provider failure does not return an error status: the request returns 201 with status failed and the reason in error.
Errors#
| Status | When |
|---|---|
400 |
Body validation failed (for example body: content or media_urls is required), or to_number ... is not E.164. |
401 |
Missing or invalid API key. |
403 |
The key's IP allowlist or scopes reject the request. This route needs the calls scope. Also returned for the member role (The member role is read-only) and when business verification is required and not approved (... before you can send SMS). |
404 |
from_number ... is not a number in this workspace. |
429 |
Rate limit exceeded. See Rate limits. |
See Errors for the body format.