CDR

The CDR endpoint is a read-only reporting endpoint. It supports GET only; create, update, and delete methods return method_not_allowed. Tenant API keys must include tenant=CANISTRACCI. Global API keys can query one tenant by code or name, or use SQL-style % wildcards in the tenant parameter.

Object Summary

PropertyValue
Objectcdr
Primary path/cdrs
Path aliases/cdr, /cdrs, /call, /calls
Supported methodGET
Default formatjson
Compatibility formatstemplate, xml

Endpoint Patterns

ActionExample pattern
List recordsGET https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI
Filter by date rangeGET https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&start=2026-06-01%2000%3A00%3A00&end=2026-06-01%2023%3A59%3A59
Filter by ID from the pathGET https://pbx.example.com/pbx/openapi.php/cdrs/RECORD_ID?tenant=CANISTRACCI
Template/XML compatibility outputGET https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&format=template&template=Docs%20Export

Query Parameters

ParameterDescription
tenantTenant code or tenant name. Global API keys can use % wildcards; tenant API keys are restricted to their tenant.
startStart date and time. Defaults to today at 00:00:00.
endEnd date and time. Defaults to today at 23:59:59.
idComma-separated CDR ID values. A path value such as /cdrs/123 also maps to this filter.
uniqueidComma-separated Asterisk unique ID values.
linkedidComma-separated linked ID values used to group call legs.
srcComma-separated source values.
firstdstComma-separated first destination values.
dispositionComma-separated disposition values such as ANSWERED, NO ANSWER, BUSY, or FAILED.
directionDirection filter based on the CDR userfield mapping. Accepted values are IN, OUT, IN,OUT, and OUT,IN.
phoneComma-separated phone values searched across src, dst, firstdst, lastdst, realsrc, and wherelanded.
formatResponse format. Defaults to json. Use template or xml for template-based compatibility output.
templateTemplate name from the tenant XML templates. Used only with format=template or format=xml.
contenttypeOptional Content-Type header for rendered template output.

Response Fields

FieldDescription
accountcodeTenant code stored on the CDR.
IDInternal CDR row ID.
startCall start timestamp.
answerAnswer timestamp when the call was answered.
endCall end timestamp.
clidFull caller ID string.
realsrcNormalized or real source value.
firstdstFirst dialed destination tracked by MiRTA PBX.
durationTotal call duration in seconds.
billsecAnswered talk time in seconds.
dispositionAsterisk call disposition.
cc_costCalculated tenant-side call cost when available.
dcontextAsterisk destination context.
dstchannelDestination channel.
userfieldMiRTA PBX call marker, commonly including inbound or outbound direction information.
uniqueidAsterisk unique ID for the CDR leg.
prevuniqueidPrevious unique ID for linked call-leg processing.
lastdstLast destination reached by the call.
wherelandedFinal PBX object or destination where the call landed.
srcAsterisk source value.
dstAsterisk destination value.
lastappLast Asterisk application executed.
srcCallIDSource SIP Call-ID when available.
linkedidAsterisk linked ID used to group related CDR legs.
peeraccountAsterisk peer account value.
originateidOrigination tracking ID when available.
cc_countryRated country when rating data is available.
cc_networkRated network when rating data is available.
pincodePIN code associated with the call when present.
cc_buyCalculated buy-side cost when available.

Important Notes

Attended transfer records

When GET /cdrs repairs a pending attended transfer, it follows linked CDRs within the tenant to find the original destination. The transfer retains its own billable duration. The destination selects the applicable rate from the tenant's client rate, with the most specific matching prefix used first.

For example, if a pending transfer links through a previous transfer to a call placed to 771, the pending leg uses the original call's destination and its own billable duration. Existing charges on the previous transfer are left as recorded. A self-linked leg uses its own destination. A missing reference or a cycle involving multiple records leaves the transfer pending. A transfer with a resolved destination and no matching rate can be normalized without adding a charge.

If a database error prevents the repair from completing, the API returns HTTP 500 with error code database_error. A later request retries legs that remain pending.

Results use the usual tenant privacy settings and CDR filters. OpenAPI uses its existing userfield normalization when it copies a note from the original leg. Web and scheduled repairs retain the original note text.

The firstdst and phone filters match the stored number and ignore the same Unicode formatting marks as MiRTA's existing number normalization. The returned CDR retains the stored number.

If several CDRs in the tenant share a call identifier and sequence, a stored charge is shown against the lowest visible CDR ID for that call and sequence. A missing CDR sequence matches a ledger sequence of zero. Filtering out the owning row does not move its charge to another row. For example, if rows 10 and 11 are both visible and match one charge of 0.34, row 10 shows 0.34 and row 11 has no share of that charge. Both call legs remain available in the report.

Examples

List Today CDRs

Returns CDR rows for the selected tenant using today as the default date range.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI"

CDR Date Range

Limits results to an explicit date and time window.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&start=2026-06-01%2000%3A00%3A00&end=2026-06-01%2023%3A59%3A59"

CDR by Path ID

Uses the path segment after /cdrs as a CDR ID filter.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs/123456?tenant=CANISTRACCI"

CDR by ID and Unique ID

Filters by one or more CDR row IDs and one or more Asterisk unique IDs.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&id=123456%2C123457&uniqueid=1717240000.42"

CDR by Linked ID

Returns all matching CDR legs associated with one linked call.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&linkedid=1717240000.42"

CDR Source Destination and Disposition

Combines source, first destination, and disposition filters.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&src=100&firstdst=15551234567&disposition=ANSWERED"

CDR Direction

Filters by outbound calls using the MiRTA PBX CDR userfield mapping.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&direction=OUT"

Searches phone values across the main CDR source and destination columns.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&phone=100%2C15551234567"

CDR Global Tenant Wildcard

Uses a global key and a tenant wildcard to query matching tenants.

curl -H "X-API-Key: GLOBAL_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CAN%25&start=2026-06-01%2000%3A00%3A00&end=2026-06-01%2023%3A59%3A59"

CDR Template Output

Renders rows through a tenant XML/template definition. This requires exactly one tenant.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/cdrs?tenant=CANISTRACCI&format=template&template=Docs%20CDR%20Export&contenttype=text%2Fcsv"

Call Recording Download

GET /recordings/UNIQUEID downloads the recording of a call of the selected tenant, preferring an exact uniqueid match. The compatibility form is GET /recording?uniqueid=UNIQUEID. The response is the audio file, with its name in Content-Disposition.

curl -H "X-API-Key: TENANT_API_KEY" -OJ \
  "https://pbx.example.com/pbx/openapi.php/recordings/1763712345.1234?tenant=CANISTRACCI"

When no audio is available, HTTP 404 returns recording_not_found or recording_unavailable, with error.recording_status and a boolean error.retryable:

recording_statusMeaning
pending_uploadRecording started or a local file was found; the upload is still expected.
not_recordedAll the call channels have closed without a recording.
upload_failedThe upload failed. retryable tells whether recovery is expected.
unavailableThe recording was catalogued but cannot be retrieved, or was discarded.
unknownNot enough information, for example for older calls.

When retryable is true, wait the number of seconds in the Retry-After header before repeating the request: normally 30 seconds while an upload is pending, 15 minutes after a failed upload. A call that ended in the last five minutes can return unknown with retryable=true. Retries are no longer suggested after 24 hours without recording activity. not_recorded requires complete CEL data in Asterisk.

Common Errors

ErrorMeaning
missing_api_keyNo API key was supplied in the query string, X-API-Key, or bearer token.
invalid_api_keyThe supplied key does not match the tenant or global API key.
tenant_requiredA tenant code or tenant name is required when using a tenant API key.
single_tenant_requiredTemplate output requires the request to resolve to exactly one tenant.
template_not_foundThe selected XML/template output template does not exist for the tenant.
database_error (HTTP 500)Attended-transfer repair could not finish. Retry the request to process the remaining transfers.
method_not_allowedThe endpoint is read-only and only supports GET.

Revision #16
Created 2026-06-06 08:14:40 UTC by Admin
Updated 2026-12-05 14:40:54 UTC by Admin