---
title: "Calculate SMS segments"
method: POST
path: "/text/segments"
---

# Calculate SMS segments

`POST /text/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.

## Request body

- object
  - `message` string — A raw message to measure. Provide this OR templateId.
  - `templateId` integer — A template to render and measure. Provide this OR message.
  - `variables` object — Values substituted into the template's placeholders (when using templateId).

## Response `200`

Segment usage for the message.

- SegmentResult
  - `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.
  - `characterCount` integer, required — Number of characters in the message.
  - `gsm7Length` integer — Length in GSM-7 units (extended characters such as { } [ ] ~ \ | ^ € cost 2).
  - `segmentCount` integer, required — Number of SMS segments the message will use.
  - `maxCharsPerSegment` integer, required — Max characters per segment for the chosen encoding (160 GSM-7, 70 UCS-2).
  - `messageSizeBits` integer — Total message size in bits.

## Other responses

- `400` — Body had neither `message` nor `templateId`, or `templateId` was not an integer.
- `429` — Rate limit exceeded.

---

[API](https://skmtc.net/collectwise/apis/collectwise-api.md) · [All operations](https://skmtc.net/collectwise/apis/collectwise-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/collectwise/collectwise-api/versions/a44939a1402b/schema)
