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

# Crear una suscripción de webhook

> Copia en Cursor/Claude/Copilot para generar una integración POST /v1/webhooks.

Pega este prompt en tu asistente de programación con IA. Ya incluye el contrato, la autenticación y el envoltorio de errores, para que el código generado coincida con la API de producción.

<CodeGroup>
  ```text Prompt theme={null}
  Estás integrando la API pública de Telepatia Synapse.

  Endpoint: POST /v1/webhooks
  Base URL: https://scribe-api.telepatia.ai
  Auth: Authorization: Bearer ${SYNAPSE_API_KEY}

  Solicitud:
  - url [body]: string (requerido, format=uri, minLength=1, maxLength=2083) — https endpoint that will receive event POSTs.
  - name [body]: string (opcional, maxLength=100) — Optional human-readable label to identify this webhook in lists/UI. Trimmed server-side; a blank value stores no name.
  - events [body]: array<WebhookEventName> (opcional) — Event types to subscribe to (at least one). Preferred over `event`.
  - event [body]: string (opcional, enum: 8 values) — Webhook event types exposed to API clients.

  Mirrors `SynapseWebhookEventType` enum in datalayer (camelCase) but
  rendered to clients as snake_case dotted strings (closer to Stripe
  convention and easier to grep in caller logs).

  Éxito 200:
  - id: string
  - url: string
  - name?: string
  - events: array<WebhookEventName>
  - event?: string
  - isActive: boolean
  - signingSecretPrefix?: string
  - signingSecretVersion?: integer
  - createdAt?: string
  - updatedAt?: string
  - deletedAt?: string
  - signingSecret: string

  Errores (envoltorio: { error: { type, code, message, param? } }):
  - 400: parameter_missing, parameter_invalid, account_invalid
  - 401: authentication_required
  - 403: permission_denied, permission_denied_role
  - 503: service_unavailable

  Genera código en el lenguaje del archivo actual que:
  1. Lea SYNAPSE_API_KEY desde el entorno (no lo escribas de forma fija).
  2. Llame al endpoint con solicitud y respuesta tipadas.
  3. Asigne el envoltorio de errores a excepciones tipadas por código de estado.
  4. Agregue una prueba de flujo exitoso usando el token Bearer.
  ```

  ```bash curl theme={null}
  curl -X POST https://scribe-api.telepatia.ai/v1/webhooks \
    -H "Authorization: Bearer $SYNAPSE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "events": [
      "scribe_session.created",
      "scribe_session.completed",
      "scribe_session.error"
    ],
    "name": "Scribe prod webhook",
    "url": "https://example.com/webhooks/scribe"
  }'
  ```
</CodeGroup>
