# Add and remove webhook NFT filters

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

PATCH https://dashboard.alchemy.com/api/update-webhook-nft-filters

Adds and removes the NFT filters of an NFT activity webhook. The JSON body
takes `webhook_id`, and `nft_filters_to_add` and `nft_filters_to_remove`,
which are optional. A filter that is in both lists is not changed.

Reference: https://www.alchemy.com/docs/data/webhooks/webhooks-api-endpoints/update-webhook-nft-filters

## Headers

| Name | Type | Required | Description |
|------|------|----------|-------------|
| X-Alchemy-Token | string | Yes | Your team's auth token. Find it on the Webhooks page of the Alchemy dashboard. |

## Code Examples

### cURL

```bash
curl --request PATCH \
  --url https://dashboard.alchemy.com/api/update-webhook-nft-filters \
  --header 'Content-Type: application/json' \
  --header 'X-Alchemy-Token: string' \
  --data '{
  "webhook_id": "string",
  "nft_filters_to_add": [
    {
      "contract_address": "string",
      "token_id": "string"
    }
  ],
  "nft_filters_to_remove": [
    {
      "contract_address": "string",
      "token_id": "string"
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', 'X-Alchemy-Token': 'string'},
  body: JSON.stringify({
    webhook_id: 'string',
    nft_filters_to_add: [{contract_address: 'string', token_id: 'string'}],
    nft_filters_to_remove: [{contract_address: 'string', token_id: 'string'}]
  })
};

fetch('https://dashboard.alchemy.com/api/update-webhook-nft-filters', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://dashboard.alchemy.com/api/update-webhook-nft-filters"

payload = {
    "webhook_id": "string",
    "nft_filters_to_add": [
        {
            "contract_address": "string",
            "token_id": "string"
        }
    ],
    "nft_filters_to_remove": [
        {
            "contract_address": "string",
            "token_id": "string"
        }
    ]
}
headers = {
    "Content-Type": "application/json",
    "X-Alchemy-Token": "string"
}

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

print(response.text)
```

### Go

```go
package main

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

func main() {

	url := "https://dashboard.alchemy.com/api/update-webhook-nft-filters"

	payload := strings.NewReader("{\n  \"webhook_id\": \"string\",\n  \"nft_filters_to_add\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ],\n  \"nft_filters_to_remove\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ]\n}")

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

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("X-Alchemy-Token", "string")

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

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

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.patch("https://dashboard.alchemy.com/api/update-webhook-nft-filters")
  .header("Content-Type", "application/json")
  .header("X-Alchemy-Token", "string")
  .body("{\n  \"webhook_id\": \"string\",\n  \"nft_filters_to_add\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ],\n  \"nft_filters_to_remove\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://dashboard.alchemy.com/api/update-webhook-nft-filters");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Alchemy-Token", "string");
request.AddJsonBody("{\n  \"webhook_id\": \"string\",\n  \"nft_filters_to_add\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ],\n  \"nft_filters_to_remove\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ]\n}", false);
var response = await client.PatchAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /api/update-webhook-nft-filters
method: PATCH
operation:
  operationId: UpdateWebhookNftFilters
  responses:
    '200':
      description: Changed the webhook's NFT filters
      content:
        application/json:
          schema:
            properties: {}
            type: object
            description: Construct a type with a set of properties K of type T
            additionalProperties: false
          examples:
            Example 1:
              value: {}
    '400':
      description: Invalid input
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Missing or invalid parameters.
                name: ValidationError
    '401':
      description: Requires authentication
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Unauthenticated request.
                name: AuthError
    '404':
      description: Webhook not found
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Webhook not found
                name: null
    '429':
      description: Rate limited
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: You're sending too many requests, please wait for 0.5 seconds and retry
                name: null
    '503':
      description: Webhooks service unavailable
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Internal server error
                name: ServerError
  description: |-
    Adds and removes the NFT filters of an NFT activity webhook. The JSON body
    takes `webhook_id`, and `nft_filters_to_add` and `nft_filters_to_remove`,
    which are optional. A filter that is in both lists is not changed.
  summary: Add and remove webhook NFT filters
  tags:
    - Webhooks
  security:
    - team_api_key: []
  parameters: []
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          required:
            - webhook_id
          properties:
            webhook_id:
              type: string
              description: The webhook ID.
            nft_filters_to_add:
              type: array
              nullable: true
              items:
                type: object
                required:
                  - contract_address
                properties:
                  contract_address:
                    type: string
                    description: The NFT contract address, or "*" to match NFT activity on every contract.
                  token_id:
                    type: string
                    nullable: true
                    description: A decimal or "0x" hex token ID. Leave it out, set it to null, or use "*", to match every token. Cannot be set when `contract_address` is "*".
              description: The NFT filters to add.
            nft_filters_to_remove:
              type: array
              nullable: true
              items:
                type: object
                required:
                  - contract_address
                properties:
                  contract_address:
                    type: string
                    description: The NFT contract address, or "*" to match NFT activity on every contract.
                  token_id:
                    type: string
                    nullable: true
                    description: A decimal or "0x" hex token ID. Leave it out, set it to null, or use "*", to match every token. Cannot be set when `contract_address` is "*".
              description: The NFT filters to remove.
```
