> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracklysms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Message Segments & Encoding

> How SMS message segments work, GSM-7 vs UCS-2 encoding, and how segments affect billing

Every SMS message is split into one or more **segments** before delivery. The number of segments determines your per-message cost — Trackly bills per segment, not per message.

## What is a Segment?

A segment is a fixed-size chunk of an SMS message. Short messages fit in one segment. Longer messages are split across multiple segments, each with overhead bytes for reassembly headers.

## GSM-7 vs UCS-2 Encoding

SMS supports two character encodings. The encoding is chosen automatically based on the characters in your message.

| Encoding  | Character Set                           | Single Segment | Multi-Segment (per part) |
| --------- | --------------------------------------- | -------------- | ------------------------ |
| **GSM-7** | Latin letters, digits, common symbols   | 160 characters | 153 characters           |
| **UCS-2** | Full Unicode (emoji, non-Latin scripts) | 70 characters  | 67 characters            |

If **every** character in your message is in the GSM-7 basic set, the message uses GSM-7 encoding. If **any** character falls outside GSM-7, the entire message switches to UCS-2.

### GSM-7 Basic Character Set

The GSM-7 basic set includes:

* **Letters**: A-Z, a-z
* **Digits**: 0-9
* **Symbols**: `@ £ $ ¥ ! " # ¤ % & ' ( ) * + , - . / : ; < = > ? ¡ ¿ § _`
* **Accented characters**: `è é ù ì ò Ç Å å Ä ä Ö ö Ñ ñ Ü ü à Æ æ ß É`
* **Greek letters**: `Δ Φ Γ Λ Ω Π Ψ Σ Θ Ξ`
* **Special**: `Ø ø` and standard whitespace (space, newline, carriage return)

## Characters That Trigger UCS-2

These commonly used characters force UCS-2 encoding, dramatically reducing your per-segment character limit:

* **Emoji** (any emoji forces UCS-2)
* **Smart quotes**: \u201c \u201d \u2018 \u2019 (use straight quotes " ' instead)
* **Em dash**: \u2014 (use a hyphen - instead)
* **Ellipsis character**: \u2026 (use three periods ... instead)
* **Non-Latin scripts**: Chinese, Arabic, Cyrillic, etc.

<Warning>
  A single emoji in a 160-character message increases it from 1 segment (GSM-7) to 3 segments (UCS-2), tripling the cost.
</Warning>

## Segment Calculation

The platform calculates segments using this algorithm:

1. Check if all characters are in the GSM-7 basic character set
2. If GSM-7: use 160-char limit (single) or 153-char limit (multi-part)
3. If UCS-2: use 70-char limit (single) or 67-char limit (multi-part)
4. Divide the message length by the per-segment limit, rounding up

### Examples

| Message                                           | Length    | Encoding | Segments    |
| ------------------------------------------------- | --------- | -------- | ----------- |
| "Your order ships today."                         | 24 chars  | GSM-7    | 1           |
| "Your code is 482910. Valid for 5 min."           | 38 chars  | GSM-7    | 1           |
| "Big sale! Save 50% on all items. Shop now at..." | 160 chars | GSM-7    | 1           |
| "Big sale! Save 50% on all items. Shop now at..." | 161 chars | GSM-7    | 2 (153 + 8) |
| "Thanks for signing up! \ud83c\udf89"             | 25 chars  | UCS-2    | 1           |
| A 140-character message with one emoji            | 140 chars | UCS-2    | 2 (70 + 70) |

## Billing Impact

Trackly bills per segment at tiered rates:

* **First 1M segments** (in a 360-day cycle): \$0.0045/segment
* **After 1M segments**: \$0.0030/segment

A 2-segment message costs twice as much as a 1-segment message. Keeping messages within the single-segment GSM-7 limit (160 characters) is the most cost-effective approach.

## Tips for Reducing Segments

1. **Avoid emoji** — they force UCS-2 encoding and cut your limit from 160 to 70 characters
2. **Use straight quotes** — replace smart quotes (\u201c \u201d) with straight quotes (" ")
3. **Use short links** — Trackly's link shortener creates compact URLs that save characters
4. **Keep messages under 160 characters** — one GSM-7 segment is the sweet spot for cost and deliverability
5. **Test with the API** — send a test message and check the `segments` field in the response

## Template Length Cap

Creative templates are limited to **1,600 characters**. This prevents accidentally creating messages that would produce an excessive number of segments.

## Next Steps

<CardGroup cols={2}>
  <Card title="Creative Templates" icon="paintbrush" href="/guides/creatives/templates">
    Design effective message templates
  </Card>

  <Card title="Platform Limits" icon="gauge" href="/guides/platform-limits">
    View all platform limits
  </Card>
</CardGroup>
