# Configure project webhook

> Create or replace the project webhook for the project behind the API key, and activate it. The response carries the signing secret; an existing secret is kept.

`POST https://api.zavu.dev/v1/invitations/webhook`

Create or replace the project webhook for the project behind the API key, and activate it. The response carries the signing `secret`; an existing secret is kept.

This is where `invitation.status_changed` is delivered. Events are scoped to this project: when you onboard clients in sub-accounts, call this with each sub-account's API key.

## Body

- `url` (string<uri>, required)
- `events` (string[], required) One of: `invitation.status_changed`, `broadcast.status_changed`, `domain.verified`, `domain.failed`.

## Responses

### 201

Webhook configured.

- `webhook` (object, required): The project-level webhook. It receives project events such as `invitation.status_changed` for this project only: a parent project does not receive its sub-accounts' events, so configure one per sub-account with that sub-account's API key.
  - `url` (string<uri>, required)
  - `events` (string[], required) One of: `invitation.status_changed`, `broadcast.status_changed`, `domain.verified`, `domain.failed`.
  - `secret` (string): Signing secret for `X-Zavu-Signature`. Returned only by `POST /v1/invitations/webhook`.
  - `active` (boolean, required)

### 400

Invalid URL or an event a project webhook cannot subscribe to.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X POST "https://api.zavu.dev/v1/invitations/webhook" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://your-app.com/webhooks/zavu",
  "events": [
    "invitation.status_changed"
  ]
}'
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.invitations.webhook.configure({
  url: "https://your-app.com/webhooks/zavu",
  events: [
    "invitation.status_changed",
  ],
});

console.log(result);
```
