> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ycloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# whatsapp.call.terminate

> Occurs when a WhatsApp call is terminated.

Use `whatsapp.call.terminate` to handle this event at your webhook endpoint.

## Triggers

Occurs when a WhatsApp call is terminated.

Subscribe to `whatsapp.call.terminate` when you [configure your webhook endpoint](https://docs.ycloud.com/en/api-reference/guides/api-fundamentals/configure-webhooks.md).

## Syntax

YCloud sends an HTTP `POST` request to your configured webhook URL. The following shape shows one payload variant. Angle-bracket values are placeholders; their types are listed under **Parameters**. Optional fields and other variants are described below.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "<ID>",
  "type": "whatsapp.call.terminate",
  "apiVersion": "<API_VERSION>",
  "createTime": "<CREATE_TIME>",
  "callingTerminate": {
    "id": "<ID>",
    "wacid": "<WACID>",
    "phoneId": "<PHONE_ID>",
    "from": "<FROM>",
    "to": "<TO>",
    "direction": "<DIRECTION>",
    "startTime": "<START_TIME_VALUE>",
    "endTime": "<END_TIME_VALUE>",
    "duration": "<DURATION_VALUE>",
    "status": "<STATUS>"
  }
}
```

## Parameters

Validate the `YCloud-Signature` HTTP header before you process the JSON body. See [signature validation](https://docs.ycloud.com/en/api-reference/guides/api-fundamentals/configure-webhooks.md).

### Event envelope

| Parameter | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Unique ID for the event. Minimum length: `6`. Maximum length: `128`. |
| `type` | string | Yes | Always `whatsapp.call.terminate`. |
| `apiVersion` | string | Yes | The API version used to render this event. |
| `createTime` | string (date-time) | Yes | The time at which this event was created, formatted in [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339). e.g., `2022-06-01T12:00:00.000Z`. |

### Event payload

| Parameter | Type | Required | Description |
| - | - | - | - |
| `callingTerminate` | object | No | Event-specific `callingTerminate` payload. |

The four common envelope fields are required. Payload fields depend on the event variant. In each object table, **Required** applies when its parent object is present. Optional fields can be omitted; a sample does not make a field required.

#### callingTerminate

| Parameter | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Unique ID for the call event. |
| `wacid` | string | Yes | The WhatsApp call ID. This ID uniquely identifies the call session. |
| `phoneId` | string | No | The WhatsApp Business phone number ID. |
| `from` | string | No | The caller's phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. |
| `fromUserId` | string | No | The caller's WhatsApp Business-scoped user ID (BSUID) for customer-initiated calls. |
| `fromParentUserId` | string | No | The caller's parent WhatsApp Business-scoped user ID for customer-initiated calls. |
| `to` | string | No | The callee's phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. |
| `toUserId` | string | No | The callee's WhatsApp Business-scoped user ID (BSUID) for business-initiated calls. |
| `toParentUserId` | string | No | The callee's parent WhatsApp Business-scoped user ID for business-initiated calls. |
| `customerProfile` | object | No | The customer's profile information, including WhatsApp username when available. |
| `direction` | string | No | The direction of the call.<ul><li>`USER_INITIATED`: Call initiated by the customer to the business.</li><li>`BUSINESS_INITIATED`: Call initiated by the business to the customer.</li></ul> |
| `startTime` | integer (int64) | No | The time when the call started, in Unix timestamp milliseconds. |
| `endTime` | integer (int64) | No | The time when the call ended, in Unix timestamp milliseconds. |
| `duration` | integer (int64) | No | The duration of the call in seconds. |
| `status` | string | No | The final status of the call.<ul><li>`COMPLETED`: The call was successfully completed.</li><li>`FAILED`: The call failed due to an error.</li></ul> |
| `errorCode` | string | No | Error code when the call status is `FAILED`. Numeric string representing the error. |

> [accordion] callingTerminate.customerProfile
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | `name` | string | No | Name of the WhatsApp account. |
> | `username` | string | No | WhatsApp username. |

## Example

The following JSON is the body delivered to your receiver. IDs, phone numbers, and other account values are illustrative.

> [accordion] WhatsApp call terminate event
>
> Example payload when a WhatsApp call is terminated
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_6757b889a5a42d369ef48481",
>   "type": "whatsapp.call.terminate",
>   "apiVersion": "v2",
>   "createTime": "2024-12-10T03:42:01.822Z",
>   "callingTerminate": {
>     "id": "6757b889960b25543b9ecc67",
>     "wacid": "wacid.HBgNNjI4MTM2MTkwNTEzMxUCABIYIEFENjB",
>     "phoneId": "461269257068832",
>     "from": "+12025550124",
>     "to": "+12025550123",
>     "direction": "USER_INITIATED",
>     "startTime": 1733734738000,
>     "endTime": 1733734771000,
>     "duration": 33,
>     "status": "COMPLETED"
>   }
> }
> ```

> [accordion] Call Completed
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_6757b889a5a42d369ef48481",
>   "type": "whatsapp.call.terminate",
>   "apiVersion": "v2",
>   "createTime": "2024-12-10T03:42:01.822Z",
>   "callingTerminate": {
>     "id": "6757b889960b25543b9ecc67",
>     "wacid": "wacid.HBgNNjI4MTM2MTkwNTE",
>     "phoneId": "461269257068832",
>     "from": "+12025550124",
>     "fromUserId": "ID.13491208655302741918",
>     "fromParentUserId": "ID.11815799212886844830",
>     "to": "+12025550123",
>     "direction": "USER_INITIATED",
>     "startTime": 1733734738000,
>     "endTime": 1733734771000,
>     "duration": 33,
>     "status": "COMPLETED"
>   }
> }
> ```

> [accordion] Call Failed
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "id": "evt_675907f431c55113a751d0e7",
>   "type": "whatsapp.call.terminate",
>   "apiVersion": "v2",
>   "createTime": "2024-12-11T03:33:08.679Z",
>   "callingTerminate": {
>     "id": "675907a13ae4a901f05fee95",
>     "wacid": "wacid.HBgNODYxNTE1NzEzNzYyM",
>     "phoneId": "461269257068832",
>     "from": "+12025550124",
>     "fromUserId": "ID.13491208655302741918",
>     "fromParentUserId": "ID.11815799212886844830",
>     "to": "+12025550123",
>     "direction": "USER_INITIATED",
>     "startTime": 1733826484000,
>     "endTime": 1733826637000,
>     "duration": 30,
>     "status": "FAILED",
>     "errorCode": "131000"
>   }
> }
> ```

After verifying the signature and durably accepting the event, return a `2xx` response. Process slow work asynchronously.

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

For scenario walkthroughs, see [annotated examples](https://docs.ycloud.com/en/api-reference/guides/examples/webhook-examples/whatsapp-calling-terminate-webhook-examples).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.