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

# on_call_end

> Triggered at the end of a call to provide detailed Call and End User information.

## About This Event

The `on_call_end` webhook is triggered at the conclusion of a call in the Altur platform. This webhook provides detailed information about the call, the agent involved, and the campaign user. Use this webhook to keep your backend or CRM updated with the latest call data.

## Event Details

* **Trigger**: Automatically triggered at the end of a call.
* **Purpose**: To update your backend or CRM with call status, transcript, recording URL, and user information.

## Request Details

* **HTTP Method**: `POST`
* **Content Type**: `application/json`
* **Endpoint**: The URL you configure in your webhook integration settings.
* **Authentication**: Includes the `X-Altur-Signature` header for HMAC verification.

## Payload Example

Here’s an example of the payload sent with the `on_call_end` event:

```json theme={null}
{
  "event_type": "on_call_end",
  "id": "cll_gBoLtd02pUI50QwXkFjB",
  "type": "outbound",
  "status": "ended",
  "phone_number_from": "+000000000000",
  "phone_number_to": "+000000000000",
  "answered_by": "human",
  "created_at": "2024-12-19T15:00:10Z",
  "started_at": "2024-12-19T15:00:10Z",
  "ended_at": "2024-12-19T15:00:10Z",
  "duration": 45,
  "billed_duration": 45,
  "recording_url": "https://api.altur.io/api/v1.0/call/cll_gBoLtd02pUI50QwXkFjB/recording",
  "transcript": [
    {
      "sent_by": "assistant",
      "sent_at": "2024-12-19T15:00:00Z",
      "content": "Hello am I speaking with Sofía?"
    },
    {
      "sent_by": "user",
      "sent_at": "2024-12-19T15:00:10Z",
      "content": "Yes, who is this?"
    }
  ],
  "assistant": {
    "id": "6cy951e6-9877-4d7c-88d7-56b4948d3cce",
    "nickname": "DebtCollectorBot",
    "name": "Diana Arroyo"
  },
  "end_user": {
    "id": "2be951e6-7798-47cd-878d-49b2918a3bba",
    "status": "converted",
    "display_name": "John Doe",
    "phone_number": "+521234567890",
    "context": "Customer data...",
    "extracted_data": {
      "Payment Amount": "1200",
      "Payment Date": "2024-12-26",
      "Payment Medium": "app"
    },
    "tags": ["payment_promise", "call_later"]
  },
  "campaign_user": {
    "f_id": "user_12345",
    "name": "John Doe",
    "contact": "+521234567890",
    "context": "Customer data for campaign...",
    "status": "converted",
    "failed_retries": 0,
    "voicemail_retries": 1,
    "extracted_data": {
      "Payment Amount": "1200",
      "Payment Date": "2024-12-26",
      "Payment Medium": "app"
    },
    "tags": ["payment_promise", "call_later"]
  }
}
```

### Root Fields

| Field               | Type       | Description                                                                                         |
| :------------------ | :--------- | :-------------------------------------------------------------------------------------------------- |
| `event_type`        | `string`   | Event type (`on_call_end`).                                                                         |
| `id`                | `string`   | Unique identifier for the call.                                                                     |
| `type`              | `string`   | Call type (`outbound`or `inbound`).                                                                 |
| `status`            | `string`   | Status of the call enum value (e.g., `ended`).                                                      |
| `phone_number_from` | `string`   | E.164 formatted number.                                                                             |
| `phone_number_to`   | `string`   | E.164 formatted number.                                                                             |
| `answered_by`       | `string`   | Indicates who answered the call (`human`, `machine` or `unknown`).                                  |
| `created_at`        | `datetime` | ISO formatted date time of when the call was created.                                               |
| `started_at`        | `datetime` | ISO formatted date time of when the call started.                                                   |
| `ended_at`          | `datetime` | ISO formatted date time of when the call ended.                                                     |
| `duration`          | `int`      | Call duration in seconds.                                                                           |
| `billed_duration`   | `int`      | Billed call duration in seconds.                                                                    |
| `recording_url`     | `string`   | URL to [download](https://docs.altur.io/api-reference/calls/retrieve-recording) the call recording. |
| `transcript`        | `array`    | Call transcript object.                                                                             |

### Assistant Object

| Field      | Type     | Description                          |
| :--------- | :------- | :----------------------------------- |
| `id`       | `uuid`   | Unique identifier for the assistant. |
| `nickname` | `string` | Assistant's nickname.                |
| `name`     | `string` | Assistant's name.                    |

### End User Object

<Warning>
  **Deprecated**: The `end_user` object is deprecated and will be removed in a
  future version. Please use the `campaign_user` object instead for
  campaign-related calls.
</Warning>

| Field            | Type     | Description                                                                                    |
| :--------------- | :------- | :--------------------------------------------------------------------------------------------- |
| `id`             | `uuid`   | Unique identifier for the end user.                                                            |
| `status`         | `string` | Current status of the user enum value (e.g., `converted`).                                     |
| `display_name`   | `string` | Display name of the user.                                                                      |
| `phone_number`   | `string` | User's phone number (E.164 format).                                                            |
| `context`        | `string` | Additional user-specific information.                                                          |
| `extracted_data` | `object` | Key-value pairs of extracted data.                                                             |
| `tags`           | `array`  | Array of tag names corresponding to tags assigned to the last campaign user or current thread. |

### Campaign User Object

| Field               | Type     | Description                                                |
| :------------------ | :------- | :--------------------------------------------------------- |
| `f_id`              | `string` | Foreign identifier for the campaign user from your system. |
| `name`              | `string` | Name of the campaign user.                                 |
| `contact`           | `string` | Contact phone number (E.164 format).                       |
| `context`           | `string` | Additional campaign user-specific information.             |
| `status`            | `string` | Current status of the campaign user (e.g., `converted`).   |
| `failed_retries`    | `int`    | Number of failed retry attempts.                           |
| `voicemail_retries` | `int`    | Number of voicemail retry attempts.                        |
| `extracted_data`    | `object` | Key-value pairs of data extracted during the call.         |
| `tags`              | `array`  | Array of tag names assigned to the campaign user.          |

## Response Expectations

Your endpoint should return a 200 OK status code to confirm receipt of the webhook. For information on retry behavior in case of failures, see the [Retry Policy](https://docs.altur.io/api-reference/webhooks/overview#delivery-retry-policy) section in the Webhook Overview.

## Security

Each request includes an HMAC signature in the `X-Altur-Signature` header. Refer to the [Securing Your Webhooks](https://docs.altur.io/api-reference/webhooks/overview#securing-your-webhooks) section for instructions on validating webhook requests.

## Example Use Cases

1. **CRM Integration**

   Use the `on_call_end` webhook to update call logs and user interaction data in your CRM system.

2. **Analytics**

   Process transcripts and user status to generate insights or trigger follow-up actions.

3. **Data Enrichment**

   Automatically store extracted data, like account numbers or due dates, in your system for further use.
