Calculate SMS segments

Changed on

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

  • Base URL
    https://collectwiseapi.com
  • URL
    https://collectwiseapi.com/text/segments
  • Auth
    API key in header collectwise_key

Headers

x-cw-timestampstring

Required together with x-cw-signature when signing is enabled for this key or organization. POST /security/verify also requires signing whenever a usable secret exists. Canonical Unix seconds, within ±300 seconds. See API Access for CW1 signing.

x-cw-signaturestring

CW1 HMAC-SHA256 signature: v1= followed by 64 lowercase hex digits. Use the decoded 32-byte signing secret and exact request bytes. See API Access.

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.

Changes

    • breaking

      the response property became optional for the status

    • info

      added the new optional header request parameter x-cw-signature

    • info

      added the new optional header request parameter x-cw-timestamp