> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.airweave.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.airweave.ai/_mcp/server.

# Create Subscription

POST https://api.airweave.ai/webhooks/subscriptions
Content-Type: application/json

Create a new webhook subscription.

Webhook subscriptions allow you to receive real-time notifications when events
occur in Airweave. When you create a subscription, you specify:

- **URL**: The HTTPS endpoint where events will be delivered
- **Event Types**: Which events you want to receive (e.g., `sync.completed`, `sync.failed`)
- **Secret** (optional): A custom signing secret for verifying webhook signatures

After creation, Airweave will send HTTP POST requests to your URL whenever
matching events occur. Each request includes a signature header for verification.

Reference: https://docs.airweave.ai/api-reference/webhooks/create-subscription-webhooks-subscriptions-post

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Servers

- `https://api.airweave.ai` (Production, default)
- `http://localhost:8001` (Local)

## Request

### Body (application/json)

This endpoint expects a CreateSubscriptionRequest.

- `url` (string, required) — The HTTPS URL where webhook events will be delivered. Must be a publicly accessible endpoint that returns a 2xx status code.
- `event_types` (list of enum, required) — List of event types to subscribe to. Events not in this list will not be delivered to this subscription. Available types: `sync.pending`, `sync.running`, `sync.completed`, `sync.failed`, `sync.cancelled`, `source_connection.created`, `source_connection.auth_completed`, `source_connection.deleted`, `collection.created`, `collection.updated`, `collection.deleted`.
  - Allowed values: `sync.pending`, `sync.running`, `sync.cancelling`, `sync.completed`, `sync.failed`, `sync.cancelled`, `entity.batch_processed`, `query.processed`, `access_control.batch_processed`, `collection.created`, `collection.updated`, `collection.deleted`, `source_connection.created`, `source_connection.auth_completed`, `source_connection.deleted`, `organization.created`, `organization.deleted`, `organization.member_added`, `organization.member_removed`, `search.started`, `search.completed`, `search.failed`, `search.reranking`, `search.thinking`, `search.tool_called`
- `secret` (string, optional, nullable) — Optional custom signing secret for webhook signature verification. If not provided, a secure secret will be auto-generated. Must be at least 24 characters if specified.

## Response

### 200

Created subscription

- `id` (string, required) — Unique identifier for this subscription (UUID format)
- `url` (string, required) — The URL where webhook events are delivered
- `created_at` (string, required) — When this subscription was created (ISO 8601 format, UTC)
- `updated_at` (string, required) — When this subscription was last updated (ISO 8601 format, UTC)
- `filter_types` (list of string, optional, nullable) — Event types this subscription is filtered to receive. See EventType enum for all available types.
- `disabled` (boolean, optional, default: false) — Whether this subscription is currently disabled. Disabled subscriptions do not receive event deliveries.
- `description` (string, optional, nullable) — Optional human-readable description of this subscription
- `health_status` (enum, optional) — Health status of this subscription based on recent delivery attempts. Values: 'healthy' (all recent deliveries succeeded), 'degraded' (mix of successes and failures), 'failing' (consecutive failures beyond threshold), 'unknown' (no delivery data yet).
  - Allowed values: `healthy`, `degraded`, `failing`, `unknown`

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationErrorDetail, required) — List of validation errors

### 429 Too Many Requests Error

Rate Limit Exceeded

- `detail` (string, required) — Error message explaining the rate limit

## Types

### ValidationErrorDetail

Details about a validation error for a specific field.

- `loc` (list of string, required) — Location of the error (e.g., ['body', 'url'])
- `msg` (string, required) — Human-readable error message
- `type` (string, required) — Error type identifier

## Examples

**Request**

```json
{
  "url": "https://api.mycompany.com/webhooks/airweave",
  "event_types": [
    "sync.completed",
    "sync.failed"
  ]
}
```

**Response**

```json
{
  "id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
  "url": "https://api.mycompany.com/webhooks/airweave",
  "created_at": "2024-03-01T08:00:00Z",
  "updated_at": "2024-03-15T14:30:00Z",
  "filter_types": [
    "sync.completed",
    "sync.failed"
  ],
  "disabled": false,
  "description": "Production notifications for data team",
  "health_status": "healthy"
}
```

**SDK Code**

```python
import requests

url = "https://api.airweave.ai/webhooks/subscriptions"

payload = {
    "url": "https://api.mycompany.com/webhooks/airweave",
    "event_types": ["sync.completed", "sync.failed"]
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript
import { AirweaveSDKClient } from "@airweave/sdk";

const client = new AirweaveSDKClient({ apiKey: "YOUR_API_KEY" });
await client.webhooks.createSubscription({
    url: "https://api.mycompany.com/webhooks/airweave",
    event_types: ["sync.completed", "sync.failed"]
});

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.airweave.ai/webhooks/subscriptions"

	payload := strings.NewReader("{\n  \"url\": \"https://api.mycompany.com/webhooks/airweave\",\n  \"event_types\": [\n    \"sync.completed\",\n    \"sync.failed\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.airweave.ai/webhooks/subscriptions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"url\": \"https://api.mycompany.com/webhooks/airweave\",\n  \"event_types\": [\n    \"sync.completed\",\n    \"sync.failed\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.airweave.ai/webhooks/subscriptions")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"https://api.mycompany.com/webhooks/airweave\",\n  \"event_types\": [\n    \"sync.completed\",\n    \"sync.failed\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.airweave.ai/webhooks/subscriptions', [
  'body' => '{
  "url": "https://api.mycompany.com/webhooks/airweave",
  "event_types": [
    "sync.completed",
    "sync.failed"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.airweave.ai/webhooks/subscriptions");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"url\": \"https://api.mycompany.com/webhooks/airweave\",\n  \"event_types\": [\n    \"sync.completed\",\n    \"sync.failed\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "url": "https://api.mycompany.com/webhooks/airweave",
  "event_types": ["sync.completed", "sync.failed"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.airweave.ai/webhooks/subscriptions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```