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

# Search Messages

> Search connector messages with complex filters

## Endpoint

`POST https://api.apifycloud.io/api/v1/analytics/{appId}/messages/search`

## Authentication

Bearer token required.

Scope: `messages:read`

## Path parameters

* `appId` (UUID, required)

## Request body

* `limit` (number, optional)
* `cursor` (string, optional)
* `status` (string, optional)
* `direction` (string, optional) e.g. `inbound`, `outbound`
* `channel` (string, optional)
* `messageType` (string, optional)
* `source` (string, optional)
* `destination` (string, optional)
* `search` (string, optional) matches `user_phone`, `provider_message_id`, `conversation_key`, `provider_from`, `provider_to`
* `startDate` (string, optional) ISO date (YYYY-MM-DD)
* `endDate` (string, optional) ISO date (YYYY-MM-DD)

```json theme={null}
{
  "limit": 25,
  "status": "pending",
  "direction": "outbound",
  "channel": "whatsapp",
  "messageType": "text",
  "source": "api",
  "destination": "gupshup",
  "search": "57300"
}
```

## Response

```json theme={null}
{
  "data": [
    {
      "id": "string",
      "source": "string",
      "destination": "string",
      "provider_from": "string",
      "provider_to": "string",
      "channel": "whatsapp",
      "direction": "outbound",
      "message_type": "text",
      "user_phone": "573001112233",
      "conversation_key": "string",
      "provider_message_id": "string",
      "status": "string",
      "error_message": null,
      "sent_at": "2024-01-01T00:00:00.000Z",
      "failed_at": null,
      "created_at": "2024-01-01T00:00:00.000Z",
      // ... more connector fields are available in detail endpoint
    }
  ],
  "meta": {
    "timestamp": "2024-01-01T00:00:00.000Z"
  },
  "pagination": {
    "limit": 25,
    "hasMore": false,
    "nextCursor": null
  }
}
```

## Errors

* `400 invalid_request` invalid JSON body
* `403 forbidden` unauthorized for app or missing scope
* `400 validation_error` invalid request parameters
* `429 rate_limit_exceeded`
* `500 server_error`

## Example

```bash theme={null}
curl -X POST "https://api.apifycloud.io/api/v1/analytics/{appId}/messages/search" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "limit": 25,
    "status": "pending",
    "direction": "outbound",
    "channel": "whatsapp",
    "search": "57300"
  }'
```
