Skip to main content

Call Recording

Record entire calls or specific segments for quality assurance, compliance, and transcription. Recordings can be enabled at call creation or triggered mid-call with an NCCO record action.

🎚️ Two Ways to Record​

MethodWhenHow
Whole callAt call startSet record: true in POST /v1/voice/call
SegmentMid-callAdd a record action to the NCCO

📞 Record at Call Start​

curl -X POST https://api.afriroute.ai/api/v1/voice/call \
-H "Authorization: Bearer $AFRIROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "+251116000000",
"to": "+251911234567",
"answer_url": "https://yourapp.com/voice/answer",
"record": true
}'

🎙️ Record a Segment (NCCO)​

[
{ "action": "talk", "text": "Please leave a message after the beep." },
{
"action": "record",
"eventUrl": ["https://yourapp.com/voice/recording"],
"endOnSilence": 3,
"endOnKey": "#",
"beepStart": true,
"format": "mp3"
}
]

Record Action Parameters​

FieldTypeDescription
eventUrlarrayWhere the recording-ready event is posted
endOnSilencenumberStop after N seconds of silence
endOnKeystringDTMF key that ends recording (e.g. #)
beepStartbooleanPlay a beep before recording
formatstringmp3 or wav
channelsnumber1 (mixed) or 2 (split per leg)

🔔 Recording Webhook​

When the recording is ready, AfriRoute posts its location:

app.post('/voice/recording', async (req, res) => {
const { call_id, recording_id, recording_url, duration } = req.body;
console.log(`Recording ${recording_id} (${duration}s): ${recording_url}`);
await saveRecording(call_id, recording_url);
res.sendStatus(200);
});
{
"call_id": "call_abc123",
"recording_id": "rec_xyz789",
"recording_url": "https://api.afriroute.ai/api/v1/voice/recordings/rec_xyz789",
"format": "mp3",
"duration": 38,
"size": 304128,
"timestamp": "2026-05-28T10:30:42Z"
}

⬇️ Download a Recording​

GET /v1/voice/recordings/:recording_id
curl https://api.afriroute.ai/api/v1/voice/recordings/rec_xyz789 \
-H "Authorization: Bearer $AFRIROUTE_API_KEY" \
--output call.mp3
import requests

audio = requests.get(
'https://api.afriroute.ai/api/v1/voice/recordings/rec_xyz789',
headers={'Authorization': 'Bearer $AFRIROUTE_API_KEY'}
)
with open('call.mp3', 'wb') as f:
f.write(audio.content)

🗑️ Retention & Deletion​

Recordings are retained for 90 days by default, then auto-deleted. Delete earlier for compliance:

DELETE /v1/voice/recordings/:recording_id

💡 Best Practices​

  • Announce recording at the start of the call where law requires consent.
  • Use 2-channel recording when you need to separate agent and caller audio.
  • Prefer MP3 for storage efficiency, WAV for transcription accuracy.
  • Download promptly or store the URL — recordings expire after retention.
  • Encrypt recordings at rest if they contain personal or payment data.

⚠️ Error Handling​

CodeDescriptionSolution
RECORDING_NOT_FOUNDExpired or invalid IDCheck retention window
RECORDING_NOT_READYStill processingWait for the webhook
CONSENT_REQUIREDJurisdiction needs consentAnnounce before recording

Need help? Contact Support → | Last Updated: May 2026