# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aviowiki.com/webhooks/managing-subscriptions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
