Skip to main content
PUT
https://jwhite.tail8bf327.ts.net
/
api
/
v1
/
sessions
/
{id}
/
end
End Session
curl --request PUT \
  --url https://jwhite.tail8bf327.ts.net/api/v1/sessions/{id}/end \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "duration": 123,
  "transcript": "<string>",
  "metadata": {}
}
'
{
  "success": true,
  "session": {
    "session_id": 456,
    "agent_id": 123,
    "agent_name": "Sales Support Agent",
    "session_type": "agent_voice",
    "status": "completed",
    "started_at": "2024-01-15T10:30:00Z",
    "ended_at": "2024-01-15T10:35:00Z",
    "duration": 300,
    "transcript": "User: Hello\nAssistant: Hi there! How can I help you today?...",
    "metadata": {
      "end_reason": "user_initiated",
      "satisfaction_score": 5
    }
  },
  "message": "Session ended successfully"
}

Authentication

Requires API key authentication (x-api-key header).
x-api-key: ah_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Path Parameters

id
integer
required
The session ID to end

Request Body

duration
integer
Session duration in seconds (auto-calculated if not provided)
transcript
string
Full transcript of the session
metadata
object
Additional metadata to store with the session

Request

PUT https://jwhite.tail8bf327.ts.net/api/v1/sessions/456/end
x-api-key: ah_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

{
  "duration": 300,
  "transcript": "User: Hello\nAssistant: Hi there! How can I help you today?...",
  "metadata": {
    "end_reason": "user_initiated",
    "satisfaction_score": 5
  }
}

Response

{
  "success": true,
  "session": {
    "session_id": 456,
    "agent_id": 123,
    "agent_name": "Sales Support Agent",
    "session_type": "agent_voice",
    "status": "completed",
    "started_at": "2024-01-15T10:30:00Z",
    "ended_at": "2024-01-15T10:35:00Z",
    "duration": 300,
    "transcript": "User: Hello\nAssistant: Hi there! How can I help you today?...",
    "metadata": {
      "end_reason": "user_initiated",
      "satisfaction_score": 5
    }
  },
  "message": "Session ended successfully"
}
{
  "success": false,
  "error": "Active session not found"
}

Notes

  • Only active sessions can be ended
  • Duration is automatically calculated if not provided
  • The agent’s average duration is updated after ending a session
  • Transcript and metadata are stored for analytics and review