Developer documentation
Send your first SMS.
A single authenticated request is all it takes. Every accepted message uses the fixed TXTSUPPORT sender ID.
Request
POST
/api/v1/messagesAuthenticate with Authorization: Bearer YOUR_API_KEY. The destination must use E.164 format.
| Field | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Destination in E.164 format. |
message | string | Yes | 1–918 characters. |
Code examples
cURL+
curl -X POST https://sms.txtsupport.co/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"+639171234567","message":"Your code is 482901"}'Node.js+
const response = await fetch('https://sms.txtsupport.co/api/v1/messages', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ to: '+639171234567', message: 'Your code is 482901' })
});
console.log(await response.json());Python+
import requests
response = requests.post(
'https://sms.txtsupport.co/api/v1/messages',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={'to': '+639171234567', 'message': 'Your code is 482901'}
)
print(response.json())PHP+
<?php
$ch = curl_init('https://sms.txtsupport.co/api/v1/messages');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['to' => '+639171234567', 'message' => 'Your code is 482901'])
]);
echo curl_exec($ch);.NET+
using System.Net.Http.Headers;
using System.Net.Http.Json;
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");
var response = await client.PostAsJsonAsync("https://sms.txtsupport.co/api/v1/messages", new { to = "+639171234567", message = "Your code is 482901" });
Console.WriteLine(await response.Content.ReadAsStringAsync());Responses
{
"data": {
"status": "sent",
"sender": "TXTSUPPORT",
"segments": 1,
"credits_remaining": 9
}
}401 invalid key · 402 insufficient credits · 422 invalid request · 502 provider error
Credits & segments
Messages up to 160 characters cost 1 credit. Longer messages are concatenated and charged in 153-character segments, up to 918 characters.