# Search conversations

Searches conversations.

```http
GET https://api.pozy.ai/v1/inbox/conversations/search
```

- Area: Inbox / Messages
- Auth: Authorization: Bearer pz_live_...

## Query parameters

- `query` (string, required)
- `direction` (string): one of incoming, outgoing
- `profileId` (string)
- `platform` (string): one of facebook, instagram, telegram, whatsapp, sms, rcs, slack, imessage
- `accountId` (string)
- `limit` (integer)
- `cursor` (string)

## Example request

```bash
curl -X GET "https://api.pozy.ai/v1/inbox/conversations/search?query=string&limit=20" \
  -H "Authorization: Bearer $POZY_API_KEY"
```

```ts
const res = await fetch("https://api.pozy.ai/v1/inbox/conversations/search?query=string&limit=20", {
  headers: { Authorization: `Bearer ${process.env.POZY_API_KEY}` },
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.get(
    "https://api.pozy.ai/v1/inbox/conversations/search",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    params={
        "query": "string",
        "limit": 20,
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `data`, array of object
  - `conversation`, object
    - `id`, string
    - `platform`, string
    - `accountId`, string
    - `participantName`, string: Can be null
    - `participantUsername`, string: Can be null
    - `participantPicture`, string: Can be null
    - `businessScopedUserId`, string
    - `whatsappUsername`, string
    - `status`, string: One of `active`, `archived`
    - `lastMessage`, string: Can be null
    - `lastMessageAt`, string (date-time): Can be null
  - `matchCount`, integer
  - `matches`, array of object
    - `id`, string
    - `text`, string: Can be null
    - `direction`, string: One of `incoming`, `outgoing`
    - `timestamp`, string (date-time)
- `pagination`, object
  - `hasMore`, boolean
  - `nextCursor`, string: Can be null
- `meta`, object
  - `accountsQueried`, integer
  - `accountsFailed`, integer
  - `failedAccounts`, array of object
    - `accountId`, string
    - `accountUsername`, string: Can be null
    - `platform`, string
    - `error`, string
  - `lastUpdated`, string (date-time)
  - `accountsSkipped`, array of object
    - `accountId`, string
    - `platform`, string

```json
{
  "data": [
    {
      "conversation": {
        "id": "6bfebd43ddc270f6d2c56fc5",
        "platform": "instagram",
        "accountId": "696e0b682d0a31188e7a2ba9",
        "participantName": "Acme",
        "participantUsername": "acme",
        "participantPicture": "string",
        "businessScopedUserId": "61f84cc05876a1c25c483817",
        "whatsappUsername": "acme",
        "status": "active",
        "lastMessage": "Hello from Pozy",
        "lastMessageAt": "2026-10-02T09:00:00.000Z"
      },
      "matchCount": 42,
      "matches": [
        {
          "id": "6bfebd43ddc270f6d2c56fc5",
          "text": "Hello from Pozy",
          "direction": "incoming",
          "timestamp": "2026-10-02T09:00:00.000Z"
        }
      ]
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "string"
  },
  "meta": {
    "accountsQueried": 42,
    "accountsFailed": 42,
    "failedAccounts": [
      {
        "accountId": "696e0b682d0a31188e7a2ba9",
        "accountUsername": "acme",
        "platform": "instagram",
        "error": "string"
      }
    ],
    "lastUpdated": "2026-10-02T09:00:00.000Z",
    "accountsSkipped": [
      {
        "accountId": "696e0b682d0a31188e7a2ba9",
        "platform": "instagram"
      }
    ]
  }
}
```
