Saltar al contenido

Create a webhook endpoint

Módulo Settings

POST/webhook-endpointswebhookEndpoints.create

Creates an endpoint subscribed to the given event types through `app.create_webhook_endpoint`. The signing secret is returned once. Requires `Idempotency-Key`; a replay returns the original response. A rule that refuses the request returns 422 with `refusal` and `reason`.

  • Requiere la capacidad org.webhooks.manage.
  • Alcances de OAuth: org.
  • Envía el encabezado Idempotency-Key. Una repetición con la misma clave devuelve la respuesta original.
  • Estados de error: 400, 401, 409, 422, 429. Los errores son detalles de problema RFC 9457.

Cuerpo de la solicitud: WebhookEndpointCreate

webhookEndpoints.create: WebhookEndpointCreate
CampoTipoObligatorioDescripción
urlstring (uri)SíHTTPS endpoint URL.
eventsarray of stringSíSubscribed event names.
descriptionstring | nullNoWhat the endpoint is for.Restricciones: length 1 to 2000
{
  "url": "https://northwindlive.example/files/site-plan.pdf",
  "events": [
    "record.state_changed",
    "po.approved"
  ],
  "description": "Sync approved POs to the ERP."
}

Respuesta 201: WebhookEndpointSecret

webhookEndpoints.create: WebhookEndpointSecret
CampoTipoObligatorioDescripción
webhook_endpoint_idstring (uuid)SíIdentifier of the webhook endpoint.
signing_secretstringSíThe endpoint's signing secret. Shown once; it is stored in Vault and never read back.Restricciones: length 1 to any
{
  "webhook_endpoint_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
  "signing_secret": "whsec_5Jk2pQ8xL1nV7cR3"
}

Ejemplos de código

curl -X POST "$XOS_BASE_URL/webhook-endpoints" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://northwindlive.example/files/site-plan.pdf","events":["record.state_changed","po.approved"],"description":"Sync approved POs to the ERP."}'
const { data } = await xos.webhookEndpoints.create({
    "url": "https://northwindlive.example/files/site-plan.pdf",
    "events": [
      "record.state_changed",
      "po.approved"
    ],
    "description": "Sync approved POs to the ERP."
  });
response = xos.webhook_endpoints.create({"url": "https://northwindlive.example/files/site-plan.pdf", "events": ["record.state_changed", "po.approved"], "description": "Sync approved POs to the ERP."})
xos webhook-endpoints create --data '{"url":"https://northwindlive.example/files/site-plan.pdf","events":["record.state_changed","po.approved"],"description":"Sync approved POs to the ERP."}'