> ## Documentation Index
> Fetch the complete documentation index at: https://deepline.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Unipile: Get Chat Messages

> Get message history from a chat. Includes SDK V2 guidance, input constraints, response fields, and Deepline credit cost.

Get message history from a chat.

> [!NOTE]
>
> Tool ID: `unipile_get_chat_messages`

## Run this action

Use the TypeScript SDK for one call. Use `ctx.tools.execute(...)` inside a Play for durable calls, scheduled calls, or CSV processing.

```ts theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
import { Deepline } from 'deepline';

const deepline = await Deepline.connect();
const result = await deepline.tools.execute(
  'unipile_get_chat_messages',
  {
    "chat_id": "chat_123"
  },
);

console.log(result.toolResponse.raw);
```

### CLI

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline tools execute unipile_get_chat_messages --input '{
  "chat_id": "chat_123"
}' --json
```

## Example response

The SDK returns this shape at `result.toolResponse.raw`. The example values illustrate the response.

```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
{
  "data": {
    "items": [
      {
        "object": "Message",
        "id": "id_123",
        "chat_id": "chat_123"
      }
    ],
    "cursor": "cursor_123",
    "object": "MessageList"
  }
}
```

Use `deepline describe unipile_get_chat_messages --json` for the latest machine-readable contract.

## Input reference

Retrieve message history for a chat. Most recent messages first.

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `payload.chat_id` | `string` | Yes | — | Chat ID |
| `payload.sender_id` | `string` | No | — | Only messages from this sender. |
| `payload.before` | `string` | No | — | Only items created before this ISO 8601 UTC datetime. Format: `date-time`. |
| `payload.after` | `string` | No | — | Only items created after this ISO 8601 UTC datetime. Format: `date-time`. |
| `payload.limit` | `integer` | No | — | Page size, 1-250. Minimum: 1. Maximum: 250. |
| `payload.cursor` | `string` | No | — | Cursor from the previous page. |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "Retrieve message history for a chat. Most recent messages first.",
    "properties": {
      "chat_id": {
        "type": "string",
        "description": "Chat ID"
      },
      "sender_id": {
        "type": "string",
        "description": "Only messages from this sender."
      },
      "before": {
        "type": "string",
        "description": "Only items created before this ISO 8601 UTC datetime.",
        "format": "date-time"
      },
      "after": {
        "type": "string",
        "description": "Only items created after this ISO 8601 UTC datetime.",
        "format": "date-time"
      },
      "limit": {
        "type": "integer",
        "description": "Page size, 1-250.",
        "minimum": 1,
        "maximum": 250
      },
      "cursor": {
        "type": "string",
        "description": "Cursor from the previous page."
      }
    },
    "required": [
      "chat_id"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output reference

Standard tool result payload.

| Name | Type | Required | Default | Details |
| - | - | - | - | - |
| `result.data` | `object` | Yes | — | Provider response payload. |
| `result.data.items` | `array` | No | — | — |
| `result.data.items[].object` | `"Message"` | No | — | Allowed: `Message`. |
| `result.data.items[].id` | `string` | No | — | — |
| `result.data.items[].chat_id` | `string` | No | — | — |
| `result.data.items[].account_id` | `string` | No | — | — |
| `result.data.items[].provider_id` | `string` | No | — | — |
| `result.data.items[].sender_id` | `string` | No | — | — |
| `result.data.items[].sender_attendee_id` | `string` | No | — | — |
| `result.data.items[].text` | `string \| null` | No | — | — |
| `result.data.items[].timestamp` | `string` | No | — | Format: `date-time`. |
| `result.data.items[].is_sender` | `unknown` | No | — | Truthy when the connected account sent the message |
| `result.data.items[].attachments` | `array` | No | — | — |
| `result.data.items[].seen` | `unknown` | No | — | Unipile 'seen' flag |
| `result.data.items[].delivered` | `unknown` | No | — | Unipile 'delivered' flag |
| `result.data.items[].hidden` | `unknown` | No | — | Unipile 'hidden' flag |
| `result.data.items[].deleted` | `unknown` | No | — | Unipile 'deleted' flag |
| `result.data.items[].edited` | `unknown` | No | — | Unipile 'edited' flag |
| `result.data.cursor` | `string \| null` | No | — | — |
| `result.data.object` | `"MessageList"` | No | — | Allowed: `MessageList`. |
| `result.meta` | `object` | No | — | Additional response metadata (status, paging). |

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "type": "object",
    "description": "Standard tool result payload.",
    "properties": {
      "data": {
        "type": "object",
        "description": "Provider response payload.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "object": {
                  "type": "string",
                  "enum": [
                    "Message"
                  ]
                },
                "id": {
                  "type": "string"
                },
                "chat_id": {
                  "type": "string"
                },
                "account_id": {
                  "type": "string"
                },
                "provider_id": {
                  "type": "string"
                },
                "sender_id": {
                  "type": "string"
                },
                "sender_attendee_id": {
                  "type": "string"
                },
                "text": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "timestamp": {
                  "type": "string",
                  "format": "date-time"
                },
                "is_sender": {
                  "description": "Truthy when the connected account sent the message"
                },
                "attachments": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  }
                },
                "seen": {
                  "description": "Unipile 'seen' flag"
                },
                "delivered": {
                  "description": "Unipile 'delivered' flag"
                },
                "hidden": {
                  "description": "Unipile 'hidden' flag"
                },
                "deleted": {
                  "description": "Unipile 'deleted' flag"
                },
                "edited": {
                  "description": "Unipile 'edited' flag"
                }
              },
              "additionalProperties": false
            }
          },
          "cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "object": {
            "type": "string",
            "enum": [
              "MessageList"
            ]
          }
        },
        "additionalProperties": false
      },
      "meta": {
        "type": "object",
        "description": "Additional response metadata (status, paging).",
        "additionalProperties": true
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Deepline cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.

## Related documentation

* [Unipile provider guide](/docs/providers/unipile/guide.md)
* [SDK V2 quickstart](/docs/sdk-v2/quickstart.md)
* [SDK reference](/docs/sdk-v2/sdk-reference.md)
* [Run tools across a CSV](/docs/sdk-v2/batch-csv.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.