# Add webhook

`opensend.webhooks.create(input)`

Adds an endpoint that is told about the events you pick. The signing secret is in this answer and is never shown again.

Needs the scope: `webhooks:write`

## Input

- `url` (string, required): A public `https://` address of yours that takes a POST. Up to 500 characters.
- `events` (string[]): The events to be told about. Without it the webhook gets every event. Default: `["email.sent","email.delivered","email.delayed","email.bounced","email.opened","email.clicked","email.complained","email.failed","email.received","email.scheduled","email.canceled","automation.entered","automation.finished","automation.step"]`. One of: `email.sent`, `email.delivered`, `email.delayed`, `email.bounced`, `email.opened`, `email.clicked`, `email.complained`, `email.failed`, `email.received`, `email.scheduled`, `email.canceled`, `automation.entered`, `automation.finished`, `automation.step`.
- `format` (string): How an event is written and signed. `resend` sends the `svix-id`, `svix-timestamp` and `svix-signature` headers and the body an endpoint built for Resend already reads. Without it, `native`. One of: `native`, `resend`.
- `secret` (string): The signing secret the endpoint already checks with, as Resend gave it: `whsec_` and Base64. Only for the `resend` format. Without it a new secret is made.

## Returns

The call resolves to the answer, already parsed. A call the API refuses throws `OpenSendError` with the code and the message of the answer. [SDK](https://opensend.sh/docs/sdk) lists the errors of the client itself.

- `object` ("webhook"): Always `webhook`.
- `id` (string): The id of the webhook.
- `url` (string): The address events are posted to.
- `events` (string[]): The events it is told about. One of: `email.sent`, `email.delivered`, `email.delayed`, `email.bounced`, `email.opened`, `email.clicked`, `email.complained`, `email.failed`, `email.received`, `email.scheduled`, `email.canceled`, `automation.entered`, `automation.finished`, `automation.step`.
- `status` (string): `enabled` while events are posted to it, `disabled` when it is switched off. One of: `enabled`, `disabled`.
- `format` (string): How an event is written and signed: `native` is this API, `resend` is the headers, signature and body an endpoint built for Resend expects. One of: `native`, `resend`.
- `lastDeliveryAt` (string | null): When an event was last posted to it, or `null`.
- `lastStatus` (integer | null): The HTTP status your address answered with last time, or `null`.
- `createdAt` (string): When the webhook was added.
- `secret` (string): The secret to check signatures with. It is shown this once and cannot be read again.

## Example

TypeScript:

```ts
await opensend.webhooks.create({
  url: 'https://example.com/hooks/mail',
  events: ['email.delivered', 'email.bounced'],
})
```

CLI:

```bash
opensend webhooks create \
  --url https://example.com/hooks/mail \
  --events email.delivered,email.bounced
```

Answer:

```json
{
  "object": "webhook",
  "id": "wh_02",
  "url": "https://example.com/hooks/mail",
  "events": [
    "email.delivered",
    "email.bounced"
  ],
  "status": "enabled",
  "format": "native",
  "lastDeliveryAt": null,
  "lastStatus": null,
  "createdAt": "2026-11-27T09:30:00.000Z",
  "secret": "whsec_08d12dfda708a7ae4540215fe3779b10"
}
```
