# Texts

Emergency texts received from the SMSCs, and the texts Ella PSAP sends, each in an [incident](<https://docs.ellanetworks.com/psap/reference/api/incidents/index.md>).

## List Texts

Returns the emergency texts received and the replies sent.

| Method | Path |
| --- | --- |
| GET | `/api/v1/texts` |

### Query Parameters

| Name | Description |
| --- | --- |
| `incident` | Only the texts of the incident with this ID. |
| `number` | Only texts from or to this phone. |
| `direction` | `in` or `out`. |
| `after` | Only texts with a greater `id`. |
| `limit` | 1 to 500. Default: `100`. |
| `order` | `asc`, oldest first, or `desc`, newest first. Default: `asc`. |
| `wait` | Seconds, 0 to 30, to wait for a matching text when there is none yet. On timeout, `items` is empty. Default: `0`. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `items` | array | The texts. |
| `items[].id` | integer | ID of the text. |
| `items[].incident_id` | string | The ID of the [incident](<https://docs.ellanetworks.com/psap/reference/api/incidents/index.md>) of the text. |
| `items[].direction` | string | `in`: from the phone. `out`: to the phone. |
| `items[].number` | string | The phone. |
| `items[].emergency_number` | string | The emergency number: the destination of a received text, the source of a sent one. |
| `items[].smsc` | string | The SMSC. |
| `items[].encoding` | string | `gsm7`, `ucs2`, `ascii`, `latin1` or `binary`. |
| `items[].text` | string | The text. Empty for `binary`. |
| `items[].status` | string | Received: `received` or `incomplete`. Sent: `sending`, `sent`, `delivered` or `failed`. |
| `items[].error` | string | Why the text failed, or could not be decoded. |
| `items[].parts` | array | For a sent text, each part: `part`, `message_id`, `status` and `error`. Empty for a received text. |
| `items[].pdus` | array | The `deliver_sm` or `submit_sm` of each part. See [PDU](<#pdu>). |
| `items[].created_at` | string | Time the text was received or sent. |
| `items[].updated_at` | string | Time of the last change of status. |

### PDU

The fields of one `deliver_sm` or `submit_sm`.

| Field | Type | Description |
| --- | --- | --- |
| `command` | string | `deliver_sm` or `submit_sm`. |
| `source`, `destination` | object | `ton`, `npi` and `addr`. |
| `esm_class`, `protocol_id`, `priority_flag`, `registered_delivery`, `data_coding` | integer | As in the PDU. |
| `user_data` | string | `short_message`, or `message_payload`, in hexadecimal. |
| `user_message_reference`, `sar_msg_ref_num`, `sar_total_segments`, `sar_segment_seqnum`, `source_port`, `destination_port` | integer | The optional parameter, or `null`. |
| `peer` | string | The SMSC node the `deliver_sm` came from. Empty for a `submit_sm`. |
| `message_id` | string | Empty. The `message_id` of each sent part is in `parts`. |

### Sample Response

```
{
    "result": {
        "items": [
            {
                "id": 1,
                "incident_id": "urn:emergency:uid:incidentid:01M8Y7C5PM7FKCY9P1VEKRJMB1:psap.example.org",
                "direction": "in",
                "number": "15551230001",
                "emergency_number": "911",
                "smsc": "ella-smsc",
                "encoding": "gsm7",
                "text": "Help, someone broke into my house.",
                "status": "received",
                "error": "",
                "parts": [],
                "pdus": [
                    {
                        "command": "deliver_sm",
                        "source": {"ton": 1, "npi": 1, "addr": "15551230001"},
                        "destination": {"ton": 0, "npi": 1, "addr": "911"},
                        "esm_class": 0,
                        "protocol_id": 0,
                        "priority_flag": 3,
                        "registered_delivery": 0,
                        "data_coding": 0,
                        "user_data": "48656c702c...",
                        "user_message_reference": 12,
                        "sar_msg_ref_num": null,
                        "sar_total_segments": null,
                        "sar_segment_seqnum": null,
                        "source_port": null,
                        "destination_port": null,
                        "peer": "10.90.3.5:2775",
                        "message_id": ""
                    }
                ],
                "created_at": "2026-12-01T12:00:00.000Z",
                "updated_at": "2026-12-01T12:00:00.000Z"
            }
        ]
    }
}
```

## Get a Text

Returns one text with its delivery state.

| Method | Path |
| --- | --- |
| GET | `/api/v1/texts/{id}` |

## Send a Text

Sends a text to a phone through an SMSC, in an open incident.

| Method | Path |
| --- | --- |
| POST | `/api/v1/texts` |

### Request Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `incident_id` | string | No | The ID of the open incident of the text. Default: the open incident with texts to or from `to`, else a new incident. |
| `to` | string | Yes | The phone: 1 to 20 digits. |
| `text` | string | Yes | 1 to 10000 characters. |
| `from` | string | No | 1 to 20 digits. Default: the `number` of the latest text from `to`, else the `callback_number` of the [SIP trunk](<https://docs.ellanetworks.com/psap/reference/api/sip_trunks/index.md>) of the incident's latest emergency call. Required when there is neither. |
| `smsc` | string | No | Default: the SMSC of the latest text from `to`, else of the latest AML report from `to`, else the `smsc` of the [SIP trunk](<https://docs.ellanetworks.com/psap/reference/api/sip_trunks/index.md>) of the incident's latest emergency call, else the only enabled SMSC with a bound texts session. |

## Count Texts

Returns how many texts were received and sent.

| Method | Path |
| --- | --- |
| GET | `/api/v1/texts/counts` |

### Query Parameters

| Name | Description |
| --- | --- |
| `since` | RFC 3339 time. Default: 24 hours ago. |

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `since` | string | Start of the count. |
| `received` | integer | Texts from phones, without AML. |
| `sent` | integer | Texts to phones. |

### Sample Response

```
{
    "result": {
        "since": "2026-11-30T12:00:00Z",
        "received": 4,
        "sent": 2
    }
}
```
