# List messages

Source: https://joinsimplesms.com/docs/api/messages/list
Index: https://joinsimplesms.com/llms.txt

`GET /v1/messages`

Send your API key as a bearer token: `Authorization: Bearer ssms_sk_...`. Test keys run this endpoint against the [sandbox](/docs/sandbox); see [Authentication](/docs/authentication) for key modes and scopes.

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer | No | Default 25. Maximum 100. |
| `cursor` | string | No |  |
| `number` | string | No | Filter to messages to or from this number |
| `to` | string | No | Exact destination number (E.164) |
| `from` | string | No | Exact sending number (E.164) |
| `status` | `queued`, `sent`, `delivered`, `failed`, `blocked`, `received` | No |  |
| `blocked_reason` | `opted_out`, `destination_not_allowed`, `sender_not_registered`, `rate_limited`, `recipient_not_verified`, `quiet_hours`, `content_blocked`, `quota_exceeded`, `spend_limit_reached`, `insufficient_credits`, `topic_unsubscribed` | No | Blocked messages with this reason. Implies status=blocked. |
| `failure_code` | string | No | Failed or blocked messages whose failure.code is this. |
| `direction` | `outbound`, `inbound` | No |  |
| `failure_code` | `carrier_filtered`, `unreachable`, `invalid_number`, `opted_out`, `content_blocked`, `rate_limited`, `landline`, `carrier_rejected`, `spend_limit_reached`, `insufficient_credits`, `sender_not_registered`, `quiet_hours`, `recipient_not_verified`, `quota_exceeded`, `destination_not_allowed`, `topic_unsubscribed`, `unknown` | No | Filter to messages that failed for this reason (the `failure.code` on a message) |
| `created_after` | string | No | Inclusive. ISO timestamp or epoch ms. |
| `created_before` | string | No | Exclusive. ISO timestamp or epoch ms. |
| `customer_id` | string | No | Filter to one customer's messages |
| `schedule_id` | string | No | Filter to the occurrences of one recurring schedule (sch_...) |

Results are paged. When `has_more` is true, pass `next_cursor` from the response as `cursor` to fetch the next page.

## Responses

| Status | Meaning | Body |
| --- | --- | --- |
| 200 | Messages, newest first | Page of `Message` |
| 401 | Missing, malformed, or revoked API key | `Error` |
| 402 | Billable live calls only: the prepaid credit balance cannot cover the call (insufficient_credits); nothing was done or charged | `Error` |
| 429 | Rate limit or quota exceeded | `Error` |

### 200: each item in `data` (Message)

The body is a page: `data` (the array), `has_more`, and `next_cursor` (null on the last page).

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Example: `msg_a1B2c3D4e5F6g7H8`. |
| `object` | `message` |  |
| `to` | string | Example: `+15005550006`. |
| `from` | string | Example: `+15005550100`. |
| `body` | string |  |
| `direction` | `outbound`, `inbound` |  |
| `status` | `queued`, `sent`, `delivered`, `failed`, `blocked`, `received` | `blocked`: refused by one of our checks before any carrier saw it (opt-out, quiet hours, unregistered sender, content, allowance, spend limit, credits). Final, never charged; `failure` says why. `failed`: accepted, then not delivered. |
| `test` | boolean |  |
| `simulated` | boolean | True when nothing was handed to a carrier: every test-key message except one sent to your own verified phone. Always false on live messages. A simulated message still reaches `delivered`. |
| `notice` | string | Only on the response to POST /messages. Present when a test-key send to a real-looking number was simulated: says nothing was sent and how to send for real. |
| `schedule_id` | string | The recurring schedule this message is an occurrence of. Present only when set. |
| `category` | `marketing`, `transactional`, `otp` | How the message was classified for quiet hours. Present when you sent one, or when it was classified as marketing. |
| `deferred` | object | Present when the message was held for quiet hours and sent when the window opened. |
| `deferred.reason` | `quiet_hours` |  |
| `deferred.held_at` | string (date-time) |  |
| `created_at` | string (date-time) |  |
| `media` | array of string (uri) | MMS attachments (inbound today). |
| `sent_by` | string | Console user or API key that composed it. |
| `failure_reason` | string | The carrier's raw text for a failed send. Kept for compatibility; see `failure`. |
| `attempts` | integer | Live sends: carrier submissions so far. More than 1 means it was retried. |
| `next_attempt_at` | string (date-time) | Present while queued for an automatic carrier retry. |
| `receipt_status` | `missing` | The carrier accepted the message but sent no delivery report within 72 hours. status stays sent. |
| `customer_id` | string | The customer this is attributed to. Present only when set. |
| `timeline` | array of object | Every status transition, oldest first. Inbound messages have a single `received`. |
| `timeline[].status` | `accepted`, `validated`, `queued`, `sent_to_carrier`, `carrier_accepted`, `retry_scheduled`, `delivered`, `failed`, `blocked`, `received` |  |
| `timeline[].at` | string (date-time) |  |
| `timeline[].attempt` | integer | Carrier attempt this step belongs to (from sent_to_carrier on). |
| `segments` | integer | Parts the body is split into (GSM-7: 160, then 153 each; UCS-2: 70, then 67). Example: `1`. |
| `encoding` | `gsm7`, `ucs2` |  |
| `price` | object | What this message costs, in USD. One all-in rate per outbound message; carrier fees are included (a 0 line). Null on messages sent before prices were recorded. Nullable. |
| `price.total` | number | Example: `0.009`. |
| `price.currency` | `usd` |  |
| `price.breakdown` | array of object |  |
| `price.breakdown[].label` | string |  |
| `price.breakdown[].amount` | number |  |
| `destination_carrier` | string | The recipient's mobile carrier, when a cached lookup knows it. Nullable. |
| `failure` | Failure | Null unless status is `failed`. Nullable. |

## Errors

| Status | When |
| --- | --- |
| 401 | Missing, malformed, or revoked API key |
| 402 | Billable live calls only: the prepaid credit balance cannot cover the call (insufficient_credits); nothing was done or charged |
| 429 | Rate limit or quota exceeded |

Every error has the same JSON shape, and `request_id` matches the `X-Request-Id` response header. [Errors](/docs/errors) lists every code and what to do about it.

```json
{
  "error": {
    "code": "invalid_request",
    "message": "What went wrong, in plain words.",
    "param": "the_field",
    "request_id": "req_a1B2c3D4e5F6g7H8"
  }
}
```

## Examples

### curl

```bash
curl -X GET "https://api.joinsimplesms.com/v1/messages?limit=10" \
  -H "Authorization: Bearer $SIMPLESMS_API_KEY"
```

### Node.js

```javascript
import { SimpleSMS } from 'joinsimplesms'; // npm install joinsimplesms

const sms = new SimpleSMS(process.env.SIMPLESMS_API_KEY);

const page = await sms.messages.list({ limit: 10 });

for (const message of page.data) console.log(message.id, message.status);
```

### Python

```python
import os
from joinsimplesms import SimpleSMS  # pip install joinsimplesms

client = SimpleSMS(os.environ["SIMPLESMS_API_KEY"])

page = client.messages.list(limit=10)

for message in page["data"]:
    print(message["id"], message["status"])
```

## Related

- Guide: [Messages](/docs/messages)
- [All messages endpoints](/docs/api#messages)
- [API reference](/docs/api)
