Developers

POST/v3/smslength

Calculate SMS encoding and segments

Analyze final message text without sending it or estimating delivery charges.

On this page
  1. Analyze the exact message text
  2. Request
  3. Response
  4. Encoding and segment limits
  5. Errors and empty text
  6. Use the result before sending

Analyze the exact message text

Calculate the encoding, encoded length and SMS segment count for the text you intend to send. This endpoint does not send an SMS, reserve a route or return a delivery-price quote. Submit the complete final text, including any footer, link or opt-out wording that your sending workflow adds.

Request

Authenticate using your enabled API account and its allowed source IP address. Keep credentials in server-side secret storage. Send a UTF-8 string in the text field; the example uses environment variables.

curl --silent --show-error --user "$API_USER:$API_PASSWORD" \
  --data-urlencode 'text=Your message here' \
  https://api.multitel.net/v3/smslength

Form-encoded input is supported. A JSON object such as {"text":"Your message here"} is also accepted when no form or query fields are supplied. Prefer POST so message text does not appear in a URL. If both form and query input are present, the form is used. Do not mix request formats.

Response

{
  "status": {
    "code": "200",
    "msg": ""
  },
  "response": {
    "charset": 0,
    "encoding": "GSM-7",
    "count": 1,
    "parts": 1,
    "chars": 17,
    "units": 17,
    "single_limit": 160,
    "multipart_limit": 153
  }
}
Calculator result fields
FieldMeaning
charset0 for GSM-7 or 2 for UTF-16.
encodingGSM-7 or UTF-16.
parts, countTwo names for the calculated number of SMS segments. Both are zero for empty text.
units, charsTwo names for encoded units. They do not necessarily equal visible characters.
single_limitEncoded-unit limit for a single segment with the selected encoding.
multipart_limitEncoded-unit limit used for each segment after concatenation overhead.

Encoding and segment limits

Limits used by the calculator
EncodingSingle segmentMultipart segment
GSM-7160 septets153 septets
UTF-1670 code units67 code units

GSM-7 extension characters such as ^, braces, brackets, backslash, vertical bar, tilde and the euro sign consume two septets. A character outside GSM-7 switches the complete message to UTF-16 counting. An emoji outside the basic multilingual plane uses two UTF-16 units; a visible emoji sequence can contain several code points.

For example, 160 ordinary GSM-7 letters fit one segment and 161 require two. Eighty ^ characters use 160 units and fit one segment; eighty-one use 162 units and require two. Thirty-five simple non-BMP emoji use 70 UTF-16 units and fit one segment; thirty-six use 72 units and require two. Combining marks and joined emoji can change those counts.

Errors and empty text

A missing text field, an array/object instead of a scalar value, or invalid UTF-8 returns API code 403. Read JSON status.code and status.msg as well as the HTTP status; this endpoint returns the code as a string. An empty string is valid and returns zero units and zero segments.

Use the result before sending

The reviewed calculator contains no message send, carrier call or account debit. Its result is an analysis of the submitted text, not a delivery guarantee or a final bill. Sending can have destination rates, carrier fees, campaign requirements and additional text transformations. Recalculate after changing the message, then use the approved sending workflow and current account pricing.