# Chats

Inbox conversations. A chat belongs to one contact and may span several channels. Reading a chat's messages marks it read.

Version: 1.0.0
License: Proprietary

## Servers

Production
```
https://uinboxpub.api.iclosed.io
```

## Security

### bearerAuth

API key required in Authorization header. Format: `iclosed_<token>`

Type: http
Scheme: bearer
Bearer Format: API key

### oauth2

OAuth 2.1 authorization code with PKCE. Tokens are issued by the iClosed authorization server and accepted by the Unified Inbox API.

Type: oauth2
Authorization URL: https://app.iclosed.io/oauth/authorize
Token URL: https://public.api.iclosed.io/v1/oauth/token
Scopes:
- `inbox.chats:read`: Read inbox chats
- `inbox.chats:write`: Create, update and assign inbox chats
- `inbox.messages:read`: Read inbox messages
- `inbox.messages:write`: Send and retry inbox messages
- `inbox.connections:read`: Read channel connections
- `inbox.analytics:read`: Read inbox analytics
- `inbox.recordings:read`: Read call recordings
- `inbox.recordings:write`: Generate call recording summaries
- `inbox.workflows:read`: Read inbox workflows

## Download OpenAPI description

 - [Chats](https://developer.iclosed.io/_bundle/openapi/uinbox/v1/modules/chats.yaml)

 - [POST /v1/chats](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/listchats.md): Returns one page of the account's chats. page is zero-based and defaults to 0; limit defaults to 20 and cannot exceed 500. data.list is the page, data.count is the total number of matching chats, data
 - [GET /v1/chats/{id}](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/getchat.md): Returns one chat. `{id}` is the chat MongoDB `_id`.
 - [POST /v1/chats/search](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/searchchats.md): Matches chats by contact name, phone, or email. search is at most 200 characters; a longer value is rejected with 400 before the search runs.
 - [POST /v1/chats/counts](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/countchats.md): Returns how many chats match the same filters as POST /v1/chats/, without the page itself. The body takes the same fields and is validated the same way, so a filter this endpoint accepts is one the li
 - [GET /v1/chats/unreadCount](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/getunreadcount.md): Returns data.unreadCount: the number of chats with at least one unread message that this key can see.
 - [GET /v1/chats/statusCounts](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/getchatstatuscounts.md): Returns chat totals for this key as data.open, data.closed, data.all, data.unread and data.unreplied.
 - [POST /v1/chats/contactDetail](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/getcontactdetail.md): Returns the contact behind a chat. contactId is the iClosed contact id, not the chat id. Pass eventCallId to scope the result to one booked call.
 - [POST /v1/chats/new](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/createchat.md): Opens a chat for an existing contact of this account, or returns the one that already exists. contactId is the iClosed contact id; a contact on another account is rejected.
 - [PUT /v1/chats/update](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/updatechat.md): Updates one chat. Send chatId or chatIds, not both; chatId wins and chatIds is ignored. The sample omits chatIds and updateAll.
 - [POST /v1/chats/assign](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/assignchat.md): Assigns one chat. Send chatId or chatIds, not both; chatId wins and chatIds is ignored. The sample omits chatIds and updateAll.
 - [POST /v1/chats/markAsRead](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/markchatread.md): Clears the unread counter on one chat.
 - [POST /v1/chats/markAsUnread](https://developer.iclosed.io/openapi/uinbox/v1/modules/chats/other/markchatunread.md): Flags one chat as unread. The counter is set to 1 regardless of how many messages are actually unread.
