Skip to content
Start here

Create Event Notification Rule

r2.buckets.event_notifications.update(strqueue_id, EventNotificationUpdateParams**kwargs) -> object
PUT/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}

Create event notification rule.

Security

API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Workers R2 Storage Write
ParametersExpand Collapse
account_id: str

Account ID.

maxLength32
bucket_name: str

Name of the bucket.

maxLength64
minLength3
queue_id: str

Queue ID.

maxLength32
rules: Iterable[Rule]

Array of rules to drive notifications.

actions: List[Literal["PutObject", "CopyObject", "DeleteObject", 2 more]]

Array of R2 object actions that will trigger notifications.

One of the following:
"PutObject"
"CopyObject"
"DeleteObject"
"CompleteMultipartUpload"
"LifecycleDeletion"
description: Optional[str]

A description that can be used to identify the event notification rule after creation.

prefix: Optional[str]

Notifications will be sent only for objects with this prefix.

suffix: Optional[str]

Notifications will be sent only for objects with this suffix.

jurisdiction: Optional[Literal["default", "eu", "fedramp"]]

Jurisdiction where objects in this bucket are guaranteed to be stored.

One of the following:
"default"
"eu"
"fedramp"
ReturnsExpand Collapse
object

Create Event Notification Rule

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
event_notification = client.r2.buckets.event_notifications.update(
    queue_id="queue_id",
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
    bucket_name="example-bucket",
    rules=[{
        "actions": ["PutObject", "CopyObject"]
    }],
)
print(event_notification)
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {},
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {},
  "success": true
}