# Create webhook

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

POST https://dashboard.alchemy.com/api/create-webhook

Creates a webhook. The JSON body takes `network`, `webhook_type`,
`webhook_url`, and an optional `name`, plus the fields for the type:
`addresses` for ADDRESS_ACTIVITY, `nft_filters` for NFT_ACTIVITY, and
`graphql_query` for GRAPHQL.

Reference: https://www.alchemy.com/docs/data/webhooks/webhooks-api-endpoints/create-webhook

## 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 POST \
  --url https://dashboard.alchemy.com/api/create-webhook \
  --header 'Content-Type: application/json' \
  --header 'X-Alchemy-Token: string' \
  --data '{
  "network": "ABSTRACT_MAINNET",
  "webhook_type": "ADDRESS_ACTIVITY",
  "webhook_url": "string",
  "name": "string",
  "app_id": "string",
  "addresses": [
    "string"
  ],
  "nft_filters": [
    {
      "contract_address": "string",
      "token_id": "string"
    }
  ],
  "graphql_query": "string"
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', 'X-Alchemy-Token': 'string'},
  body: JSON.stringify({
    network: 'ABSTRACT_MAINNET',
    webhook_type: 'ADDRESS_ACTIVITY',
    webhook_url: 'string',
    name: 'string',
    app_id: 'string',
    addresses: ['string'],
    nft_filters: [{contract_address: 'string', token_id: 'string'}],
    graphql_query: 'string'
  })
};

fetch('https://dashboard.alchemy.com/api/create-webhook', 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/create-webhook"

payload = {
    "network": "ABSTRACT_MAINNET",
    "webhook_type": "ADDRESS_ACTIVITY",
    "webhook_url": "string",
    "name": "string",
    "app_id": "string",
    "addresses": ["string"],
    "nft_filters": [
        {
            "contract_address": "string",
            "token_id": "string"
        }
    ],
    "graphql_query": "string"
}
headers = {
    "Content-Type": "application/json",
    "X-Alchemy-Token": "string"
}

response = requests.post(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/create-webhook"

	payload := strings.NewReader("{\n  \"network\": \"ABSTRACT_MAINNET\",\n  \"webhook_type\": \"ADDRESS_ACTIVITY\",\n  \"webhook_url\": \"string\",\n  \"name\": \"string\",\n  \"app_id\": \"string\",\n  \"addresses\": [\n    \"string\"\n  ],\n  \"nft_filters\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ],\n  \"graphql_query\": \"string\"\n}")

	req, _ := http.NewRequest("POST", 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.post("https://dashboard.alchemy.com/api/create-webhook")
  .header("Content-Type", "application/json")
  .header("X-Alchemy-Token", "string")
  .body("{\n  \"network\": \"ABSTRACT_MAINNET\",\n  \"webhook_type\": \"ADDRESS_ACTIVITY\",\n  \"webhook_url\": \"string\",\n  \"name\": \"string\",\n  \"app_id\": \"string\",\n  \"addresses\": [\n    \"string\"\n  ],\n  \"nft_filters\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ],\n  \"graphql_query\": \"string\"\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://dashboard.alchemy.com/api/create-webhook");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Alchemy-Token", "string");
request.AddJsonBody("{\n  \"network\": \"ABSTRACT_MAINNET\",\n  \"webhook_type\": \"ADDRESS_ACTIVITY\",\n  \"webhook_url\": \"string\",\n  \"name\": \"string\",\n  \"app_id\": \"string\",\n  \"addresses\": [\n    \"string\"\n  ],\n  \"nft_filters\": [\n    {\n      \"contract_address\": \"string\",\n      \"token_id\": \"string\"\n    }\n  ],\n  \"graphql_query\": \"string\"\n}", false);
var response = await client.PostAsync(request);

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

```


## Operation Specification

```yaml
path: /api/create-webhook
method: POST
operation:
  operationId: CreateWebhook
  responses:
    '200':
      description: Created the webhook
      content:
        application/json:
          schema:
            description: |-
              Standard API response wrapper.
              All API responses are wrapped in this format for consistency.
            properties:
              data:
                description: A webhook. A key whose value would be null is left out.
                properties:
                  id:
                    type: string
                    description: The webhook ID. Other endpoints take it as `webhook_id`.
                  name:
                    type: string
                    description: Empty when the webhook has no name.
                  app_id:
                    type: string
                    description: |-
                      The ID of the webhook's app. Only V1 webhooks and webhooks of retired
                      types have one.
                  network:
                    type: string
                    description: The network of the webhook.
                  networks:
                    items:
                      type: string
                    type: array
                    description: The networks of a webhook that has more than one. Can be empty.
                  webhook_type:
                    type: string
                    description: |-
                      A webhook created before a type was retired keeps that type, for
                      example `MINED_TRANSACTION`.
                  webhook_url:
                    type: string
                    description: The URL that receives the webhook requests.
                  is_active:
                    type: boolean
                    description: Whether the webhook sends requests.
                  time_created:
                    type: number
                    format: double
                    description: Milliseconds since the epoch, truncated to whole seconds.
                  signing_key:
                    type: string
                    description: |-
                      The key that signs each webhook request. Use it to check the
                      `X-Alchemy-Signature` header.
                  version:
                    type: string
                    enum:
                      - V1
                      - V2
                    description: '`V1` only for a webhook created before V1 was retired.'
                  deactivation_reason:
                    type: string
                    description: Why the webhook was deactivated. `UNKNOWN` when no reason is set.
                required:
                  - id
                  - name
                  - network
                  - networks
                  - webhook_url
                  - is_active
                  - time_created
                  - signing_key
                  - version
                  - deactivation_reason
                type: object
                additionalProperties: false
            required:
              - data
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                data:
                  id: wh_octjglnywaupz6th
                  name: Treasury wallet activity
                  network: ETH_MAINNET
                  networks: []
                  webhook_type: ADDRESS_ACTIVITY
                  webhook_url: https://example.com/webhooks/alchemy
                  is_active: true
                  time_created: 1730764800000
                  signing_key: whsec_7mXvC3qGkJ2pT9sLwR4nYbE8
                  version: V2
                  deactivation_reason: UNKNOWN
    '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 required fields
                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
    '403':
      description: Active webhook limit reached
      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've reached the maximum number of active webhooks for your plan.
                name: PermissionError
    '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: |-
    Creates a webhook. The JSON body takes `network`, `webhook_type`,
    `webhook_url`, and an optional `name`, plus the fields for the type:
    `addresses` for ADDRESS_ACTIVITY, `nft_filters` for NFT_ACTIVITY, and
    `graphql_query` for GRAPHQL.
  summary: Create webhook
  tags:
    - Webhooks
  security:
    - team_api_key: []
  parameters: []
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          required:
            - network
            - webhook_type
            - webhook_url
          properties:
            network:
              type: string
              enum:
                - ABSTRACT_MAINNET
                - ABSTRACT_TESTNET
                - ANIME_MAINNET
                - ANIME_SEPOLIA
                - APECHAIN_CURTIS
                - APECHAIN_MAINNET
                - ARB_MAINNET
                - ARB_SEPOLIA
                - ARC_MAINNET
                - ARC_TESTNET
                - AVAX_FUJI
                - AVAX_MAINNET
                - BASE_MAINNET
                - BASE_SEPOLIA
                - BERACHAIN_BEPOLIA
                - BERACHAIN_MAINNET
                - BLAST_MAINNET
                - BLAST_SEPOLIA
                - BNB_MAINNET
                - BNB_TESTNET
                - CELO_MAINNET
                - CELO_SEPOLIA
                - ETH_MAINNET
                - ETH_SEPOLIA
                - GENSYN_TESTNET
                - GNOSIS_CHIADO
                - GNOSIS_MAINNET
                - HYPERLIQUID_MAINNET
                - INK_MAINNET
                - INK_SEPOLIA
                - LINEA_MAINNET
                - LINEA_SEPOLIA
                - MANTLE_MAINNET
                - MANTLE_SEPOLIA
                - MATIC_AMOY
                - MATIC_MAINNET
                - METIS_MAINNET
                - MONAD_MAINNET
                - MONAD_TESTNET
                - OPT_MAINNET
                - OPT_SEPOLIA
                - PLASMA_MAINNET
                - ROBINHOOD_MAINNET
                - ROBINHOOD_TESTNET
                - RONIN_MAINNET
                - RONIN_SAIGON
                - SCROLL_MAINNET
                - SETTLUS_MAINNET
                - SETTLUS_SEPTESTNET
                - SHAPE_MAINNET
                - SHAPE_SEPOLIA
                - SOLANA_DEVNET
                - SOLANA_MAINNET
                - SONEIUM_MAINNET
                - SONEIUM_MINATO
                - SONIC_MAINNET
                - STARKNET_MAINNET
                - STARKNET_SEPOLIA
                - STELLAR_MAINNET
                - STELLAR_TESTNET
                - UNICHAIN_MAINNET
                - UNICHAIN_SEPOLIA
                - WORLDCHAIN_MAINNET
                - WORLDCHAIN_SEPOLIA
                - ZETACHAIN_MAINNET
                - ZETACHAIN_TESTNET
                - ZKSYNC_MAINNET
                - ZKSYNC_SEPOLIA
                - ZORA_MAINNET
                - ZORA_SEPOLIA
              description: |-
                The network of the webhook. Every network supports `ADDRESS_ACTIVITY`, `NFT_ACTIVITY`, and `GRAPHQL`, except:
                - `SOLANA_DEVNET`, `SOLANA_MAINNET`, `STELLAR_MAINNET`, `STELLAR_TESTNET`: only `ADDRESS_ACTIVITY`.
                - `STARKNET_MAINNET`, `STARKNET_SEPOLIA`: only `GRAPHQL`.
            webhook_type:
              type: string
              enum:
                - ADDRESS_ACTIVITY
                - NFT_ACTIVITY
                - GRAPHQL
              description: 'The type of webhook. Each type requires its own field: `addresses`, `nft_filters`, or `graphql_query`.'
            webhook_url:
              type: string
              description: The URL that receives the webhook requests.
            name:
              type: string
              description: A name for the webhook.
            app_id:
              type: string
              description: Optional for `ADDRESS_ACTIVITY`. If set, it must be the ID of an app on your team.
            addresses:
              type: array
              items:
                type: string
              description: The addresses to watch. Required for `ADDRESS_ACTIVITY`.
            nft_filters:
              type: array
              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 NFTs to watch. Required for `NFT_ACTIVITY`.
            graphql_query:
              anyOf:
                - type: string
                - type: object
                  required:
                    - query
                  properties:
                    query:
                      type: string
                    skip_empty_messages:
                      type: boolean
                      default: false
                      description: If true, no webhook is sent for a block that the query matches nothing in.
              description: The GraphQL query, as a string or as an object. Required for `GRAPHQL`.
```
