Skip to content
Start here

Create Event Notification Rules

PUT/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}

Creates rules that send notifications for matching R2 object events to the specified Cloudflare Queue. Rules can filter objects by key prefix and suffix. New rules are added to any existing rules for the queue; a rule that overlaps an existing rule is rejected.

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
Path ParametersExpand Collapse
account_id: string

Cloudflare account ID that owns the R2 resource.

maxLength32
bucket_name: string

Name of the bucket.

maxLength64
minLength3
queue_id: string

ID of the Cloudflare Queue that receives notifications for matching R2 object events.

maxLength32
Header ParametersExpand Collapse
"cf-r2-jurisdiction": optional "default" or "eu" or "us" or 2 more
One of the following:
"default"
"eu"
"us"
"fedramp"
"fedramp-high"
Body ParametersJSONExpand Collapse
rules: array of object { actions, description, prefix, suffix }

Array of rules to drive notifications.

actions: array of "PutObject" or "CopyObject" or "DeleteObject" or 2 more

Array of R2 object actions that will trigger notifications.

One of the following:
"PutObject"
"CopyObject"
"DeleteObject"
"CompleteMultipartUpload"
"LifecycleDeletion"
description: optional string

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

prefix: optional string

Notifications will be sent only for objects with this prefix.

suffix: optional string

Notifications will be sent only for objects with this suffix.

ReturnsExpand Collapse
errors: array of ResponseInfo { code, message, documentation_url, source }
code: number
minimum1000
message: string
documentation_url: optional string
source: optional object { pointer }
pointer: optional string
messages: array of string
result: unknown
success: true

Whether the API call was successful.

Create Event Notification Rules

curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/event_notifications/r2/$BUCKET_NAME/configuration/queues/$QUEUE_ID \
    -X PUT \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{
          "rules": [
            {
              "actions": [
                "PutObject",
                "CopyObject"
              ]
            }
          ]
        }'
{
  "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
}