Skip to content
Start here

Get Event Notification Rule

client.R2.Buckets.EventNotifications.Get(ctx, bucketName, queueID, params) (*BucketEventNotificationGetResponse, error)
GET/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}

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

Name of the bucket.

maxLength64
minLength3
queueID string

Queue ID.

maxLength32
params BucketEventNotificationGetParams
AccountID param.Field[string]

Path param: Account ID.

maxLength32
Jurisdiction param.Field[BucketEventNotificationGetParamsCfR2Jurisdiction]Optional

Header param: The bucket jurisdiction.

const BucketEventNotificationGetParamsCfR2JurisdictionDefault BucketEventNotificationGetParamsCfR2Jurisdiction = "default"
const BucketEventNotificationGetParamsCfR2JurisdictionEu BucketEventNotificationGetParamsCfR2Jurisdiction = "eu"
const BucketEventNotificationGetParamsCfR2JurisdictionFedramp BucketEventNotificationGetParamsCfR2Jurisdiction = "fedramp"
ReturnsExpand Collapse
type BucketEventNotificationGetResponse struct{…}
QueueID stringOptional

Queue ID.

QueueName stringOptional

Name of the queue.

Rules []BucketEventNotificationGetResponseRuleOptional
Actions []BucketEventNotificationGetResponseRulesAction

Array of R2 object actions that will trigger notifications.

One of the following:
const BucketEventNotificationGetResponseRulesActionPutObject BucketEventNotificationGetResponseRulesAction = "PutObject"
const BucketEventNotificationGetResponseRulesActionCopyObject BucketEventNotificationGetResponseRulesAction = "CopyObject"
const BucketEventNotificationGetResponseRulesActionDeleteObject BucketEventNotificationGetResponseRulesAction = "DeleteObject"
const BucketEventNotificationGetResponseRulesActionCompleteMultipartUpload BucketEventNotificationGetResponseRulesAction = "CompleteMultipartUpload"
const BucketEventNotificationGetResponseRulesActionLifecycleDeletion BucketEventNotificationGetResponseRulesAction = "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.

Get Event Notification Rule

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"),
  )
  eventNotification, err := client.R2.Buckets.EventNotifications.Get(
    context.TODO(),
    "example-bucket",
    "queue_id",
    r2.BucketEventNotificationGetParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", eventNotification.QueueID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "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": {
    "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
}