# Voice OUT Call Events

Voice OUT Call Events allow you to receive real-time call event notifications for outbound calls using the HTTP
protocol.
Events are delivered individually with no batching delays. Each request contains a single event and is sent via an HTTP
**POST** request.
The request content can optionally be **gzipped** to reduce data size.

Available event types:
:   - **Call Start Event** - Triggered when an outbound call attempt is initiated.
    - **Call Connect Event** - Triggered when the call is successfully answered (**200 OK/Connect** response).
    - **Call End Event** - Triggered when the call is terminated.



---

## Request Header Example

The following is an example of an HTTP **POST** request header used to send Voice OUT Call Events. It includes details
such as the destination server, content type, encoding, and request size.

> ```
> POST /call-events HTTP/1.1
> Host: 192.0.2.5
> User-Agent: CDR-streamer
> Accept: */*
> Content-Type: application/vnd.api+json
> Content-Encoding: gzip
> Content-Length: 2358
> ```

---

## Call Start Event

A **Call Start Event** is triggered when an outbound call attempt is initiated. This event is sent to the customer via
the HTTP protocol after the call routing process is completed by DIDWW (destination determination process).
At this stage, a **SIP INVITE** is sent from DIDWW to the call destination.

When is this event triggered?
:   - After DIDWW completes the call routing process.
    - When a **SIP INVITE** is sent to initiate the outbound call.
    - Before the call is answered or connected.

### HTTP request payload example

The following JSON payload represents a **Call Start Event**, providing details such as event type, call identifiers,
timestamps, and call routing details.

> ```
> {
>     "type": "outbound-call-start-event",
>     "id": "10-10282FC6-5F632C460006A397-AC8C7700",
>     "attributes": {
>         "source_ip" : "192.0.2.1",
>         "source_port": 5060,
>         "call_id" : "3eab288b2e0eb547122434ce0e648bb5",
>         "time_start": "2020-03-05T11:05:33.879559+00:00",
>         "pop": "NYC",
>         "original_src_number": "02089643990",
>         "src_number": "123439643990",
>         "dst_number": "441158720600",
>         "trunk_name": "Trunk 1",
>         "rate": "0.004",
>         "initial_billing_interval": 1,
>         "next_billing_interval": 1,
>         "p_charge_info": "<sip:02089643990@customer.example.com;billing-account-id=212>",
>         "diversion" : [ "<sip:+123456789@sip.didww.com>;reason=unconditional" ]
>     }
> }
> ```

---

## Call Connect Event

A **Call Connect Event** is triggered when the call is successfully answered, and a **200 OK/Connect** response is
received from the destination (**call leg B**).

When is this event triggered?
:   - When the call destination (**call leg B**) responds with **200 OK**.
    - When the call moves from the ringing state to an active conversation.

    Note

    If the call is terminated before a successful handshake (**200 OK**), the **Call Connect Event** will not be sent to the customer's endpoint.

### HTTP request payload example

The following JSON payload represents a **Call Connect Event**, providing details such as event type, call identifiers,
timestamps, and call routing details.

> ```
> {
>     "type": "outbound-call-connect-event",
>     "id": "10-10282FC6-5F632C460006A397-AC8C7700",
>     "attributes": {
>         "source_ip" : "192.0.2.1",
>         "source_port": 5060,
>         "call_id" : "3eab288b2e0eb547122434ce0e648bb5",
>         "time_start": "2020-03-05T11:05:33.879559+00:00",
>         "time_connect": "2020-03-05T11:05:38.879559+00:00",
>         "pop": "NYC",
>         "original_src_number": "02089643990",
>         "src_number": "123439643990",
>         "dst_number": "441158720600",
>         "trunk_name": "Trunk 1",
>         "rate": "0.004",
>         "initial_billing_interval": 1,
>         "next_billing_interval": 1,
>         "p_charge_info": "<sip:02089643990@customer.example.com;billing-account-id=212>",
>         "diversion" : [ "<sip:+123456789@sip.didww.com>;reason=unconditional" ]
>     }
> }
> ```

---

## Call End Event

A Call End Event is sent to the customer via HTTP protocol when the call is terminated in any way.

When is this event triggered?
:   - When the call is **disconnected** by either party.
    - Whether the call was **answered** (**connected**) or not.

    Note

    If the call was never connected, the **time\_connect** attribute will be null, and the **duration** will be 0.

### HTTP request payload example

The following JSON payload represents a **Call End Event**, including timestamps, call duration, and routing details.

> ```
> {
>     "type": "outbound-call-end-event",
>     "id": "10-10282FC6-5F632C460006A397-AC8C7700",
>     "attributes": {
>         "source_ip" : "192.0.2.1",
>         "source_port": 5060,
>         "call_id" : "3eab288b2e0eb547122434ce0e648bb5",
>         "time_start": "2020-03-05T11:05:33.879559+00:00",
>         "time_connect": "2020-03-05T11:05:38.879559+00:00",
>         "time_end": "2020-03-05T11:05:58.879559+00:00",
>         "duration": 10,
>         "pop": "NYC",
>         "original_src_number": "02089643990",
>         "src_number": "123439643990",
>         "dst_number": "441158720600",
>         "trunk_name": "Trunk 1",
>         "rate": "0.004",
>         "initial_billing_interval": 1,
>         "next_billing_interval": 1,
>         "p_charge_info": "<sip:02089643990@customer.example.com;billing-account-id=212>",
>         "diversion" : [ "<sip:+123456789@sip.didww.com>;reason=unconditional" ]
>     }
> }
> ```



---

## Call Event Attributes

Voice OUT (outbound) Call Event Descriptions and Examples






| **Attribute** | **Type** | **Description** | **Example** |
| --- | --- | --- | --- |
| **type** | String | Event type. Possible values:   - outbound-call-start-event - outbound-call-connect-event - outbound-call-end-event | "outbound-call-start-event" |
| **id** | String | Unique call identifier.  All events related to the same call will contain the same **id** value. | "10-10282FC6-5F632C460006A397-AC8C7700" |
| **attributes** | Hash | Structure containing all CDR attributes. | *See below for attribute details.* |
| **source\_ip** | String | IP address of the call originator. | "192.0.2.1" |
| **source\_port** | Integer | Port of the call originator. | 5060 |
| **call\_id** | String | SIP Call-ID of the call leg between the customer's equipment and DIDWW.  All events related to the same call will contain the same **call\_id** value. | "3eab288b2e0eb547122434ce0e648bb5" |
| **time\_start** | Timestamp | Start time when the initial SIP INVITE is received. | "2024-03-05T11:05:33.879559+00:00" |
| **time\_connect** | Timestamp | Time of the successful handshake (**200 OK SIP** response).  If the call was never connected, this value is null in the **Call End Event**. | "2024-03-05T11:05:38.879559+00:00" |
| **time\_end** | Timestamp | Call disconnection time. | "2024-03-05T11:05:58.879559+00:00" |
| **duration** | Integer | Call duration in seconds.  For non-connected calls, the duration is 0. | 10 |
| **pop** | String | Location of the DIDWW equipment that processed the call.  See [DIDWW Point of Presence](../presence/index.html#presence). Possible values:   - NYC - USA, New York - LAC - USA, Los Angeles - MIA - USA, Miami - FRA - Germany, Frankfurt - AMS - Netherlands, Amsterdam - SG - Singapore - HG - Hong Kong | "NYC" |
| **original\_src\_number** | String | Incoming Caller ID before any modifications. | "02089643990" |
| **src\_number** | String | Incoming Caller ID after applying rewrites. | "123439643990" |
| **dst\_number** | String | Call destination number. | "441158720600" |
| **trunk\_name** | String | Outbound trunk friendly name. | "Trunk 1" |
| **rate** | Numeric | Customer's outbound call termination rate. | "0.004" |
| **initial\_billing\_interval** | Integer | Initial billing interval for the outbound call termination. | 1 |
| **next\_billing\_interval** | Integer | Next billing interval for the outbound call termination. | 1 |
| **p\_charge\_info** | String | P-Charge-Info header value received from the call originator.  This allows customers to add custom information to DIDWW CDR for technical and/or billing purposes.  See [Service description](../voice/outbound-trunks/outbound-sip-information.html#service-termination-sip-details-p-charge-info) for more details. | "<sip:02089643990@customer.example.com;billing-account-id=212>" |
| **diversion** | Array of Strings | Diversion header values received from the call originator.  The order of headers in the **INVITE** request is preserved. | [ "<sip:+123456789@sip.didww.com>;reason=unconditional" ] |
