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
| Method | When | How |
|---|---|---|
| Whole call | At call start | Set record: true in POST /v1/voice/call |
| Segment | Mid-call | Add 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
| Field | Type | Description |
|---|---|---|
eventUrl | array | Where the recording-ready event is posted |
endOnSilence | number | Stop after N seconds of silence |
endOnKey | string | DTMF key that ends recording (e.g. #) |
beepStart | boolean | Play a beep before recording |
format | string | mp3 or wav |
channels | number | 1 (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
| Code | Description | Solution |
|---|---|---|
RECORDING_NOT_FOUND | Expired or invalid ID | Check retention window |
RECORDING_NOT_READY | Still processing | Wait for the webhook |
CONSENT_REQUIRED | Jurisdiction needs consent | Announce before recording |
📚 Related Resources
Need help? Contact Support → | Last Updated: May 2026