Send Your First SMS
Send an SMS message in under 5 minutes using the Trunx API.
Send a text message, check delivery, and receive replies — all through one endpoint.
Get your API key
If you haven't already, create an API key from the dashboard. You'll need a key with the sms:send scope.
export TRUNX_API_KEY="tk_live_..."Send a message
curl -X POST https://api.trunx.io/sms/send \
-H "Authorization: Bearer $TRUNX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+14155551234",
"from": "415",
"message": "Hello from Trunx! Your verification code is 123456."
}'const response = await fetch("https://api.trunx.io/sms/send", {
method: "POST",
headers: {
Authorization: "Bearer tk_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "+14155551234",
from: "415",
message: "Hello from Trunx! Your verification code is 123456.",
}),
});
const result = await response.json();
console.log(result.id); // msg_abc123import requests
response = requests.post(
"https://api.trunx.io/sms/send",
headers={"Authorization": "Bearer tk_live_..."},
json={
"to": "+14155551234",
"from": "415",
"message": "Hello from Trunx! Your verification code is 123456.",
},
)
result = response.json()
print(result["id"]) # msg_abc123Response:
{
"id": "msg_abc123",
"to": "+14155551234",
"from": "+14155559876",
"status": "queued",
"created_at": "2026-03-09T15:30:00.000Z"
}The from field can be a full E.164 number (+14155559876) or just an area code (415). When you pass an area code, Trunx selects the healthiest DID in that area automatically.
Check delivery status
Poll the message status until it reaches a terminal state (delivered, failed, or undelivered).
curl https://api.trunx.io/sms/messages/msg_abc123 \
-H "Authorization: Bearer $TRUNX_API_KEY"const status = await fetch("https://api.trunx.io/sms/messages/msg_abc123", {
headers: { Authorization: "Bearer tk_live_..." },
}).then((r) => r.json());
console.log(status.status); // "delivered"status = requests.get(
"https://api.trunx.io/sms/messages/msg_abc123",
headers={"Authorization": "Bearer tk_live_..."},
).json()
print(status["status"]) # "delivered"Receive replies
To handle inbound messages, register a webhook for the sms.received event.
curl -X POST https://api.trunx.io/webhooks \
-H "Authorization: Bearer $TRUNX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/sms",
"events": ["sms.received"]
}'When a reply arrives, Trunx sends a POST to your endpoint:
{
"event": "sms.received",
"data": {
"id": "msg_def456",
"from": "+14155551234",
"to": "+14155559876",
"message": "Confirmed, thanks!",
"received_at": "2026-03-09T15:32:00.000Z"
}
}All outbound SMS is scanned for compliance automatically. Messages containing credentials or PII patterns may be blocked. See the guardrails documentation for details.