Skip to content
Start here

Create webhooks

stream.webhooks.update(WebhookUpdateParams**kwargs) -> WebhookUpdateResponse
PUT/accounts/{account_id}/stream/webhook

Creates a webhook notification.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Stream Write
ParametersExpand Collapse
account_id: Optional[str]

The account identifier tag.

maxLength32
notification_url: Optional[str]

The URL where webhooks will be sent.

formaturi
notification_url: Optional[str]

The URL where webhooks will be sent.

formaturi
ReturnsExpand Collapse
class WebhookUpdateResponse:
modified: Optional[datetime]

The date and time the webhook was last modified.

formatdate-time
notification_url: Optional[str]

The URL where webhooks will be sent.

formaturi
notification_url: Optional[str]

The URL where webhooks will be sent.

formaturi
secret: Optional[str]

The secret used to verify webhook signatures.

Create webhooks

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
webhook = client.stream.webhooks.update(
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(webhook.modified)
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "modified": "2014-01-02T02:20:00Z",
    "notification_url": "https://example.com",
    "notificationUrl": "https://example.com",
    "secret": "secret"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "modified": "2014-01-02T02:20:00Z",
    "notification_url": "https://example.com",
    "notificationUrl": "https://example.com",
    "secret": "secret"
  }
}