Event Reference

PortSIP sends the events to the webhook in JSON object encoded using UTF-8, the events are defined as the below.

CDR Events

Call Target Definition

The definition of the call target: In PortSIP PBX, a call target refers to an endpoint. For example, if user 102 registers with the PBX from an IP phone and an app simultaneously, when user 101 calls 102, the PBX will send INVITE messages to both the IP phone and the app. In this scenario, the CDR will have two call targets: one for the IP phone and another for the app.

When the PBX sends an INVITE to a target, and the call target is ringing, answered, hung up, or the call to the target fails, the PortSIP PBX will send this call target event to the webhook.

Call Start Event

This event is sent to the webhook when a call is starting, it contains the below fields:

Key nameValue

event_type

call_start

time

The Unix timestamp in string format represents the call start time.

session_id

The session ID of the call.

cdr_id

The ID of this CDR.

direction

The call direction can have the following values:

  • ext: Indicates a call between extensions.

  • in: Indicates an inbound call from a trunk.

  • in2out: Indicates an inbound call routed to the trunk.

  • out: Indicates an outbound call to the trunk.

user_data

If the call is initiated from the REST API, additional information may be passed to this call as user_data.

call_id

The Call-ID of the INVITE SIP message.

caller_display_name

The display name of the caller.

caller

The caller number.

callee_display_name

The display name of the callee.

callee

The callee number.

tenant_id

The numeric tenant ID in string format

did

If the call is an inbound call, this key stores the DID.

outbound_caller_id

If the call is an outbound call, this key stores the outbound caller ID.

Call Info Update Event

This event is sent to the webhook when call information is updated, it contains the below fields:

Key nameValue

event_type

call_update_info

time

The Unix timestamp in string format represents the call start time.

session_id

The session ID of the call.

cdr_id

The ID of this CDR.

direction

The call direction can have the following values:

  • ext: Indicates a call between extensions.

  • in: Indicates an inbound call from a trunk.

  • in2out: Indicates an inbound call routed to the trunk.

  • out: Indicates an outbound call to the trunk.

caller_display_name

The display name of the caller.

caller

The caller number.

callee_display_name

The display name of the callee.

callee

The callee number.

tenant_id

The numeric tenant ID in string format

did

If the call is an inbound call, this key stores the DID.

outbound_caller_id

If the call is an outbound call, this key stores the outbound caller ID.

Call Target Event

As per the Call Target Definition, the call target event includes the below information.

event_type

For call target events, this event type can have the following values:

  • cdr_target_add: Sends the INVITE to the call target.

  • cdr_target_ringing: Indicates that a call target is ringing.

  • cdr_target_answer: Indicates that a call target has answered the call.

  • cdr_target_noanswer: Indicates that a ringing call target did not answer the call within the allotted time.

  • cdr_target_fail: Indicates that the call to a call target failed (e.g., network not reachable, rejected by call target).

  • cdr_target_end: Indicates that an established call has now ended.

time

The Unix timestamp in string format represents the call start time.

session_id

The session ID of the call.

cdr_id

The ID of this CDR.

tenant_id

The numeric tenant ID in string format

direction

The call direction can have the following values:

  • ext: Indicates a call between extensions.

  • in: Indicates an inbound call from a trunk.

  • in2out: Indicates an inbound call routed to the trunk.

  • out: Indicates an outbound call to the trunk.

destiantion

The call target address, for example: sip:102@192.168.0.18:5066

caller

The caller number.

did

If the call is an inbound call, this key stores the DID.

outbound_caller_id

If the call is an outbound call, this key stores the outbound caller ID.

Call End Event

When a call is completed (either hung up or failed), the PortSIP PBX sends this event to the webhook. This event includes all information about the call. Below is an example of a CDR.

The call flow is as follows: caller 1888722 dials 18800606 > trunk > PBX IVR (5000) > Queue (8000) > Agent (102, 103).

{
    "answered_time": "1725845648",
    "call_id": "zw6DDIua5lyVCtcLsI1Gnw..",
    "call_status": "answered",
    "call_targets": [
        {
            "answered_time": "1725845648",
            "call_type": "normal_call",
            "callee": "5000",
            "caller": "1888722",
            "destination": "sip:5000@192.168.1.93:8922",
            "did": "",
            "end_reason": "referred",
            "ended_time": "1725845655",
            "id": "883611252155219968",
            "outbound_caller_id": "",
            "ring_duration": "0",
            "ring_time": "1725845648",
            "start_time": "1725845648",
            "status": "answered",
            "status_code": 0,
            "talk_duration": "7",
            "trunk_name": "122:883631675865563136"
        },
        {
            "answered_time": "1725845655",
            "call_type": "normal_call",
            "callee": "8000",
            "caller": "1888722",
            "destination": "sip:8000@192.168.1.93:8916",
            "did": "",
            "end_reason": "referred",
            "ended_time": "1725845662",
            "id": "883611252155219968",
            "outbound_caller_id": "",
            "ring_duration": "0",
            "ring_time": "1725845655",
            "start_time": "1725845655",
            "status": "answered",
            "status_code": 0,
            "talk_duration": "7",
            "trunk_name": "122:883631675865563136"
        },
        {
            "answered_time": "1725845662",
            "call_type": "normal_call",
            "callee": "102",
            "caller": "1888722",
            "destination": "sip:102@192.168.2.135:5960",
            "did": "",
            "end_reason": "None",
            "ended_time": "1725845669",
            "id": "883611252155219968",
            "outbound_caller_id": "",
            "ring_duration": "6",
            "ring_time": "1725845656",
            "start_time": "1725845656",
            "status": "answered",
            "status_code": 0,
            "talk_duration": "7",
            "trunk_name": "122:883631675865563136"
        }
    ],
    "callee": "5000",
    "callee_domain": "test.com",
    "caller": "1888722",
    "caller_display_name": "1888722",
    "caller_domain": "192.168.1.93",
    "did": "18800606",
    "direction": "in",
    "ended_reason": "callee_disconnect",
    "ended_time": "1725845669",
    "event_type": "call_cdr",
    "outbound_caller_id": "",
    "ring_duration": "0",
    "ring_time": "1725845648",
    "session_id": "885337248273272832",
    "start_time": "1725845648",
    "status_code": "0",
    "talk_duration": 21,
    "tenant_id": "883611252155219968",
    "tenant_name": "test",
    "trunk_name": "122:883631675865563136",
    "user_data": ""
}

event_type

call_cdr

start_time

The Unix timestamp in string format represents the call start time.

ring_time

The Unix timestamp in string format represents the first call target ring.

answered_time

The Unix timestamp in string format represents the first call target answered.

ended_time

The Unix timestamp in string format represents the call was ended.

session_id

The session ID of the call.

cdr_id

The ID of this CDR.

call_id

The Call-ID of the INVITE SIP message.

callee

The callee number.

callee_domain

The domain of the callee.

caller

The caller number.

caller_display_name

The display name of the caller.

caller_domain

The domain of the caller.

call_status

The call final status can have the following values:

  • noanswer: The call was not answered.

  • fail: The call failed.

  • answered: The call was answered.

trunk_name

If the call is an inbound call or an outbound call through the trunk, the trunk name is stored in this key.

tenant_id

The numeric tenant ID in string format

tenant_name

The tenant name.

status_code

The final status code of the call is a SIP standard-defined status code.

direction

The call direction can have the following values:

  • ext: Indicates a call between extensions.

  • in: Indicates an inbound call from a trunk.

  • in2out: Indicates an inbound call routed to the trunk.

  • out: Indicates an outbound call to the trunk.

end_reason

The end reason of the call can have the following values:

  • None: Unknown reason.

  • caller_disconnected: The caller hung up.

  • callee_disconnected: The callee hung up.

  • replaced: Ended by attended transfer or call pickup.

  • referred: The call ended due to a blind transfer.

  • redirected: The call ended because of a 302 Redirect.

  • blind_transfer_complete: The call was hung up because the blind transfer was completed.

  • attended_transfer_complete: The call was hung up before the attended transfer was completed.

  • cancelled: The call was cancelled by the caller.

did

If the call is an inbound call, this key stores the DID.

outbound_caller_id

If the call is an outbound call, this key stores the outbound caller ID.

ring_duration

The ring time of the call.

talk_duration

The talk time of the call.

Call Targets Information

Since a call may be forwarded multiple times to different call targets during its duration, PortSIP PBX includes all call targets in the CDR when the call is completed. We can simply parse the call_targets JSON array object to access the call target information.

call_type

Indicates the call type. The values can be:

  • callback_call: An automatic callback call.

  • none: Unknown call type.

  • normal_call: A normal call.

  • queue_call: The call is of the queue.

  • queue_callback_call: The call is a callback to the caller from an agent.

  • ring_group_call: The call of the group.

start_time

The Unix timestamp in string format represents the call start time.

ring_time

The Unix timestamp in string format represents the first call target ring.

answered_time

The Unix timestamp in string format represents the first call target answered.

ended_time

The Unix timestamp in string format represents the call was ended.

cdr_id

The ID of CDR for this call target.

callee

The callee number.

caller

The caller number.

destination

The address of the call target, for example: sip:102@192.168.0.11.

status

The call final status can have the following values:

  • noanswer: The call was not answered.

  • answered: The call was answered.

trunk_name

If the call is an inbound call or an outbound call through the trunk, the trunk name is stored in this key.

cost

If the billing is enabled, store the call cost in this key.

status_code

The final status code of the call is a SIP standard-defined status code.

direction

The call direction can have the following values:

  • ext: Indicates a call between extensions.

  • in: Indicates an inbound call from a trunk.

  • in2out: Indicates an inbound call routed to the trunk.

  • out: Indicates an outbound call to the trunk.

end_reason

The end reason of the call can have the following values:

  • None: Unknown reason.

  • caller_disconnected: The caller hung up.

  • callee_disconnected: The callee hung up.

  • replaced: Ended by attended transfer or call pickup.

  • referred: The call ended due to a blind transfer.

  • redirected: The call ended because of a 302 Redirect.

  • blind_transfer_complete: The call was hung up because the blind transfer was completed.

  • attended_transfer_complete: The call was hung up before the attended transfer was completed.

  • cancelled: The call was cancelled by the caller.

did

If the call is an inbound call, this key stores the DID.

outbound_caller_id

If the call is an outbound call, this key stores the outbound caller ID.

ring_duration

The ring time of the call.

talk_duration

The talk time of the call.

Last updated