End Session
Session APIs
End Session
End an existing session to cleanup resources and terminate conversation context.
DELETE
End Session
End an existing session when the conversation is complete. This is useful for cleanup and resource management.
Example error responses:
400 Bad Request:
401 Unauthorized:
Base URL
End Session
Path Parameters
The ID of your project
Request Headers
Bearer token authentication using your Project API Key (starts with
sk_). Format: Bearer {your-api-key}Request Body
The unique identifier of the session to end
Response
Indicates whether the session was successfully ended
The ID of the ended session
Confirmation message that the session has been ended
Example
Request
Response
Usage Notes
- Resource Cleanup: Ending sessions helps free up server resources and should be done when conversations are complete
- Session Variables: All session variables and conversation context are permanently removed when a session is ended
- Session Management: The API will attempt to end the specified session. Success is returned regardless of whether the session was active
Error Responses
| Status Code | Description |
|---|---|
| 400 | Missing or invalid session_id |
| 401 | Invalid authentication |
| 500 | Internal server error |
Best Practices
- Always End Sessions: End sessions when conversations are complete to prevent resource leaks
- Error Handling: Handle errors gracefully and implement appropriate retry logic for failed requests
- Session Tracking: Keep track of active session IDs in your application to manage them properly
