How to fetch calls, transcripts and recordings through the API
Three requests return everything that happened on your calls: the list, one call with its transcript, and the recording file. You need an API key with the calls:read scope.
How do I list calls?
The last 20 completed calls
curl 'https://platform.direnium.com/api/v1/calls?status=completed&limit=20' \
-H 'Authorization: Bearer <API-KEY>'| Field | Description |
|---|---|
agentId | Only calls of one agent. |
status | One of: active, completed, failed, no_answer, voicemail. |
direction | One of: inbound, outbound. |
phone | Only calls with one number. |
from, to | A date range. |
includeTests | Include test calls too. Default: no. |
limit, offset | Paging. limit defaults to 50 and goes up to 100. |
The response has calls, an array of calls, and total, the number of calls that match the filter. Each call has, among others, id, status, direction, durationSeconds, summary, sentiment, collectedVariables and recordingUrl.
How do I fetch one call with its transcript?
One call
curl 'https://platform.direnium.com/api/v1/calls/<CALL-ID>' \
-H 'Authorization: Bearer <API-KEY>'Response (shortened)
{
"id": "<CALL-ID>",
"direction": "outbound",
"status": "completed",
"durationSeconds": 142,
"summary": "The customer booked an annual service for Tuesday.",
"sentiment": "positive",
"collectedVariables": [
{ "name": "car_model", "value": "Mazda 3" }
],
"recordingUrl": "https://platform.direnium.com/api/v1/calls/<CALL-ID>/recording",
"transcript": [
{ "role": "agent", "content": "Hi, this is Eve from the garage.", "at": 0 },
{ "role": "user", "content": "Hi, yes.", "at": 3 }
]
}In transcript each row is one sentence: role is agent, user or system, and content is the text. A call that does not exist returns 404.
How do I download the recording?
Download the recording to a file
curl 'https://platform.direnium.com/api/v1/calls/<CALL-ID>/recording' \
-H 'Authorization: Bearer <API-KEY>' \
-o call.mp3The address in recordingUrl is the same address, so it needs the key too. When there is no recording you get 404.
See also: how to place a call right away through the API and how to receive updates with webhooks.