# Close a chat

`POST /v1/contacts/{id}/close`

Closes the contact's chat.

Needs `chats:write`.

## Path parameters

- `id` (string, uuid): The contact's ID.

## Headers

- `Idempotency-Key` (string): Makes this request safe to retry. See [Retrying safely](/reference/api/#retrying-safely). 1 to 255 characters.

## After it closes

The bot answers the customer again, even if an agent is still assigned. The chat opens again when the customer writes, or with `POST /v1/contacts/{id}/reopen`.

## Closing twice

Closing a closed chat changes nothing and still returns `200`. `chat.closed` is sent only if the chat was open. The request takes no body: send none, or `{}`.

## Example

```sh
curl -X POST https://app.soosh.io/v1/contacts/4ea0d485-435d-407f-837a-c7d67095f23a/close \
  -H "Authorization: Bearer $SOOSH_API_KEY" \
  -H "Idempotency-Key: close-chat-example-1"
```

Response 200:

```json
{
  "contact_id": "4ea0d485-435d-407f-837a-c7d67095f23a",
  "status": "closed",
  "assigned_agent_id": "5b1d7d0e-3c2a-4f61-9a0e-6f8f3b2c1d40",
  "team_id": null,
  "contact": null
}
```

## Returns

200. The chat as it is now. `contact` is `null` unless your key also has `contacts:read`.

## Errors

Besides the ones every request can get (https://docs.soosh.io/reference/api/errors/):

- 404 `not_found`: There is no contact with this ID in your workspace.
- 409 `idempotency_in_progress`: A request with the same `Idempotency-Key` is still running.
- 422 `idempotency_mismatch`: The `Idempotency-Key` was used before for a different request, or by another of your API keys.