# End a conversation session

URL: https://www.atmee.ai/docs/v2/api/reference/session/forceEndSession

`POST /v1/sessions/{session_id}/end`

Ends a session started with `POST /v1/sessions` now: the room
closes and the avatar leaves. End it with the credential that
started it:

- **API key** — a session your backend started. Billing stops; the
  session settles `completed` with `endReason: ended_by_api`,
  billed only for the time both the visitor and the avatar were in
  the room. **Idempotent**: ending one that already ended answers
  `200` with `alreadyEnded: true` (`AvatarSessionEndResponse`). Read
  its state and cost with `GET /v1/sessions/{id}`.
- **Signed-in user** — a website session of the user's account.
  Ending one that already ended answers `409`
  (`ForceEndSessionResponse` on success).

With both credentials, the API key's end applies.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `session_id` | path | yes | Session ID to forcefully end |

## Responses

| Status | Description | Schema |
| --- | --- | --- |
| `200` | The session is ended (API key: or already was, `alreadyEnded`). | object |
| `401` | A missing, invalid or revoked API key or bearer token. | none |
| `403` | The session belongs to another account, or (API key) its avatar is not on the key's allow-list (`avatar_not_allowed`). | object |
| `404` | No such session. With an API key, also a website session of the account (not one started through the API). | object |
| `409` | (Signed-in user) the session has already ended. | `ErrorResponse` |
| `422` | The `session_id` path parameter is not a valid UUID. Returned by the request-validation layer before the handler runs. | `FrameworkErrorResponse` |
| `500` | Internal server error (API key `finalize_failed`; retry). | object |
| `503` | The room could not be closed from here right now (API key `session_unavailable`, retry after `Retry-After`; ending is idempotent), or the session is not managed by this process. | object |
