DELETE
https://api.decisionnode.com /v1/sessions/{id}curl -X DELETE \
https://api.decisionnode.com/v1/sessions/ses_3f9a1c07b2e84d5f6a0c9e12 \
-H "Authorization: Bearer $DECISIONNODE_API_KEY"Ends the session, frees its context and closes its socket. Closing the socket yourself ends the session too, so a client that closes its socket need not call this.
Authentication#
AuthorizationheaderrequiredBearer dn_live_..., the same key as every call. A session belongs to the key that opened it: other keys, even in the same workspace, get404for it (close code4404on the stream).
Path parameters#
idstringrequired- The
session_idthat Open a session returned, for exampleses_3f9a1c07b2e84d5f6a0c9e12.
Request body#
None.
Response#
200 OK with the session's final state. An open socket on the session closes with 1000.
{
"session_id": "ses_3f9a1c07b2e84d5f6a0c9e12",
"model": "decisionnode-1.0",
"status": "ended",
"expires_at": "2026-10-06T09:35:00Z",
"frames_answered": 412,
"frames_dropped": 3,
"frames_cut": 0,
"last_seq": 415,
"tokens_billed": 37656
}session_idstring- The session that ended.
modelstring- The pinned version that answered its frames.
statusstring"ended".expires_atstring- When it would have expired.
frames_answeredinteger- Frames that got a reply.
frames_droppedinteger- Frames passed over because a newer one arrived (latest wins).
frames_cutinteger- Older frames that left the window early, so the recent frames fit
window_tokens. last_seqinteger- The
seqof the last answered frame. tokens_billedinteger- Every input token the session billed: the fixed part and each billed frame.
curl -X DELETE \ https://api.decisionnode.com/v1/sessions/ses_3f9a1c07b2e84d5f6a0c9e12 \ -H "Authorization: Bearer $DECISIONNODE_API_KEY"Errors#
| Status | Type | When | What to do |
|---|---|---|---|
401 | authentication_error | The key is missing, unknown or revoked | Check the Authorization header |
404 | not_found_error | No open session with this id belongs to your key | Nothing: it has already ended |
429 | rate_limit_error | Over your key's request rate | Wait Retry-After seconds, then retry |
500 | api_error | A fault on our side | Retry with backoff and jitter; it is always safe |
Every error body is {"detail": {"error_type": "...", "message": "..."}}, or a list of fields for a 422. Retry 408, 429, 529 and any 5xx, waiting at least what Retry-After says when it is set; fix the request for the other 4xx. All the bodies are on Errors.
Notes#
- Safe to repeat: a second call gets
404, which means the session has ended. The samples treat it as success. - Ending a session bills nothing. What it billed before (the fixed part and each answered frame) stays billed.
- A session ends on its own at
expires_at; call this to free your open-session slot sooner.