Create a webhook

SDK platic.webhooks.create()

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

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

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

Request body

{
  "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

ParameterTypeDescriptionRequired
namestringWebhook name, 1 to 100 characters✓
urlstringURL where the notifications are sent, up to 500 characters✓
eventsarrayEvents it subscribes to, at least one. See available events✓
activebooleanWith false it is saved without verifying or activating. Default true—
secretstringSecret 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—
headersobjectHeaders 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—
secretsobjectMap 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—
autoPauseobjectWhen 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—

Response

201 Created. data carries the whole webhook, with the fields from get a webhook, plus activation.

{
  "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

FieldTypeDescription
activebooleantrue if the webhook already delivers
hasSecretbooleantrue if it has a signing secret. The value is never returned
activation.activebooleanResult of the verification in this call
activation.reasonobjectOnly if it was not activated: { code, message } with the reason
secretsErrorobjectOnly if the webhook was saved but a credential could not be stored or bound: { code, message }
All the others—See get a webhook

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":

{
  "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 to activate the saved webhook.

activation.reason.codeWhen
VERIFICATION_FAILEDThe destination answered with a 5xx status
OPERATION_UNCONFIRMEDThe verification could not be completed, for example because the destination did not answer in time
SECRETS_NEED_AUTHORIZATIONA credential is not authorized for the current destination

Errors

Statusdetails.codeWhen
400INVALID_REQUESTThe 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
400INVALID_REQUESTYour 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
400INVALID_CONFIGThe name, the URL, or the events are not valid
400SECRET_DESTINATION_INVALIDYou sent secret and url is not https, points to localhost or a private IP, or carries a #fragment. Nothing is saved
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENAn 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
409REQUEST_ID_CONFLICTYou repeated an Idempotency-Key with a different body. Use a new key for a new operation
{
  "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.

Notes

  • Keep the secret on your server when you create it. If you lose it, rotate it or send a new one with update a webhook.
  • The secrets created here show up in list secrets 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 to validate every delivery.