> For the complete documentation index, see [llms.txt](https://docs.aviowiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aviowiki.com/webhooks/managing-subscriptions.md).

# Managing subscriptions

### Create a Subscription

```bash
curl -X POST "https://api.aviowiki.com/webhooks" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook",
    "types": ["AIRPORT", "RUNWAY", "PROVIDER"],
    "authHeader": "Bearer your-custom-auth-token"
  }'
```

**Request Body**

| Field        | Type   | Required | Description                                                                                             |
| ------------ | ------ | -------- | ------------------------------------------------------------------------------------------------------- |
| `url`        | string | Yes      | The HTTPS endpoint where notifications will be sent. Must be unique across all subscriptions.           |
| `types`      | array  | Yes      | The event types you want to subscribe to. See [Event Types](/webhooks/event-types.md).                  |
| `authHeader` | string | No       | A custom `Authorization` header value that will be included in every webhook delivery to your endpoint. |

**Response** `201 Created`

```json
{
  "aid": "WSAxxxxxxxx",
  "url": "https://your-server.com/webhook",
  "types": ["AIRPORT", "RUNWAY", "PROVIDER"],
  "secret": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

{% hint style="warning" %}
Save the `secret` from the response. It is used to verify webhook signatures and is only returned when the subscription is created. See [Verifying Signatures](/webhooks/verifying-signatures.md).
{% endhint %}

The `aid` is your subscription identifier, used for updating and deleting the subscription.

### Update a Subscription

```bash
curl -X PUT "https://api.aviowiki.com/webhooks/WSAxxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook-v2",
    "types": ["AIRPORT", "FUEL_COST", "FLIGHT"],
    "authHeader": "Bearer updated-auth-token"
  }'
```

Returns the updated subscription object.

### Delete a Subscription

```bash
curl -X DELETE "https://api.aviowiki.com/webhooks/WSAxxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Returns `200 OK` on success.

### List Your Subscriptions

```bash
curl -X GET "https://api.aviowiki.com/webhooks" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Returns an array of all your active webhook subscriptions.
