# Messaging (SMS)

> Send and receive texts on your numbers by API, with a webhook for each text that comes in.

Messaging works on numbers you claimed from [stock](/docs/numbers-stock). Send a text from one of
them, read the texts it sent and received, and get a `message.received`
[webhook](/docs/webhooks) for each text that comes in.

> **NOTE** Messaging is text only for now: no MMS (pictures, video or group texts). Delivery
> receipts are not reported yet: `submitted` means the carrier accepted the text, not that the
> handset got it.

Every call needs a live key (`gk_live_…`). Sandbox keys and accounts still in review get
`403 live_customer_required`. Phone numbers here are E.164, with the `+` (`+14125550123`),
unlike the number endpoints, which take digits only.

## Send a text

```http
POST /v1/gather/lines/message/send
Idempotency-Key: 5b0e7c4a-reminder-8812
Content-Type: application/json

{ "from": "+14125550123", "to": "+14125550188", "text": "Your table is ready." }
```

The body has exactly three fields, and any other field is refused:

| Field | Rules |
| --- | --- |
| `from` | One of your numbers, live and not released. |
| `to` | The recipient. Must be a different number from `from`. |
| `text` | 1 to 1600 characters (Unicode, so emoji count as one each). |

`Idempotency-Key` is required (up to 255 printable characters, no spaces). The same key with the
same body returns the same message, so a retry never sends twice. The same key with a different
body returns `409 idempotency_conflict`. Use one key per text you mean to send.

The response is `202 Accepted` with the message, queued to send:

```json
{
  "id": "msg_2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881",
  "from": "+14125550123",
  "to": "+14125550188",
  "text": "Your table is ready.",
  "direction": "outbound",
  "status": "queued",
  "created_at": "2026-11-05T09:30:00Z",
  "expires_at": "2026-11-05T09:35:00Z"
}
```

`202` means we have the text, not that it was sent. Read it back with its `id` to follow it.

### Statuses

| Status | Meaning |
| --- | --- |
| `queued` | We have it and will hand it to the carrier. |
| `submitting` | Being handed to the carrier now. |
| `submitted` | The carrier accepted it. This is the last status for now: delivery receipts are not reported yet. |
| `failed` | Not sent. `failure_code` says why, for example `expired`. |
| `submission_unknown` | We could not tell whether the carrier took it. It is never resent automatically, so check with the recipient before you send again. |

A text that is not handed to the carrier within 5 minutes (`expires_at`) is not sent:
it becomes `failed` with `failure_code` `expired`, so an old text never goes out late.

## Get one message

```http
GET /v1/gather/lines/message/id?id=msg_2d711642…
```

Returns one of your messages, sent or received, as above. A message that is not yours returns
`404 not_found`.

## List messages

```http
GET /v1/gather/lines/message/list?direction=inbound&number=%2B14125550123
```

| Parameter | |
| --- | --- |
| `direction` | `inbound` (the default) or `outbound`. |
| `number` | One of your numbers, E.164 (encode the `+` as `%2B`). Without it, all your numbers. |
| `limit` | 1 to 100, default 50. |
| `cursor` | The `cursor` from the last page. |

Messages come oldest first, as `data` with a `cursor`:

```json
{
  "data": [
    {
      "id": "msg_a1fce4363854ff888cff4b8e7875d600c2682390412a8cf79b37d0b11148b0fa",
      "from": "+14125550188",
      "to": "+14125550123",
      "text": "Thanks, on my way",
      "direction": "inbound",
      "status": "received",
      "created_at": "2026-11-05T09:31:12Z"
    }
  ],
  "cursor": "eyJwb3NpdGlvbiI6NDIsImJpbmRpbmciOiIuLi4ifQ"
}
```

Pass the `cursor` back with the same `direction` and `number` to get what came after. The cursor
always comes back, even on an empty page, so you can poll with it: keep the last one and ask again
later. A cursor from other filters is refused. Reading a message does not mark or delete it.

## Receiving texts

Texts sent to your number show up as `inbound` messages with status `received`, in `message/list`
and as a `message.received` webhook if you have set one. Use either, or both.

```json
{
  "id": "evt_594e519ae499312b2943",
  "type": "message.received",
  "created_at": "2026-11-05T09:31:12Z",
  "data": {
    "id": "msg_a1fce4363854ff888cff4b8e7875d600c2682390412a8cf79b37d0b11148b0fa",
    "from": "+14125550188",
    "to": "+14125550123",
    "text": "Thanks, on my way",
    "direction": "inbound",
    "status": "received",
    "created_at": "2026-11-05T09:31:12Z"
  }
}
```

There is one event per text, and its `id` comes from the message, so a retried delivery has the
same `id`: dedupe on it. Events are signed like every other [webhook](/docs/webhooks).

A webhook you set (or set again) starts from the next text: texts that arrived before it are not
sent again, so read those with `message/list`. Texts older than the webhook retry window (about two
days) are skipped too.

## Sending limits

Each number has sending limits, so carriers keep treating it as a person's phone and don't flag
or filter it:

| Limit | Default per number |
| --- | --- |
| Texts per minute | 3 |
| Texts per 24 hours | 200 |
| New contacts per 24 hours | 50 |

Windows are rolling, not reset at midnight. A new contact is a number this line has never texted
and that has never texted it, so replying to someone who texted you first does not count against
it. Retrying a send that was already accepted (same `Idempotency-Key`) is not counted again.

A text over a limit is not queued. You get `429 rate_limited` with a `Retry-After` header (seconds
until it would fit), and the message names the limit it hit (`per_minute`, `per_day` or
`new_contacts_per_day`):

```json
{ "error": { "code": "rate_limited", "message": "This number reached its sending limit (per_minute: 3 a minute). Retry after 41 seconds." } }
```

Wait `Retry-After` seconds and send again with the same `Idempotency-Key`.

### Reply ratio

Carriers watch how many texts a number sends compared with how many it gets back. A number
that sends far more than it receives looks automated and gets filtered. So each number also
has a reply-ratio rule: texts out per text in, over a rolling 24 hours and a rolling 6 hours.

| Window | Warns above | Blocks new contacts above | Checked once the number has sent |
| --- | --- | --- | --- |
| 24 hours | 1.5 texts out per text in (100+ sent) | 2.0 texts out per text in | 50 texts in the window |
| 6 hours | 2.0 texts out per text in | 2.5 texts out per text in | 50 texts in the window |

**Replies to people who have texted your number are never blocked by this rule.** While the number
is over, only texts to people who have never texted it are refused. That includes follow-ups to
people you texted who never replied, since those are what push the ratio up. The refusal is
`429 rate_limited` naming `reply_ratio`, with `Retry-After: 3600`. That is an estimate: the number
unblocks by itself as soon as both windows are back under, as replies come in or older sends age out.

Before it gets there, a number over a warning level triggers a
`number.sms_ratio_warning` [webhook](/docs/webhooks), so you can slow down. You also get it if a
send is refused for `reply_ratio`, in case the number jumped past the warning between two sends.
It is sent at most once per number per 24 hours. Its `data` has `line_id`, `number` and `sms_ratio`. `GET number/id` shows the
same `sms_ratio`: sent, received, people sent to, people received from, and the ratio for each
window.

A failed send and an identical retry to the same number within a few seconds count as one text.
The counts are per line: a number that was someone else's before starts fresh.

This rule is an early signal, not a guarantee. Carriers decide what to filter, and a number can
be filtered while under every threshold here. Keep your texts conversational and reply-led.

If your use needs higher limits, tell us; we can change them for your account. See also
[Acceptable use](/docs/acceptable-use).

## Errors

| Status | Code | When |
| --- | --- | --- |
| 403 | `live_customer_required` | A sandbox key, or an account still in review. |
| 404 | `not_found` | `from` is not one of your live numbers, or the message is not yours. |
| 409 | `idempotency_conflict` | The `Idempotency-Key` was used for a different text. |
| 409 | `messaging_unavailable` | The number can't send texts right now, for example while it is suspended. |
| 422 | `invalid_request` | A missing `Idempotency-Key`, an extra field, numbers that are not E.164 or are the same, or `text` empty or over 1600 characters. |
| 429 | `rate_limited` | Over a sending limit. Honour `Retry-After`. |
| 503 | `messaging_not_ready` | Messaging is briefly unavailable. Retry with the same `Idempotency-Key`. |

All errors share one shape: see [Errors](/docs/errors).
