# List ticket messages

> GET https://api.nabrah.ai/api/ext/omni_v2/ticket/{id}/messages

Group: Tickets. Page: https://www.nabrah.ai/en/docs/api-reference/tickets/list-ticket-messages

Returns the message history for a ticket, ordered for display, along with a `meta` block describing the contact, labels, and seen timestamps. Results are paginated with the `before` cursor for loading older messages (infinite-scroll style). Use the embedded ticket `messages` from GET /ticket/{id} for a quick preview, but use this endpoint to page through the complete history.

## Cursor pagination

This endpoint pages backwards in time using a message id cursor, not page numbers.

- **before**: Pass the numeric `id` of the oldest message you have already loaded to fetch the page of messages immediately before it. Omit `before` on the first request to get the most recent page, then repeat with the smallest `id` from `payload` until no older messages are returned.

## Response shape

- **meta**: Conversation-level context: the `contact` object, applied `labels`, and agent/assignee last-seen markers. Fields: `contact`, `labels`, `agent_last_seen_at`, `assignee_last_seen_at`.
- **payload[] — messages**: Each message includes its content, type, sender, privacy flag, and timestamps. `message_type` distinguishes incoming vs outgoing/activity messages; `private` marks internal notes. Fields: `id`, `content`, `content_type`, `message_type`, `private`, `sender`, `created_at`, `conversation_id`.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Path parameters

- `id` (integer, required): Numeric identifier of the ticket whose messages to list. From GET /api/ext/omni_v2/ticket or the create-ticket response.

## Query parameters

- `before` (integer, optional): Message id cursor for fetching older messages. Optional integer. Set it to the smallest message `id` from the previous page to load the next-older page. Omit for the most recent page.

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "meta": {
    "labels": [
      "string"
    ],
    "additional_attributes": {},
    "contact": {
      "additional_attributes": {},
      "custom_attributes": {},
      "email": "string",
      "id": 0,
      "identifier": "string",
      "name": "string",
      "phone_number": "string",
      "thumbnail": "string",
      "blocked": false,
      "type": "string"
    },
    "agent_last_seen_at": "string",
    "assignee_last_seen_at": "string"
  },
  "payload": [
    {
      "content": "string",
      "content_attributes": {},
      "content_type": "string",
      "conversation_id": 0,
      "created_at": 0,
      "echo_id": "string",
      "id": 0,
      "inbox_id": 0,
      "message_type": 0,
      "private": false,
      "sender": {
        "id": 0,
        "name": "string",
        "type": "string",
        "email": "string",
        "phone_number": "string"
      },
      "source_id": "string",
      "status": "string"
    }
  ]
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request GET \
  --url 'https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.get(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages", {
  method: "GET",
  headers: { "X-API-Key": "<your-api-key>" },
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://api.nabrah.ai/api/ext/omni_v2/ticket/<id>/messages", nil)
	req.Header.Set("X-API-Key", "<your-api-key>")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
