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

# Leave a group

> POST /api/v1/chats/:id/leave — leave an iMessage group chat from the pinned line.

<Note>
  **Auth.** HMAC v1 or bearer token — see [Authentication](/api/authentication).
  **Status.** Live · **Idempotent:** No (leaving twice yields `1006` once the chat is no longer a group from your line's perspective).
</Note>

Leaves an iMessage group chat from the line pinned to this chat. The group must have at least 4 participants before leaving so 3 remain afterward. No body required.

## Request

`POST /api/v1/chats/{id}/leave`

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://console.trychert.com/api/v1/chats/ch_01H.../leave \
    -H "x-chert-tenant: $TENANT" \
    -H "x-chert-signature: v1,$TS,$SIG"
  ```

  ```js Node.js theme={null}
  const ts = Math.floor(Date.now() / 1000)
  const body = ""
  const sig = crypto.createHmac("sha256", SIGNING_SECRET).update(`${ts}.${body}`).digest("hex")
  const res = await fetch(`https://console.trychert.com/api/v1/chats/${chatId}/leave`, {
    method: "POST",
    headers: {
      "x-chert-tenant": TENANT_SLUG,
      "x-chert-signature": `v1,${ts},${sig}`,
    },
  })
  ```

  ```python Python theme={null}
  import hmac, hashlib, time, requests
  ts = int(time.time())
  body = ""
  sig = hmac.new(SIGNING_SECRET.encode(), f"{ts}.{body}".encode(), hashlib.sha256).hexdigest()
  r = requests.post(
      f"https://console.trychert.com/api/v1/chats/{chat_id}/leave",
      headers={
          "x-chert-tenant": TENANT_SLUG,
          "x-chert-signature": f"v1,{ts},{sig}",
      },
  )
  ```
</RequestExample>

## Response

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "chat_id": "ch_01H...",
    "status": "left"
  }
  ```
</ResponseExample>

### Path parameters

<ParamField path="id" type="string" required>
  Chat identifier (`ch_…`).
</ParamField>

### Response fields

<ResponseField name="chat_id" type="string">
  The chat that was left.
</ResponseField>

<ResponseField name="status" type="string">
  Always `"left"` on success.
</ResponseField>

## Errors

| Code   | HTTP | When                                                 |
| ------ | ---- | ---------------------------------------------------- |
| `1002` | 400  | Group would have fewer than 3 members after leaving. |
| `1006` | 400  | Chat is a direct message.                            |
| `2002` | 404  | Chat not found.                                      |
| `4001` | 502  | Delivery failed.                                     |
| `4099` | 501  | Group is missing its chat key or has no pinned line. |

See the full [error code reference](/api/errors).

## See also

* [Remove a participant](/api/group-chats/remove-participant)
* [Add a participant](/api/group-chats/add-participant)
* [Create a group](/api/group-chats/create)
