Push CDR

Push CDR to Webhook

You can collect Call Detail Records (CDRs) by sending an HTTP request to an external service or application each time a call is completed.

A webhook is an event-driven mechanism that allows PortSIP PBX to notify an external system when specific events occur, such as call start or call completion.

Only the Tenant Administrator has permission to enable or disable this feature.

Configuration

  1. Select Company from the left menu.

  2. On the Event URL page, enable CDR Events.

  3. Choose an Authentication Method.

  4. Enter your Webhook URL.

Once configured, PortSIP PBX will push CDR-related events to the specified third-party webhook endpoint.


Example: Call Start Event

Below is an example generated when extension 102 receives a call.


Example: Call Detail Record (CDR)

The following example represents a completed call. The call flow is: caller > trunk > PBX IVR > Queue > Agent


CDR Fields Description

The CDR information is provided in JSON format and includes the following fields:

  • answered_time The timestamp (Unix format) when the call was answered. In this example, it represents when the PBX IVR answered the call. A value of 0 indicates the call was not answered.

  • call_id The Call-ID of the SIP INVITE received by PortSIP PBX from the trunk.

  • callee The first destination when the call arrived at the PBX (for example, IVR 5000).

  • callee_domain The SIP domain (tenant SIP domain) of the callee.

  • caller The caller number received from the trunk.

  • caller_display_name The display name from the SIP From header.

  • caller_domain The host part of the SIP From header.

  • did_cid The DID number dialed from the trunk (user part of the SIP To header).

  • direction Indicates call direction:

    • in: inbound from trunk

    • out: outbound to trunk

    • in2out: inbound call forwarded to trunk

  • end_reason Indicates why the call ended. Possible values include: caller_disconnect, callee_disconnect, replaced, referred, redirected, blind_transfer_complete, attended_transfer_complete, cancelled

  • ended_time The time when the call ended (Unix timestamp).

  • event_type Indicates that this event is a CDR.

  • outbound_caller_id The outbound caller ID used for outbound trunk calls.

  • ring_time Ring start time for the call target.

  • session_id Session ID also present in the SIP X-Session-ID header; can be used to query call recordings.

  • start_time The timestamp when the call arrived at PortSIP PBX.

  • status_code SIP status code if the call failed (e.g., 404, 408). A value of 0 indicates no error.

  • tenant_id The ID of the tenant that handled the call.

  • tenant_name The name of the tenant that handled the call.

  • trunk_name The name of the trunk used for the call.

  • user_data Custom data passed when the call is initiated via REST API.


Call Targets

A call may include multiple call targets, representing each routing step or ringing endpoint.

Example Scenarios:

  • An extension registered on both an IP phone and an app creates multiple targets.

  • A call rings extension 101, goes unanswered, and is forwarded to extension 102.

  • A call passes through IVR, queue, and multiple agents.

In this example:

  • The first target is IVR 5000.

  • The caller presses DTMF 1.

  • The call is forwarded to Queue 8000.

  • Agents 102 and 103 ring while the caller waits.


Example: IVR Target (5000)


Push CDR to WebSocket Subscriber

You can also collect CDRs by subscribing to CDR events via WebSocket.

A WebSocket subscription allows an external service or application to receive real-time events directly from PortSIP PBX without polling.

For more details, please refer to the WSI: Pub/Sub documentation.

Last updated