Call Detail Records (CDR): Fields, Formats, KPIs and How to Build a CDR Pipeline
A call detail record (CDR) is a record that a phone system writes for each call attempt. It captures who called whom, when the call started, answered, and ended, how long it lasted, which route carried it, and why it ended. CDRs are the foundation of billing, analytics, fraud detection, troubleshooting, and reporting in any VoIP platform.
If you operate a PBX, a contact center, a carrier-facing platform, or a voice AI service, your CDRs are your most reliable source of truth about what actually happened on your network.
What a CDR contains
Exact fields vary by system, but most CDRs include:
| Field | Meaning |
|---|---|
| Call ID / UUID | Unique identifier for the call, used to correlate records and logs |
| Caller (CLI/ANI) | The calling number or identity |
| Called number (DNIS) | The dialed destination |
| Start time | When the call attempt began |
| Answer time | When the call was answered, if it was |
| End time | When the call ended |
| Duration | Total time from start to end |
| Billable duration (billsec) | Time from answer to end, which is usually what is billed |
| Disposition / hangup cause | Why the call ended (answered, busy, no answer, failed, rejected) |
| SIP response code | Final SIP result such as 200, 486, 503 |
| Direction | Inbound, outbound, or internal |
| Trunk / route / carrier | Which path carried the call |
| Source and destination IP | Where signaling came from and went to |
| Codec | Negotiated audio codec |
| Account or tenant | Which customer or extension the call belongs to |
| Rate and cost | Price per minute and computed charge, if rated |
Some platforms add quality data such as jitter and packet loss, and custom tags like campaign ID.
CDR vs call log vs SIP trace
- CDR. One summary row per call, designed for billing and analytics.
- Call log. A user-facing history, usually a subset of CDR data.
- SIP trace. Every signaling message for a call, designed for debugging.
Use CDRs to find which calls had a problem, then use SIP traces to find why. See VoIP monitoring with Homer and HEP and SIP response codes and troubleshooting.
How phone systems generate CDRs
FreeSWITCH
FreeSWITCH can write CDRs through modules such as mod_cdr_csv, mod_json_cdr, and mod_xml_cdr, or you can build your own by listening for the CHANNEL_HANGUP_COMPLETE event over the Event Socket and storing the channel variables. Commonly used variables include uuid, start_stamp, answer_stamp, end_stamp, duration, billsec, and hangup_cause. See the FreeSWITCH Event Socket guide.
Asterisk
Asterisk has a CDR engine and Channel Event Logging (CEL), with backends for CSV and databases through ODBC. CEL records finer-grained events, which is useful when one call has several legs.
Kamailio
Kamailio is a SIP router, not a media server, but its acc module records transactions and, together with the dialog module, can produce call-level records. See the acc module documentation.
SBCs and carriers
Session border controllers and carrier softswitches also write CDRs, often with richer routing and rating data. If you buy termination, your vendor's CDRs are the basis for their invoice. See wholesale VoIP termination.
Multi-leg calls: the common trap
Many systems act as a back-to-back user agent, so a single customer call can produce two or more CDRs: one for the inbound leg and one for each outbound leg. If you count them naively, you will double-count calls and misreport revenue.
To handle this correctly:
- Store a correlation ID that ties legs of the same call together, such as a custom header or channel variable.
- Decide which leg is the billable record and which are informational.
- Be explicit about direction, so reports do not mix inbound and outbound legs.
Duration and time pitfalls
- Duration vs billable duration. Total duration includes ring time, which usually is not billed. Billable duration starts at answer.
- Billing increments. Carriers round durations (for example in 6-second blocks), so your computed cost must apply the same rules.
- Clock accuracy. Keep all servers synchronized with NTP, or timestamps across systems will not match.
- Time zones. Store timestamps in UTC and convert only when displaying.
KPIs you can calculate from CDRs
| KPI | Formula | What it tells you |
|---|---|---|
| ASR | Answered calls ÷ call attempts × 100 | How often calls succeed |
| ACD | Total billable seconds ÷ answered calls | Typical conversation length |
| NER | Attempts not failing for network reasons ÷ attempts | Network-level health |
| PDD | Time from INVITE to first ringing response | Setup delay as experienced by callers |
| Concurrent calls | Overlap of start and end times | Capacity usage and peaks |
| Cost and margin per route | Revenue minus carrier cost | Which vendors and routes are profitable |
| Calls by hour/day | Counts over time | Traffic patterns and capacity planning |
Example: ASR and ACD per route, per hour
SELECT
date_trunc('hour', start_time) AS hour,
route,
COUNT(*) AS attempts,
COUNT(*) FILTER (WHERE billsec > 0) AS answered,
ROUND(100.0 * COUNT(*) FILTER (WHERE billsec > 0) / COUNT(*), 1) AS asr_pct,
ROUND(AVG(billsec) FILTER (WHERE billsec > 0), 1) AS acd_seconds
FROM cdr
WHERE start_time >= now() - interval '24 hours'
GROUP BY 1, 2
ORDER BY 1 DESC, 2;
Adjust the definition of "answered" to your platform. Some systems treat any 200 OK as answered, others use billsec > 0.
Building a reliable CDR pipeline
A CDR pipeline must never silently lose records, because lost records mean lost revenue and blind spots in fraud detection.
- Capture at hangup. Write the record when the call ends, from the call engine or by listening to its events.
- Buffer durably. Send records to a queue or local spool first so a database outage does not drop data.
- Normalize. Convert to a consistent schema: UTC timestamps, E.164 numbers, standard disposition codes.
- Deduplicate. Use the call UUID as an idempotency key so retries and replays do not create duplicates.
- Store for the access pattern. A relational database with time-based partitioning works well for operational and billing needs. Analytical columnar stores suit large-scale reporting.
- Rate and enrich. Apply rates, tenant mapping, and route names to produce cost and revenue.
- Reconcile. Compare your CDRs with vendor invoices and flag disputes.
- Alert. Trigger notifications on ASR drops, cost spikes, and unusual destinations.
Using CDRs to detect fraud
CDRs make abuse visible. Typical signals include:
- Sudden spikes in short international calls
- Calls to high-cost or premium destinations that an account never called before
- Calls at unusual hours for that customer
- Many calls from a single account in a short window
Combine alerts with automatic limits, such as pausing an account that exceeds a spend threshold. See fraud detection from CDR analysis and VoIP toll fraud prevention.
Privacy, retention, and compliance
Call detail data is sensitive. In the U.S., call detail information is protected as customer proprietary network information (CPNI) for regulated carriers, and privacy laws such as GDPR can apply to data about people in other regions. Retention rules also exist: for example, FCC rules require certain carriers to retain toll billing records for a set period. Your obligations depend on your role and location, so confirm them with counsel.
Practical safeguards:
- Restrict access to CDRs by role
- Encrypt data in transit and at rest
- Define retention periods and delete data on schedule
- Mask or hash numbers in analytics where full numbers are not needed
Common CDR mistakes
- Counting every leg as a separate customer call
- Using total duration instead of billable duration for billing
- Letting server clocks drift
- Writing CDRs directly to a database with no buffer
- Keeping CDRs forever with no retention policy
- Not reconciling against carrier invoices
Frequently asked questions
What does CDR stand for?
Call detail record, sometimes called call data record. It is the record a telephone system creates for each call.
What is the difference between a CDR and a call log?
A CDR is a detailed technical and billing record for each call. A call log is a simplified history shown to users.
How long should CDRs be kept?
It depends on law, contract, and business need. Billing and dispute handling usually require months, and some regulated services have longer requirements. Set a documented policy.
Can CDRs be used as evidence?
CDRs can support investigations and disputes, but their weight depends on how they were generated, stored, and protected, and on local law. Keep records secure and unaltered.
References
Need billing-grade CDRs, rating, and fraud alerts on your platform? Our custom VoIP development and Telecom API and middleware teams build CDR pipelines, billing integrations, and monitoring for voice platforms.
Related Services
Keep Reading
Discussion
0Join the conversation
Sign in with your preferred account to comment, reply, and keep the discussion useful for other engineers.
Takes a few seconds. No separate password required.
Controva LLC
Engineering Team
We build digital empires that scale. Specializing in high-performance web architecture, AI automation, and headless commerce.
Work with us