# Create webhook

> Registers an endpoint. The signing `secret` is returned only in this response.

Source: https://mailvina.com/docs/api-reference/webhooks/create-webhook · Base URL: https://api.mailvina.com · Guide: https://mailvina.com/docs/webhooks

`POST /webhooks`

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | `string` | yes | Public HTTPS URL. |
| `events` | `string[]` | no | Event types to send. Empty or omitted means all events. |

**Request**

```bash
curl -X POST 'https://api.mailvina.com/webhooks' \
  -H 'Authorization: Bearer mv_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "https://acme.com/webhooks/mailvina",
  "events": [
    "email.delivered",
    "email.bounced",
    "email.complained"
  ]
}'
```

```js
const res = await fetch('https://api.mailvina.com/webhooks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MAILVINA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "url": "https://acme.com/webhooks/mailvina",
    "events": [
      "email.delivered",
      "email.bounced",
      "email.complained"
    ]
  }),
});
const data = await res.json();
```

```python
import os, requests

res = requests.post(
    "https://api.mailvina.com/webhooks",
    headers={"Authorization": f"Bearer {os.environ['MAILVINA_API_KEY']}"},
    json={
        "url": "https://acme.com/webhooks/mailvina",
        "events": [
            "email.delivered",
            "email.bounced",
            "email.complained"
        ]
    },
)
print(res.json())
```

**Response**

```json
{
  "object": "webhook",
  "id": "a1f9c1d2-7d3e-4b8f-9a0c-2e5b6d7f8a90",
  "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"
}
```

### The webhook object

An endpoint that receives events.

**Fields**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `string` | no | Always `webhook`. |
| `id` | `string` | no | Unique ID of the webhook. |
| `url` | `string` | no | Where events are posted. |
| `events` | `string[]` | no | Event types it receives. Empty means all of them. |
| `active` | `boolean` | no | `false` while paused. |
| `created_at` | `string` | no | When it was created (ISO 8601, UTC). |
| `secret` | `string` | no | Only in the create response: the secret for verifying signatures. |
