Subcore AI Docs
Agents API

Call recordings

Record an agent's phone calls, keep the audio with each call's session, and play it back in the console. How to turn it on, what to tell callers, where recordings are kept, and the two routes your deployment stores them through.

An agent can record its phone calls. Subcore keeps each recording with the call's session, and you play it in the console beside the transcript. A transcript shows what was said. A recording shows how it sounded: a long pause before the agent answers, the agent talking over the caller, a name said badly.

Recording is off for every agent until someone turns it on. A recording is a person's voice, so turning it on is a choice you make for each agent.

Turn it on

In the console, an admin goes to the agent's Configuration → Connection tab and opens the voice channel's side sheet from the routing map. Record calls is there, under the voice engine.

With the agents API, send recordCalls:

curl -X PUT -H "Authorization: Bearer $SUBCORE_API_KEY" \
  -H "Content-Type: application/json" \
  "https://api.subcore.ai/agents/clinic-one" \
  -d '{ "recordCalls": true }'
  • recordCalls is true or false. Anything else, null included, is refused with 400 INVALID_RECORD_CALLS, and nothing in that PUT is written.
  • Every Agent object carries it.
  • Your deployment reads it with the rest of the agent's configuration on every call, so a change applies from the agent's next call.
  • Calls the agent answers and calls it places with POST /outbound are both recorded.
  • Set it back to false to stop. Recordings already stored are kept.

Subcore does not tell callers they are being recorded, and many places require that you do. Add a line such as "This call may be recorded" to the agent's greeting yourself. Nothing is added to the greeting for you.

When a call is not recorded

A call with recordCalls on still goes unrecorded when:

  • The deployment is structural. A structural deployment keeps what callers say out of Subcore, and a recording is what they say, so it never records, whatever recordCalls says. The console says so under Record calls, and does not let you turn it on; a setting already on can still be turned off.
  • The deployment runs a kit from before 0.49.0. The console says the build does not record calls yet. The setting applies once the deployment runs kit 0.49.0 or later.
  • The deployment's project never registered the recording callback route. A project that calls registerVoiceRoutes itself must also call registerRecordingStatusRoute, or every recording would stay at Twilio. Until it does, the deployment records nothing, and the console treats it as it treats a structural one.
  • The deployment does not send its telemetry to Subcore. With nowhere to store the audio, it does not record. A deployment sends telemetry when it runs with NODE_ENV=production or TELEMETRY_ENABLED=true, and not with TELEMETRY_ENABLED=false or NODE_ENV=test. Its describe document still says callRecording: true.
  • It is a Playground conversation or an eval. That is typed text, not a call.
  • It happened before the switch was on. There is nothing to fetch.

A recording covers the agent's part of the call. It stops when the agent's conversation ends, so a transfer to a person is not recorded. On relay voice, about the first second of the transfer may be.

Recording never fails a call. If the recording cannot be started or stored, the call goes on as usual, and the session in the console says the recording could not be stored.

A few cases leave a recording at Twilio with nothing in the session to say so, all of them a change between the call's start and Twilio's callback: the deployment was redeployed with a different SUBCORE_API_KEY, or redeployed so that it no longer records, or the agent's Twilio connection changed. Delete those copies in Twilio if you do not want them kept.

Where recordings are kept

Each recording is stored in Subcore as an MP3, with its call's session. Anyone in your organization who can open the session can play it.

  • Twilio's copy is deleted. Twilio makes the recording. Once Subcore has stored it, a few minutes after the call, your deployment deletes Twilio's copy, so there is one copy, kept under one set of rules. If storing fails, or deleting Twilio's copy does, Twilio's copy stays where it is, so nothing is lost. It stays there until someone deletes it in Twilio.
  • A recording lasts as long as its session. Subcore does not delete recordings on a schedule. When an admin deletes a session in the console, its recording is deleted with it. A recording that arrives after its session was deleted is not stored, and Twilio's copy stays. So is one whose call's events never reached Subcore, which is rare: Subcore cannot tell the two apart. Deleting an agent deletes all its recordings.
  • Twilio charges for it. The Twilio account the call runs on, the deployment's or the agent's own, pays for each recorded minute, and for keeping the recording until it is deleted.

Play a call

Open a voice session in the console. When it has a recording, the session sheet opens wider, with a player across the top: play and pause, the waveform, the time, the speed and mute. A recording that is still being stored does not show yet, so the sheet opens as usual for a few minutes after the call.

Under the waveform, markers show the moments that matter:

MarkerShows
Tool callA tool the agent called, the transfer tool included. Red when it failed
Slow replyThe agent took more than 2 seconds to start answering
Agent errorThe agent failed to answer a turn
Call endHow the call ended: transferred, sent to voicemail, or hung up by the caller or agent

Click a marker to play from just before it, and the transcript scrolls to that turn. Each message shows its time in the call, and clicking it plays from there. Turn on Follow audio to keep the turn you are hearing in view while the call plays. On a wide screen, a column beside the transcript lists the call's facts and its events.

The markers line up with the audio to within about a second on relay voice, and closer on realtime. The player's link to the audio works for an hour, so a copied link stops working.

What your deployment does

Your deployment does all of this by itself, with its deployment key. You never call the two routes below. They are set out here so you can see the path a recording takes, and read a deployment's logs without guesswork.

  1. When the call starts, the deployment asks Twilio to record it, and sends a call.recording.started event.
  2. When the agent's part of the call ends, it stops the recording.
  3. When Twilio has the audio ready, it calls the deployment back, at an address the deployment signed when it started the recording, so the deployment acts only on recordings it started. The deployment downloads the audio from the account the call ran on. It asks Subcore where to upload it with POST /telemetry/recordings, uploads the MP3 there, and confirms with POST /telemetry/recordings/{recordingSid}/stored.
  4. Once Subcore confirms, it deletes Twilio's copy.

What describe says

The deployment's describe document says whether it records calls, as deployment.callRecording. The console reads it, and describe_deployment returns it.

ValueMeaning
trueIt records an agent's calls once that agent's recordCalls is on, while it sends its telemetry to Subcore
falseIt is structural, or its project never registered the recording callback route, and it records nothing
Not thereIts kit is from before 0.49.0, and records nothing

The events it sends

EventDataSent
call.recording.started{ "recordingSid", "startedAt" }When Twilio starts recording. startedAt is in milliseconds on the deployment's clock, the same clock as every other event, which is how each event is placed on the audio
call.recording.failed{ "stage", "reason" }When a recording could not be started, stopped, fetched from Twilio, stored in Subcore or cleaned up. stage is one of the five below
stageWhat failed
startTwilio would not start recording, or the deployment has no Twilio key for the call's account. Nothing is recorded
stopThe recording could not be stopped when the agent's part ended, so the rest of the call, a transfer included, is in it too
fetchThe deployment could not get the recording: Twilio's read or download failed, the recording was not ready, the agent's settings could not be read, no Twilio key fit, or the recording is not the one the deployment started. reason is absent when Twilio recorded nothing
storeSubcore could not store it. Twilio's copy stays
cleanupThe recording is stored, but Twilio's copy could not be deleted, so it stays there too

A stop failure does not stop the store: the recording runs to the end of the call and is stored as usual, unless a later fetch or store fails. A cleanup failure comes after the recording was stored, so it plays as usual.

call.recording.started comes during the call. The recording is stored after the call ends, so a call.recording.failed about fetching, storing or cleaning it up comes after the call's session.ended. Neither event reopens a session that has ended, or changes its summary. Read them with GET /telemetry/events, for instance with eventType=call.recording.failed.

Start an upload

POST /telemetry/recordings
{
  "serviceName": "clinic-one",
  "sessionId": "voice-CA0123456789abcdef0123456789abcdef",
  "callSid": "CA0123456789abcdef0123456789abcdef",
  "recordingSid": "RE0123456789abcdef0123456789abcdef",
  "startedAt": "2026-11-16T15:04:05Z",
  "durationSeconds": 102,
  "bytes": 408576
}
FieldTypeDescription
serviceNamestringThe agent's slug. It must be an agent your organization already has. Unlike the telemetry your deployment sends, this never creates one
sessionIdstringThe call's session: voice-{callSid} on relay voice, voice-rt-{callSid} on realtime
callSidstringTwilio's call SID: CA and 32 lowercase hex characters
recordingSidstringTwilio's recording SID: RE and 32 lowercase hex characters
startedAtstring | nullWhen Twilio says the recording started, as an ISO 8601 time. May be null or left out
durationSecondsintegerHow long the recording is, from 0 to 86400
bytesintegerThe MP3's size, from 1 to 52428800 (50 MB)

The answer is 201:

{
  "uploadUrl": "https://…/storage/v1/object/upload/sign/call-recordings/…?token=…",
  "path": "…/RE0123456789abcdef0123456789abcdef.mp3",
  "expiresInSeconds": 7200
}

The deployment then sends the MP3 to uploadUrl with a PUT and Content-Type: audio/mpeg, within two hours. Nothing but an MP3 of at most 50 MB is taken there, and the URL never replaces an MP3 already there. The same request sent again, for the same call, is answered again with a new uploadUrl until the upload is confirmed. After that it is answered 200 with "stored": true and no uploadUrl, since there is nothing left to send.

Confirm an upload

POST /telemetry/recordings/{recordingSid}/stored

The body gives the path the first request answered:

{ "path": "…/RE0123456789abcdef0123456789abcdef.mp3" }

Subcore checks that the MP3 is there at the size the first request gave. The answer is 200:

{ "recordingSid": "RE0123456789abcdef0123456789abcdef", "stored": true }

Only then does the console show the recording, and only then does the deployment delete Twilio's copy. Sending it again is harmless. If the session or the agent was deleted since the first request, the recording is gone: when path names the MP3 just sent, it is removed and the answer is 410. Without a path, or with nothing uploaded there, the answer is 404.

Rules and errors

Both routes take the deployment key as a bearer token and need its telemetry permission. Like telemetry ingestion, neither is rate limited, since both run just after a call. Every refusal is the usual { "error", "code", "timestamp" }.

StatuscodeMeaning
401AUTHENTICATION_ERRORNo key, or an invalid, revoked or expired one
400AUTHENTICATION_ERRORThe Authorization header is not Bearer followed by a key
403FORBIDDENThe key has no telemetry permission. On start, also a key whose permissions.cores does not reach the agent
400INVALID_JSON, INVALID_BODYStart: the body is not JSON, or not an object
400INVALID_SERVICE_NAMEStart: serviceName is missing or empty
400INVALID_CALL_SID, INVALID_RECORDING_SIDA SID is not CA or RE and 32 lowercase hex characters. On confirm, the one in the path
400INVALID_SESSION_IDStart: sessionId is not voice-{callSid} or voice-rt-{callSid} for this callSid
400INVALID_STARTED_ATStart: startedAt is neither a time nor null
400INVALID_DURATIONStart: durationSeconds is not a whole number from 0 to 86400
400INVALID_BYTESStart: bytes is not a whole number above 0
413RECORDING_TOO_LARGEStart: bytes is over 52428800
413PAYLOAD_TOO_LARGEThe request body is over 16 KiB
404NOT_FOUNDStart: no agent with this slug in your organization. Confirm: no such recording in your organization, one for an agent the key does not reach, or a deleted one whose path names no upload
409RECORDING_CONFLICTStart: this recording SID is already stored for another call, or another request is storing it at the same moment
409NOT_UPLOADEDConfirm: nothing has been uploaded yet
409SIZE_MISMATCHConfirm: the upload is not the size the first request gave. error gives both sizes
410SESSION_DELETEDStart: the call's session has no events, because it was deleted or, rarely, its events never arrived. Confirm: the session or the agent was deleted since the start, and the MP3 at path is removed. Either way the recording is not kept, and Twilio's copy stays
500DATABASE_ERRORA query failed, or on confirm the recording changed while it was checked. Try once more: the retry answers as the recording is now
503STORAGE_UNAVAILABLEStorage could not prepare, check or remove an upload. Try once more

On this page