# Subscribe to Events

<mark style="color:blue;">`POST`</mark> `https://api.getalby.com/nwc/subscriptions`

Notifies about new events matching the filter provided via webhooks

#### Request Body

<table><thead><tr><th width="157">Name</th><th width="138">Type</th><th>Description</th></tr></thead><tbody><tr><td>relayUrl</td><td>string</td><td>If no relay is provided, it uses the default relay (wss://relay.getalby.com/v1)</td></tr><tr><td>webhookUrl<mark style="color:red;">*</mark></td><td>string</td><td>Webhook URL to publish events</td></tr><tr><td>filter<mark style="color:red;">*</mark></td><td>JSON object (see <a href="#filter-example">example</a>)</td><td>Filters to subscribe to</td></tr></tbody></table>

#### Filter Example

```json
{
  "ids": ["id1", "id2"],
  "kinds": [1,2],
  "authors": ["author1", "author2"],
  "since": 1721212121,
  "until": 1721212121,
  "limit": 10,
  "search": "example search",
  "#tag1": ["value1", "value2"],
  "#tag2": ["value3"],
  "#tag3": ["value4", "value5", "value6"],
}
// Source: https://pkg.go.dev/github.com/nbd-wtf/go-nostr@v0.30.0#Filter
```

#### Response

{% tabs %}
{% tab title="200: OK" %}

```javascript
{
  "subscription_id": "f370d1fc-x0x0-x0x0-x0x0-8f68fa12f32c",
  "webhookUrl": "https://your.webhook.url"
}
```

{% endtab %}
{% endtabs %}

#### Response to Webhook URL

{% tabs %}
{% tab title="200: OK" %}

```javascript
{
  "id": "a16ycf4a01bcxx........xxxxx",
  "pubkey": "a16y69effexxxx........xxxxx",
  "created_at": 1709033612,
  "kind": 23195,
  "tags": [
      [
          "p",
          "f490f5xxxxx........xxxxx"
      ],
      [
          "e",
          "a41aefxxxxx........xxxxx"
      ]
  ],
  "content": "<encrypted content>",
  "sig": "<signature>"
}
```

{% endtab %}
{% endtabs %}
