Atmee.aiDocs
APIAPI referenceAvatar sessions

End an avatar session

POST
/v1/avatar_sessions/{id}/end

Ends an API session now and stops billing. It settles completed with endReason: ended_by_api. For a conversation, this is the same as POST /v1/sessions/{id}/end with an API key.

  • Idempotent: a session that already ended answers 200 with alreadyEnded: true, so it is safe to call from every teardown path.
  • Renders usually end on their own when your agent leaves, the room closes or you remove the avatar participant. Call this to stop paying while your room stays open; it does not remove the avatar from your room, so remove the participant yourself.
  • Conversations: the room is closed.
  • Only sessions started through the API can be ended here (website sessions are 404), and an avatar-scoped key ends only its avatar's.

Authorization

headerX-Api-Key<token>

Your secret API key (sk_atmee_...; older keys start sk_live_), sent as X-Api-Key. Keep it on your server and never send it to a browser.

Path Parameters

id*string

The avatar session id (sessionId from the create response).

Formatuuid

Response Body

The session is ended (or already was).

application/json
  1. response
sessionId*string
Formatuuid
status*string
Value in"completed""failed"
endedAt?string
Formatdate-time
alreadyEnded*boolean

True when the session was already terminal before this call.

endReason?string

Why the session ended: ended_by_api for this call, or the earlier reason when it had already ended (see AvatarSessionStatusResponse.endReason).

Example Request
curl -X POST 'https://api.atmanity.us/v1/avatar_sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/end'
Example Response
{  "sessionId": "f6567dd8-e069-418e-8893-7d22fcf12459",  "status": "completed",  "endedAt": "2019-08-24T14:15:22Z",  "alreadyEnded": true,  "endReason": "string"}