Preview SMS POST
Calculates the credit a message would use and its encoding without sending and without deducting credit. Takes the same body as Send SMS.
Authorization
API Key (Authentication) in the header Authorization: Bearer <API_KEY>.
HTTP Request
http
POST https://public-api.smsup-plus.com/sms/previewContent Type
application/json (JSON only)
Parameter Description
Same body as Send SMS. Fields that affect the result:
| Property | Type | Required | Description |
|---|---|---|---|
messages | array | Required | At least 1 |
messages[].from | string | Required | Must not be empty (sender approval is not checked) |
messages[].destinations | array | Required | At least 1, and every item needs a to (number format is not checked) |
messages[].text | string | Required | Text to calculate |
messages[].shorturl | string | Optional | Y = count each URL as a short link |
messages[].sendAt | string | Optional | If sent, must be RFC3339 |
Other fields (bulkId, notifyUrl, messageId, …) are accepted but do not change the result.
Response Description
| Property | Type | Description |
|---|---|---|
status | number | 200 |
data.totalCredit | number | Total credit = sum of (credit per recipient × number of destinations) over all messages — counts every number sent, including ones that may be rejected on a real send |
data.creditPerMessage | number | Credit per recipient of the first message (including the shorturl effect) |
data.messageCount | number | SMS parts of the first message text (without the shorturl effect) |
data.encoding | string | Encoding of the first message: ascii = standard character set, thai = Unicode (contains a character outside the standard set — not necessarily Thai) |
Part-counting rules: see Credit calculation.
Request Example
bash
curl -X POST 'https://public-api.smsup-plus.com/sms/preview' \
-H 'Authorization: Bearer <API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"messages": [
{
"from": "MyBrand",
"destinations": [{ "to": "0812345678" }, { "to": "0898765432" }],
"text": "สวัสดีครับ คำสั่งซื้อของคุณจัดส่งแล้ว"
}
]
}'js
const res = await fetch('https://public-api.smsup-plus.com/sms/preview', {
method: 'POST',
headers: { Authorization: 'Bearer <API_KEY>', 'Content-Type': 'application/json' },
body: JSON.stringify({
messages: [
{
from: 'MyBrand',
destinations: [{ to: '0812345678' }, { to: '0898765432' }],
text: 'สวัสดีครับ คำสั่งซื้อของคุณจัดส่งแล้ว',
},
],
}),
})
console.log(await res.json())Response Example
json
{
"status": 200,
"data": {
"totalCredit": 2,
"creditPerMessage": 1,
"messageCount": 1,
"encoding": "thai"
}
}Possible Errors
See Error Codes for the overview.
| HTTP | Response | Cause |
|---|---|---|
| 400 | {"error":{"statusCode":"400","description":"Invalid request body","message":"BAD_REQUEST"}} | Body is not valid JSON, or messages is missing/empty |
| 400 | {"error":{"statusCode":"400","description":"Destinations not found","message":"BAD_REQUEST"}} | A message has no destinations, or a destination has an empty to |
| 400 | {"error":{"statusCode":"400","description":"Text not found","message":"BAD_REQUEST"}} | text is empty |
| 400 | {"error":{"statusCode":"400","description":"sender not found","message":"BAD_REQUEST"}} | from is empty |
| 400 | {"error":{"statusCode":"400","description":"sendAt must be in RFC3339 format (e.g. 2026-04-10T09:00:00+07:00)","message":"BAD_REQUEST"}} | sendAt has a bad format |
| 429 | {"error":{"statusCode":"429","description":"rate limit exceeded: max 50 requests per second per account","message":"TOO_MANY_REQUESTS"}} | Too many requests — wait as told by Retry-After |
Preview does not run every send check
Preview does not check sender approval, remaining credit, number format, the 1,600-character limit or the recipient cap — a request that previews fine can still be rejected by Send SMS.
