v1

latestOpenAPI 3.0.1MIT2026-07-22241852.5 KB

Calculate SMS segments

Returns how many SMS segments a message will use, matching the Twilio segment calculator. Provide either a raw message, or a templateId with variables (the template is rendered first, then counted). This endpoint does not send anything.

post/text/segments

Request body

messagestring

A raw message to measure. Provide this OR templateId.

templateIdinteger

A template to render and measure. Provide this OR message.

variablesobject

Values substituted into the template's placeholders (when using templateId).

Response

Segment usage for the message.

encoding'GSM-7' | 'UCS-2' required

Encoding the message is sent with. Any non-GSM-7 character (emoji, smart quotes, most CJK) forces the whole message to UCS-2.

characterCountinteger required

Number of characters in the message.

gsm7Lengthinteger

Length in GSM-7 units (extended characters such as { } [ ] ~ \ | ^ € cost 2).

segmentCountinteger required

Number of SMS segments the message will use.

maxCharsPerSegmentinteger required

Max characters per segment for the chosen encoding (160 GSM-7, 70 UCS-2).

messageSizeBitsinteger

Total message size in bits.