Skip to content
Start here

List Event Notification Rules

client.R2.Buckets.EventNotifications.List(ctx, bucketName, params) (*BucketEventNotificationListResponse, error)
GET/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration

List all event notification rules for a bucket.

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 WriteWorkers R2 Storage Read
ParametersExpand Collapse
bucketName string

Name of the bucket.

maxLength64
minLength3
params BucketEventNotificationListParams
AccountID param.Field[string]

Path param: Account ID.

maxLength32
Jurisdiction param.Field[BucketEventNotificationListParamsCfR2Jurisdiction]Optional

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

const BucketEventNotificationListParamsCfR2JurisdictionDefault BucketEventNotificationListParamsCfR2Jurisdiction = "default"
const BucketEventNotificationListParamsCfR2JurisdictionEu BucketEventNotificationListParamsCfR2Jurisdiction = "eu"
const BucketEventNotificationListParamsCfR2JurisdictionFedramp BucketEventNotificationListParamsCfR2Jurisdiction = "fedramp"
ReturnsExpand Collapse
type BucketEventNotificationListResponse struct{…}
BucketName stringOptional

Name of the bucket.

Queues []BucketEventNotificationListResponseQueueOptional

List of queues associated with the bucket.

QueueID stringOptional

Queue ID.

QueueName stringOptional

Name of the queue.

Rules []BucketEventNotificationListResponseQueuesRuleOptional
Actions []BucketEventNotificationListResponseQueuesRulesAction

Array of R2 object actions that will trigger notifications.

One of the following:
const BucketEventNotificationListResponseQueuesRulesActionPutObject BucketEventNotificationListResponseQueuesRulesAction = "PutObject"
const BucketEventNotificationListResponseQueuesRulesActionCopyObject BucketEventNotificationListResponseQueuesRulesAction = "CopyObject"
const BucketEventNotificationListResponseQueuesRulesActionDeleteObject BucketEventNotificationListResponseQueuesRulesAction = "DeleteObject"
const BucketEventNotificationListResponseQueuesRulesActionCompleteMultipartUpload BucketEventNotificationListResponseQueuesRulesAction = "CompleteMultipartUpload"
const BucketEventNotificationListResponseQueuesRulesActionLifecycleDeletion BucketEventNotificationListResponseQueuesRulesAction = "LifecycleDeletion"
CreatedAt stringOptional

Timestamp when the rule was created.

Description stringOptional

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

Prefix stringOptional

Notifications will be sent only for objects with this prefix.

RuleID stringOptional

Rule ID.

Suffix stringOptional

Notifications will be sent only for objects with this suffix.

List Event Notification Rules

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/r2"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  eventNotifications, err := client.R2.Buckets.EventNotifications.List(
    context.TODO(),
    "example-bucket",
    r2.BucketEventNotificationListParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", eventNotifications.BucketName)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "bucketName": "bucketName",
    "queues": [
      {
        "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11",
        "queueName": "first-queue",
        "rules": [
          {
            "actions": [
              "PutObject",
              "CopyObject"
            ],
            "createdAt": "2024-09-19T21:54:48.405Z",
            "description": "Notifications from source bucket to queue",
            "prefix": "img/",
            "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11",
            "suffix": ".jpeg"
          }
        ]
      }
    ]
  },
  "success": true
}
{
  "errors": [
    {
      "code": 11015,
      "message": "workers.api.error.no_configs_found_for_bucket"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "bucketName": "bucketName",
    "queues": [
      {
        "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11",
        "queueName": "first-queue",
        "rules": [
          {
            "actions": [
              "PutObject",
              "CopyObject"
            ],
            "createdAt": "2024-09-19T21:54:48.405Z",
            "description": "Notifications from source bucket to queue",
            "prefix": "img/",
            "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11",
            "suffix": ".jpeg"
          }
        ]
      }
    ]
  },
  "success": true
}
{
  "errors": [
    {
      "code": 11015,
      "message": "workers.api.error.no_configs_found_for_bucket"
    }
  ],
  "messages": [],
  "result": null,
  "success": false
}