Delete session
Delete a session, stop execution, and remove public history; returns 409 while cleanup is incomplete.
Endpoint
Returns 200 and a delete envelope. Deletion stops the session's execution, closes input acceptance, and removes public history.
If cleanup is incomplete, the API returns 409 conflict_error; retry the same request. After deletion completes, repeating DELETE still returns 200 with the delete envelope, while GET returns 404. An unknown session ID or a cross-workspace DELETE returns 404.
/agents/sessions/{session_id}Path parameters
session_idstringRequiredSession ID. Treat it as an opaque string
This endpoint has no request body or query parameters.
Request example
curl -sS -X DELETE "$BASE_URL/agents/sessions/sess_xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1"
client.beta.agents.sessions.delete("sess_xxx")
Response fields
idstringID of the deleted session
objectstringSession deletion result object type, fixed as agent.session.deleted
deletedbooleanWhether deletion succeeded, true when deletion succeeds
Response example
{
"id": "sess_xxx",
"object": "agent.session.deleted",
"deleted": true
}
Error codes
Business errors return an error object with type, code, message, and param. Common errors:
| HTTP status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error | Pass a valid session ID in the expected format |
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
404 | not_found_error / not_found_error | Use a non-archived session ID from the current workspace |
409 | conflict_error / conflict_error | Retry the same request |
503 | server_error / agents_api_upstream_unavailable | Retry later. If it keeps failing, submit a ticket with x-request-id |