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)
Authentication
Requires API key in theX-API-Key header:
Request body
The session ID to close.
Request example
Response schema
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:- User-initiated: User clicks “End conversation” or closes the chat widget
- Time-based: Close sessions inactive for > 24 hours
- Status-based: Close sessions when a support ticket is resolved
- 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:Related endpoints
- M2M Chat (Sync) — Send a message
- M2M Chat (Async) — Non-blocking message
- M2M Session List — List all sessions
- M2M Chat Feedback — Rate a response