> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unosend.co/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>
  The URL to receive webhook events.
</ParamField>

<ParamField body="events" type="string[]" required>
  Events to subscribe to: `email.sent`, `email.delivered`, `email.opened`, `email.clicked`, `email.bounced`, `email.complained`.
</ParamField>

### Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.unosend.co/webhooks \
    -H "Authorization: Bearer un_xxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://yourapp.com/webhooks/unosend",
      "events": ["email.delivered", "email.bounced"]
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch('https://api.unosend.co/webhooks', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer un_xxxxxxxxxx',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      url: 'https://yourapp.com/webhooks/unosend',
      events: ['email.delivered', 'email.bounced']
    })
  });
  ```

  ```python Python theme={null}
  import requests

  requests.post('https://api.unosend.co/webhooks',
    headers={'Authorization': 'Bearer un_xxxxxxxxxx'},
    json={
      'url': 'https://yourapp.com/webhooks/unosend',
      'events': ['email.delivered', 'email.bounced']
    }
  )
  ```
</CodeGroup>

### Response

```json 201 theme={null}
{
  "success": true,
  "data": {
    "id": "wh_123",
    "url": "https://yourapp.com/webhooks/unosend",
    "events": ["email.delivered", "email.bounced"],
    "signing_secret": "whsec_abc123...",
    "created_at": "2024-01-15T10:30:00.000Z"
  }
}
```

<Warning>
  Store the `signing_secret` securely. It's only shown once and is used to verify webhook signatures.
</Warning>
