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

# Create Webhook

> Create a webhook endpoint.

Changes state - verify before retry
Registers a URL endpoint to receive call notifications. When a call that was not started by a batch call ends, DialNexa sends an HTTP `POST` to your URL with a signed plain JSON payload. DialNexa does not encrypt the webhook body.

The `secret` is required. Generate a long random value, store it in a secret manager, and send it only over HTTPS. The create response is the only response that exposes the unmasked value; get, list, and update responses return `********`.

The response wraps the new subscription in `data.webhook`. Its `id` has the `webhook_` prefix; use that value with the get, update, and delete operations.

## Payload delivered when a call ends

```json theme={null}
{
  "call_id": "mrjurp82fXXDJr",
  "status": "completed",
  "sentiment": "positive",
  "summary": "The agent confirmed the appointment.",
  "transcript": "...",
  "extracted_data": { "name": "John", "intent": "book_appointment" },
  "duration": "120",
  "recording_url": "...",
  "agent_id": "agent_FBbwBB8Lof7Mtm",
  "metadata": { "call_id": null },
  "billing": {
    "total_amount_inr": 5.5,
    "billed_duration_seconds": 120,
    "billing_plan": { "id": "abc", "name": "Standard" },
    "line_items": [{ "item_type": "call", "rate_inr": 0.05, "units": 120, "amount_inr": 5.5 }]
  }
}
```

| Field | Description |
| - | - |
| `call_id` | The call ID without the `call_` prefix that API responses use. Add `call_` before you compare it with an ID returned by [Create Call](https://dialnexa.com/docs/api-reference/v1/calls/create.md). |
| `status` | How the call ended: `completed`, `did_not_pick`, `busy`, `no_answer`, or `failed`. |
| `sentiment` | `positive`, `negative`, `neutral`, or `unknown` when no sentiment was recorded. |
| `summary` | Call summary, or an empty string. |
| `transcript` | Call transcript as a string, or an empty string. |
| `extracted_data` | Post-call extraction results as `key: value` pairs, `{}`, or `null`. The field can also be absent from the payload, so read post-call results from [Get Call Details](https://dialnexa.com/docs/api-reference/v1/calls/get.md) when it is missing. |
| `duration` | Call duration in seconds, serialized as a string (for example `"120"`). A call with no talk time sends `"0"`. |
| `recording_url` | The stored recording location, or `null`. It is not a pre-signed download link; use `recording_sas_url` from [Get Call Details](https://dialnexa.com/docs/api-reference/v1/calls/get.md) to download the recording. |
| `agent_id` | The ID of the agent that handled the call, with the `agent_` prefix, or `null` when the call record carries no agent ID. |
| `metadata` | Always `{ "call_id": null }`. It is a fixed placeholder and does not carry the metadata you sent when creating the call. |
| `billing` | Charges for the call. Present only when a billing record already exists for the call at the moment the delivery is sent. |

> [!NOTE]
>
> `billing` can be absent even for workspaces on the new billing system, because billing is recorded in the background while the delivery is being prepared. Read the call afterwards for its final charges.

## Which calls are delivered

* Calls placed directly by a [batch call](https://dialnexa.com/docs/api-reference/v1/batches/create.md) do not trigger a delivery. Every other call does, including single calls, web calls, workflow calls, inbound calls, and automatic retry attempts (which are created without a batch link).
* A delivery is sent when the call reaches one of the final statuses listed above. Calls refused before dialling, which end `failed` with `end_reason` `dnc_blocked`, `spend_cap_reached` or `insufficient_balance`, send no delivery; reconcile them with [Get Call Details](https://dialnexa.com/docs/api-reference/v1/calls/get.md) or [List Calls](https://dialnexa.com/docs/api-reference/v1/calls/list.md).
* A `completed` call whose recording location is not yet known when the call ends may not be delivered. Do not rely on receiving a delivery for every ended call; reconcile with [Get Call Details](https://dialnexa.com/docs/api-reference/v1/calls/get.md) using the call ID.

## Delivery behavior

* Each delivery is one `POST` attempt. DialNexa does not retry a failed delivery and does not set a request timeout.
* The response status your endpoint returns is not checked or stored. Return a `2xx` quickly and do the work asynchronously.
* Requests carry `Content-Type: application/json` and `User-Agent: Nexa-SingleOutboundCall-Webhook/1.0`.
* A call can occasionally produce more than one delivery, for example when a later status upgrades an earlier final status to `completed`. Make your handler safe to run twice for the same `call_id`.

## Verifying the signature

Every delivery includes an `x-nexa-signature` header:

```
x-nexa-signature: sha256=<hex>
```

Computed as `HMAC-SHA256(secret, rawBody)` over the **raw request body**. Always verify against the raw body before parsing JSON.

```js Node.js theme={null}
const crypto = require('crypto');

function verifySignature(rawBody, secret, signatureHeader) {
  if (!signatureHeader || !signatureHeader.startsWith('sha256=')) {
    return false;
  }

  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');
  const expectedBuffer = Buffer.from(expected);
  const receivedBuffer = Buffer.from(signatureHeader);

  return expectedBuffer.length === receivedBuffer.length &&
    crypto.timingSafeEqual(expectedBuffer, receivedBuffer);
}
```

```python Python theme={null}
import hmac, hashlib

def verify_signature(raw_body: bytes, secret: str, signature_header: str) -> bool:
    signature_header = signature_header or ''
    if not signature_header.startswith('sha256='):
        return False
    expected = 'sha256=' + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature_header or '')
```

## When to use this

* **Call outcome processing**: get notified when a call that was not placed directly by a batch call ends instead of polling [Get Call Details](https://dialnexa.com/docs/api-reference/v1/calls/get.md), then write the outcome to your CRM or trigger the next step.
* **Live dashboards**: track call completions as they happen.

## Available events

`events` must be a non-empty list of strings and is stored and returned as you sent it. Delivery is not filtered by it today: every active subscription in the workspace receives the call-ended delivery shown above, whatever its list contains, and the payload's `status` field says how the call ended. Use `call.completed` so the subscription reads correctly when filtering is introduced; do not translate dots to underscores.


## OpenAPI

````yaml POST /v1/user-webhooks
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Organization Folders
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
  - name: Agent Evaluations
paths:
  /v1/user-webhooks:
    post:
      tags:
        - Webhooks
      summary: Create Webhook
      description: >-
        Registers a webhook URL for your workspace. The response is the only one
        that returns the plain secret; store it securely. DialNexa sends one
        signed POST when a call that was not started by a batch call ends, with
        no retry and no timeout. The x-nexa-signature header is sha256=<hex>, an
        HMAC-SHA256 of the raw request body with your secret.
      operationId: createWebhook
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookRequest'
            examples:
              request:
                summary: Create a webhook
                value:
                  url: https://example.com/dialnexa/webhook
                  events:
                    - call.completed
                  is_active: true
                  secret: replace-with-a-long-random-secret
      responses:
        '201':
          description: Webhook created successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                  - statusCode
                  - message
                  - data
                  - timestamp
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  error:
                    type: boolean
                    enum:
                      - false
                  statusCode:
                    type: integer
                    example: 201
                  message:
                    type: string
                    example: Success
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: Webhook created successfully
                      webhook:
                        type: object
                        properties:
                          id:
                            type: string
                            example: webhook_c9v3nz8rq4pmxa
                            description: Webhook ID with the `webhook_` prefix.
                          org_id:
                            type: string
                            example: o14XKPP84rt22g
                            description: Owning workspace ID, without the `org_` prefix.
                          url:
                            type: string
                            format: uri
                            example: https://example.com/dialnexa/webhook
                          events:
                            type: array
                            items:
                              type: string
                            example:
                              - call.completed
                            description: >-
                              Stored and returned as sent. It does not filter
                              deliveries today.
                          is_active:
                            type: boolean
                            example: true
                            description: Inactive subscriptions receive no deliveries.
                          secret:
                            type: string
                            example: replace-with-a-long-random-secret
                            description: >-
                              The plain secret you sent. Shown only in this
                              response.
                          last_triggered_at:
                            type: string
                            format: date-time
                            nullable: true
                            description: >-
                              When a delivery was last attempted, whether or not
                              your endpoint accepted it.
                          is_deleted:
                            type: boolean
                            example: false
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                  timestamp:
                    type: string
                    format: date-time
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    error: false
                    statusCode: 201
                    message: Success
                    data:
                      message: Webhook created successfully
                      webhook:
                        id: webhook_c9v3nz8rq4pmxa
                        org_id: o14XKPP84rt22g
                        url: https://example.com/dialnexa/webhook
                        events:
                          - call.completed
                        is_active: true
                        secret: replace-with-a-long-random-secret
                        last_triggered_at: null
                        is_deleted: false
                        created_at: '2026-07-03T10:30:00.000Z'
                        updated_at: '2026-07-03T10:30:00.000Z'
                    timestamp: '2026-09-07T06:00:00.000Z'
        '400':
          description: Bad request - missing required fields or invalid URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 400 Bad Request
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: url must be a URL address
                    errors:
                      - url must be a URL address
        '401':
          description: Unauthorized - missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 401 Unauthorized
                  value:
                    statusCode: 401
                    error: true
                    success: false
                    data: []
                    message: Invalid API key
                    errors: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 500 Internal Server Error
                  value:
                    statusCode: 500
                    error: true
                    success: false
                    data: []
                    message: Internal server error
                    errors: []
      security:
        - bearer: []
components:
  schemas:
    CreateWebhookRequest:
      type: object
      properties:
        url:
          type: string
          format: uri
          example: https://webhook.site/your-endpoint
          description: The URL to which webhook events will be sent.
        events:
          minItems: 1
          example:
            - call.completed
          description: List of events this webhook is subscribed to.
          type: array
          items:
            type: string
        is_active:
          type: boolean
          example: true
          description: Whether the webhook is active.
        secret:
          type: string
          example: replace-with-a-long-random-secret
          description: Secret used to sign webhook payloads.
      required:
        - url
        - events
        - secret
    ErrorResponse:
      type: object
      description: Error body on endpoints without response filtering.
      properties:
        statusCode:
          type: integer
          example: 404
        error:
          type: boolean
          enum:
            - true
        success:
          type: boolean
          enum:
            - false
        data:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable refusal code.
            - type: array
              items: {}
          description: >-
            For a coded refusal, an object with code and the details listed for
            that code. Otherwise an empty array.
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: Validation messages for a 400. Empty for other errors.
        validation_errors:
          type: array
          description: >-
            Present when uploaded rows fail number validation (batch and
            workflow lead uploads): one group per distinct error.
          items:
            type: object
            properties:
              error:
                type: string
              rows:
                type: array
                items:
                  type: integer
                description: Row numbers with this error.
              phone_numbers:
                type: array
                items:
                  type: string
        invalid_row_count:
          type: integer
          description: 'Present with validation_errors: how many rows failed.'
      required:
        - statusCode
        - error
        - success
        - data
        - message
        - errors
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````

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