## Get messages

**get** `/api/v2/messages`

Retrieve a list of messages for the authenticated account with comprehensive filtering capabilities.
Rate limited to 100 requests per 10 seconds per account.

## Common Use Cases

**Polling for inbound messages (no webhooks):**

```
GET /api/v2/messages?is_outbound=false&sendblue_number=+16292925296&order_by=createdAt&order_direction=desc&limit=50
```

Track processed message IDs to avoid duplicates.

**Get conversation with a specific contact:**

```
GET /api/v2/messages?number=+15551234567&order_by=createdAt&order_direction=desc
```

### Query Parameters

- `account_email: optional string`

  Filter by account email

- `created_at_gte: optional string`

  Filter messages created after this date (ISO 8601 format)

- `created_at_lte: optional string`

  Filter messages created before this date (ISO 8601 format)

- `from_number: optional string`

  Filter by sender phone number

- `group_id: optional string`

  Filter by group ID

- `is_outbound: optional "true" or "false"`

  Filter by message direction. Use `false` to get inbound messages (messages sent TO your Sendblue number).

  **To get inbound messages for polling:** Use `is_outbound=false` combined with `sendblue_number` or `to_number` set to your Sendblue phone number.

  Note: Do NOT use `message_type=inbound` - that parameter only accepts `message` or `group` values.

  - `"true"`

  - `"false"`

- `limit: optional number`

  Maximum number of messages to return

- `message_type: optional "message" or "group"`

  Filter by message type (1:1 vs group chat). Only accepts `message` or `group`.

  **Common mistake:** This is NOT for filtering inbound vs outbound messages. Use `is_outbound` parameter instead.

  - `"message"`

  - `"group"`

- `number: optional string`

  Filter by any phone number (from or to)

- `offset: optional number`

  Number of messages to skip

- `order_by: optional "createdAt" or "updatedAt" or "sentAt"`

  Field to order messages by

  - `"createdAt"`

  - `"updatedAt"`

  - `"sentAt"`

- `order_direction: optional "asc" or "desc"`

  Sort order

  - `"asc"`

  - `"desc"`

- `sendblue_number: optional string`

  Filter by Sendblue phone number

- `sent_at_gte: optional string`

  Filter messages sent after this date (ISO 8601 format)

- `sent_at_lte: optional string`

  Filter messages sent before this date (ISO 8601 format)

- `service: optional "iMessage" or "SMS" or "RCS"`

  Filter by service type

  - `"iMessage"`

  - `"SMS"`

  - `"RCS"`

- `status: optional "REGISTERED" or "PENDING" or "SENT" or 7 more`

  Filter by message status

  - `"REGISTERED"`

  - `"PENDING"`

  - `"SENT"`

  - `"DELIVERED"`

  - `"RECEIVED"`

  - `"QUEUED"`

  - `"ERROR"`

  - `"DECLINED"`

  - `"ACCEPTED"`

  - `"SUCCESS"`

- `to_number: optional string`

  Filter by recipient phone number

- `updated_at_gte: optional string`

  Filter messages updated after this date (ISO 8601 format)

- `updated_at_lte: optional string`

  Filter messages updated before this date (ISO 8601 format)

- `worker_id: optional string`

  Filter by worker ID (Admin only)

### Returns

- `data: optional array of object { accountEmail, content, date_sent, 29 more }`

  - `accountEmail: optional string`

    Email of the account

  - `content: optional string`

    Message content

  - `date_sent: optional string`

    When the message was sent

  - `date_updated: optional string`

    When the message was last updated

  - `error_code: optional number`

    Numeric error code if message failed

  - `error_detail: optional string`

    Detailed error information

  - `error_key: optional string`

    Stable identifier of the rule that declined the message, e.g. `PRE_REPLY_LIMIT_REACHED`
    or `OPTED_OUT`. Branch on this field. `null` when the message was not declined by a rule.

  - `error_message: optional string`

    Error message if message failed

  - `error_reason: optional string`

    Error reason if message failed

  - `from_number: optional string`

    Sender phone number

  - `group_display_name: optional string`

    Display name for group messages

  - `group_id: optional string`

    Group ID for group messages

  - `is_outbound: optional boolean`

    Whether this is an outbound message

  - `is_reaction: optional boolean`

    Present as true only for positively identified inbound reaction additions or removals on supported V2 lines. The handle identifies the reaction event and cannot be an inline-reply target. Absence does not establish replyability.

  - `location: optional object { latitude, longitude, accuracy, 3 more }`

    Decoded Find My location share coordinates.

    - `latitude: number`

    - `longitude: number`

    - `accuracy: optional number`

      Horizontal accuracy in meters

    - `altitude: optional number`

      Altitude in meters

    - `duration: optional string`

      Share duration selected by the recipient

    - `timestamp: optional string`

  - `media_url: optional string`

    URL of attached media

  - `message_handle: optional string`

    Unique message identifier

  - `message_type: optional "message" or "group" or "location"`

    - `"message"`

    - `"group"`

    - `"location"`

  - `number: optional string`

    Primary phone number (to_number for outbound, from_number for inbound)

  - `opted_out: optional boolean`

    Whether the recipient has opted out

  - `participants: optional array of string`

    List of participants for group messages

  - `plan: optional string`

    Account plan used for this message

  - `reply_to: optional object { message_handle, part_index }`

    Immediate parent of an iMessage inline reply. The target must belong to the same
    account, conversation, and sending line.

    - `message_handle: string`

      Public handle of the immediate parent message

    - `part_index: optional number`

      Advanced override for a known part of a multipart target. Omit this in normal
      reply requests and never guess it; requests default to 0. When replying to an
      attachment represented by its own webhook, use that webhook's `message_handle`
      and omit `part_index` so Sendblue can use the stored authoritative part.
      Responses omit it when no authoritative immediate-parent part is available.

  - `seat_id: optional string`

    UUID of the seat that sent the message. Present when `seat_id` was provided on
    send, or for dashboard-originated group messages.

  - `send_style: optional "celebration" or "shooting_star" or "fireworks" or 10 more`

    The iMessage expressive message style

    - `"celebration"`

    - `"shooting_star"`

    - `"fireworks"`

    - `"lasers"`

    - `"love"`

    - `"confetti"`

    - `"balloons"`

    - `"spotlight"`

    - `"echo"`

    - `"invisible"`

    - `"gentle"`

    - `"loud"`

    - `"slam"`

  - `sendblue_number: optional string`

    Sendblue phone number used

  - `sender_email: optional string`

    Email of the seat (user) that sent the message. Auto-populated when a `seat_id`
    is provided on send. `null` for messages sent without a `seat_id`.

  - `service: optional "iMessage" or "SMS" or "RCS"`

    The messaging service used

    - `"iMessage"`

    - `"SMS"`

    - `"RCS"`

  - `status: optional "REGISTERED" or "PENDING" or "SENT" or 7 more`

    - `"REGISTERED"`

    - `"PENDING"`

    - `"SENT"`

    - `"DELIVERED"`

    - `"RECEIVED"`

    - `"QUEUED"`

    - `"ERROR"`

    - `"DECLINED"`

    - `"ACCEPTED"`

    - `"SUCCESS"`

  - `thread_originator: optional object { message_handle, part }`

    Message that originated an iMessage inline-reply thread.

    - `message_handle: string`

      Public handle of the thread's root message

    - `part: optional string`

      Opaque Apple thread-originator part descriptor

  - `to_number: optional string`

    Recipient phone number

  - `was_downgraded: optional boolean`

    Whether the message was downgraded from iMessage to SMS

- `pagination: optional object { hasMore, limit, offset, total }`

  - `hasMore: optional boolean`

    Whether there are more messages available

  - `limit: optional number`

    Number of messages returned in this request

  - `offset: optional number`

    Number of messages skipped

  - `total: optional number`

    Total number of messages matching the filters

- `status: optional string`

### Example

```http
curl https://api.sendblue.co/api/v2/messages \
    -H "sb-api-key-id: $SENDBLUE_API_API_KEY" \
    -H "sb-api-secret-key: $SENDBLUE_API_API_SECRET"
```

#### Response

```json
{
  "data": [
    {
      "accountEmail": "user@example.com",
      "content": "Hello, World!",
      "date_sent": "2024-01-01T12:00:00Z",
      "date_updated": "2024-01-01T12:00:01Z",
      "error_code": null,
      "error_detail": null,
      "error_key": null,
      "error_message": null,
      "error_reason": null,
      "from_number": "+19998887777",
      "group_display_name": null,
      "group_id": null,
      "is_outbound": true,
      "is_reaction": true,
      "location": {
        "latitude": 37.7749,
        "longitude": -122.4194,
        "accuracy": 12,
        "altitude": 8,
        "duration": "oneHour",
        "timestamp": "2026-06-23T12:00:00.000Z"
      },
      "media_url": null,
      "message_handle": "msg_abc123def456",
      "message_type": "message",
      "number": "+18887776666",
      "opted_out": false,
      "participants": [
        "string"
      ],
      "plan": "premium",
      "reply_to": {
        "message_handle": "msg_parent123",
        "part_index": 0
      },
      "seat_id": "550e8400-e29b-41d4-a716-446655440000",
      "send_style": "celebration",
      "sendblue_number": "+19998887777",
      "sender_email": "rep@example.com",
      "service": "iMessage",
      "status": "SENT",
      "thread_originator": {
        "message_handle": "msg_root456",
        "part": "0:0"
      },
      "to_number": "+18887776666",
      "was_downgraded": false
    }
  ],
  "pagination": {
    "hasMore": true,
    "limit": 50,
    "offset": 0,
    "total": 1000
  },
  "status": "OK"
}
```
