Skip to main content

Overview

This endpoint marks a chat session as closed. Closed sessions are archived and no longer receive new messages. Use this when:
  • A user ends a conversation
  • A support ticket is resolved
  • A session is inactive for an extended period
  • You want to create a new session for the same user (fresh context)
Closing a session is idempotent: closing an already-closed session returns success.

Authentication

Requires API key in the X-API-Key header:

Request body

session_id
string
required
The session ID to close.

Request example

Response schema

status
string
Always ok on success.

Response example

Error responses

400 Bad Request

Missing or invalid session ID.

401 Unauthorized

API key is missing, invalid, expired, or revoked.

403 Forbidden

The API key’s plan does not include M2M API access.

404 Not Found

The site does not exist.

500 Internal Server Error

An unexpected error occurred.

Implementation tips

Idempotency

Closing an already-closed session returns success:

When to close a session

Close sessions in these scenarios:
  1. User-initiated: User clicks “End conversation” or closes the chat widget
  2. Time-based: Close sessions inactive for > 24 hours
  3. Status-based: Close sessions when a support ticket is resolved
  4. Context shift: Start a new session when switching topics

Starting a fresh session after closing

When you close a session and want the user to continue, use a new session ID:

Batch closing multiple sessions

Close multiple sessions efficiently:

Marking session state in your database

Track which sessions you’ve closed: