---
docId: doc_274612cac125454d96620f3c2913c4ee
title: Create a webhook
description: "Create a webhook, store its credentials, and verify the destination."
api:
  group: webhooks
  auth: bearer
  operations:
    - operationId: createWebhook
      method: POST
      path: /v1/webhooks
      postmanName: Create a webhook
---

<script>
  import { Note, Ways } from '$lib/components';
</script>

# Create a webhook

Create a webhook to receive events on your server. In the same call, Platica stores its credentials as secrets and verifies the destination. A successful verification activates the webhook.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/webhooks \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "CRM",
    "url": "https://example.com/hooks/platica",
    "events": ["message.created"]
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.webhooks.create({ name: "CRM", url: "https://example.com/hooks/platica", events: ["message.created"] });
```

</Ways.Way>
</Ways>

If your credential covers several workspaces, add `?workspace=<id>` with the workspace where it is created ([list workspaces](/api-reference/workspaces)); without it the answer is `400`.

## Request body

```json
{
  "name": "Notifications webhook",
  "url": "https://example.com/webhook",
  "events": [
    "conversation.created",
    "conversation.status.updated",
    "message.created",
    "client.created",
    "client.customFields.updated"
  ],
  "active": true,
  "secret": "whsec_test_example",
  "headers": {
    "Authorization": "Bearer sk_test_example",
    "Custom-Header": "custom value"
  },
  "autoPause": { "mode": "time", "hours": 24 }
}
```

## Body parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `name` | string | Webhook name, 1 to 100 characters | ✓ |
| `url` | string | URL where the notifications are sent, up to 500 characters | ✓ |
| `events` | array | Events it subscribes to, at least one. See [available events](/api-reference/webhooks/events) | ✓ |
| `active` | boolean | With `false` it is saved without verifying or activating. Default `true` | — |
| `secret` | string | Secret used to sign every delivery, up to 255 characters. It is stored as a workspace secret and is not returned. It is only accepted if `url` is https and public | — |
| `headers` | object | Headers included in every delivery. Up to 10; names up to 100 characters and values up to 500. The value of a header that carries a credential is stored as a secret and is not returned | — |
| `secrets` | object | Map of slot to the id of a secret that already exists, instead of sending its value: `webhook.secret` for the signature, `header:<name>` for a header | — |
| `autoPause` | object | When it pauses itself if your server keeps failing: `{ "mode": "failures", "failures": 5..1000 }` or `{ "mode": "time", "hours": 1..168 }`. Default: after 5 consecutive failed deliveries. See [automatic pause](/api-reference/webhooks/signatures#automatic-pause) | — |

<Note type="tip">

You can mix conversation, message, contact, and WhatsApp Flows events in the same webhook. If you use `whatsapp.flows.*`, your endpoint must answer with JSON in under 700 ms. See [WhatsApp Flows](/api-reference/webhooks/whatsapp-flows).

</Note>

## Response

`201 Created`. `data` carries the whole webhook, with the fields from [get a webhook](/api-reference/webhooks/get#response-fields), plus `activation`.

```json
{
  "status": "success",
  "message": "Webhook created successfully",
  "data": {
    "id": "webhook_abc123",
    "name": "Notifications webhook",
    "url": "https://example.com/webhook",
    "events": [
      "conversation.created",
      "conversation.status.updated",
      "message.created",
      "client.created",
      "client.customFields.updated"
    ],
    "active": true,
    "hasSecret": true,
    "headers": {
      "Authorization": "[REDACTED]",
      "Custom-Header": "custom value"
    },
    "createdAt": "2026-10-28T12:05:00.000Z",
    "updatedAt": "2026-10-28T12:05:03.000Z",
    "creationDate": "2026-10-28T12:05:00.000Z",
    "lastUpdate": "2026-10-28T12:05:03.000Z",
    "lastDeliveryAt": null,
    "lastDeliveryStatus": null,
    "lastDeliveryCode": null,
    "lastDeliveryError": null,
    "autoPause": { "mode": "time", "hours": 24 },
    "consecutiveFailures": 0,
    "failingSince": null,
    "status": "enabled",
    "version": 3,
    "verified": true,
    "secrets": [
      {
        "slot": "webhook.secret",
        "state": "authorized",
        "secretId": "a1c3e5f7092b4d6f8a0c2e4f6b8d0a1c3e5f7092b4d6f8a0c2e4f6b8d0a1c3e5"
      },
      {
        "slot": "header:authorization",
        "state": "authorized",
        "secretId": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
      }
    ],
    "activation": { "active": true },
    "workspaceId": "ws_123",
    "nextStep": "Active. It delivers: conversation.created, conversation.status.updated, message.created, client.created, client.customFields.updated."
  }
}
```

## Response fields

| Field | Type | Description |
|-------|------|-------------|
| `active` | boolean | `true` if the webhook already delivers |
| `hasSecret` | boolean | `true` if it has a signing secret. The value is never returned |
| `activation.active` | boolean | Result of the verification in this call |
| `activation.reason` | object | Only if it was not activated: `{ code, message }` with the reason |
| `secretsError` | object | Only if the webhook was saved but a credential could not be stored or bound: `{ code, message }` |
| All the others | — | See [get a webhook](/api-reference/webhooks/get#response-fields) |

## If the destination does not pass verification

The webhook is saved anyway, inactive. The response is still `201`, with `message: "Webhook saved but not active — see nextStep"`:

```json
{
  "status": "success",
  "message": "Webhook saved but not active — see nextStep",
  "data": {
    "id": "webhook_abc123",
    "active": false,
    "status": "draft",
    "activation": {
      "active": false,
      "reason": {
        "code": "VERIFICATION_FAILED",
        "message": "El destino no pasó la verificación (respondió HTTP 503): tiene que estar en línea y no contestar con un error del servidor. El webhook quedó guardado e inactivo."
      }
    },
    "nextStep": "Saved but not active: El destino no pasó la verificación (respondió HTTP 503): tiene que estar en línea y no contestar con un error del servidor. El webhook quedó guardado e inactivo. Fix the destination and run POST /v1/webhooks/webhook_abc123/test."
  }
}
```

The example omits the webhook's other fields. `reason.message` is in Spanish. Fix your server and use [test a webhook](/api-reference/webhooks/test) to activate the saved webhook.

| `activation.reason.code` | When |
|--------------------------|------|
| `VERIFICATION_FAILED` | The destination answered with a `5xx` status |
| `OPERATION_UNCONFIRMED` | The verification could not be completed, for example because the destination did not answer in time |
| `SECRETS_NEED_AUTHORIZATION` | A credential is not authorized for the current destination |

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The body fails validation: a field is missing, `url` is not a URL, an event does not exist, there are more than 10 headers, `autoPause` carries another field or a number out of range. `details.issues` carries each problem with `path` and `message`, without repeating the `secret` |
| `400` | `INVALID_REQUEST` | Your credential covers several workspaces and you did not send `?workspace=`, or you sent one it does not cover. `details.available` carries the IDs you can use |
| `400` | `INVALID_CONFIG` | The name, the URL, or the events are not valid |
| `400` | `SECRET_DESTINATION_INVALID` | You sent `secret` and `url` is not https, points to localhost or a private IP, or carries a `#fragment`. Nothing is saved |
| `401` | `UNAUTHENTICATED` | The credential is missing or invalid |
| `403` | `FORBIDDEN` | An OAuth token without the `platica:write` scope, the person does not have the Integrations module (the message is `Missing integrations permission`), or does not have permission to configure webhooks |
| `409` | `REQUEST_ID_CONFLICT` | You repeated an `Idempotency-Key` with a different body. Use a new key for a new operation |

```json
{
  "code": 400,
  "error": "Bad Request - The request has validation errors",
  "details": {
    "code": "INVALID_REQUEST",
    "message": "The request has validation errors",
    "issues": [
      { "path": ["url"], "message": "Must be a valid URL" },
      { "path": ["events", 0], "message": "Invalid event" }
    ]
  }
}
```

The general error format is in [Errors](/api-reference/errors).

## Notes

- Keep the `secret` on your server when you create it. If you lose it, [rotate it](/api-reference/secrets/rotate) or send a new one with [update a webhook](/api-reference/webhooks/update).
- The secrets created here show up in [list secrets](/api-reference/secrets/list) with names like `Webhook <name> · firma`. Their ids are in `secrets[]`.
- The verification sends a `HEAD` request to your URL. A response with a status below `500` is enough, `404` or `405` too.
- Continue with [Delivery and signatures](/api-reference/webhooks/signatures) to validate every delivery.
