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

# Create Webhook

> Create a new webhook endpoint

<ParamField body="url" type="string" required>
  HTTPS URL to receive webhook events.
</ParamField>

<ParamField body="events" type="array" required>
  Array of event types to subscribe to.
</ParamField>

<ParamField body="enabled" type="boolean" default={true}>
  Whether the webhook is active.
</ParamField>

<ParamField body="description" type="string">
  Human-readable description.
</ParamField>

<ParamField body="headers" type="object">
  Custom headers to include in webhook requests.
</ParamField>

<ResponseField name="webhook" type="object">
  The created webhook configuration.
</ResponseField>

<ResponseField name="secret" type="string">
  Webhook secret for signature verification. **Only shown once at creation.**
</ResponseField>

<Warning>
  Save the webhook secret immediately. It cannot be retrieved later.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://agentgate.mynewapi.com/v1/webhooks \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://your-app.com/webhooks/agentgate",
      "events": ["run.completed", "run.failed"],
      "description": "Production webhook"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "webhook": {
      "id": "wh_abc123",
      "url": "https://your-app.com/webhooks/agentgate",
      "events": ["run.completed", "run.failed"],
      "enabled": true,
      "description": "Production webhook",
      "createdAt": "2024-01-15T10:30:00Z"
    },
    "secret": "whsec_xxxxxxxxxxxxxxxxxxxxxxxx"
  }
  ```
</ResponseExample>
