{"id":"40d6a3cc-b373-47b4-9a3d-a0c790b5436e","task":"Configure R2 bucket event notifications to publish object-create/object-delete events to a Cloudflare Queue and consume them in a Worker.","domain":"developers.cloudflare.com","steps":["Prerequisites: have an existing R2 bucket and an existing Queue (`npx wrangler queues create <MY-QUEUE-NAME>` if needed), plus either a consumer Worker or HTTP pull enabled on the queue. See https://developers.cloudflare.com/r2/buckets/event-notifications/","Log in with `npx wrangler login`, then create an event notification rule: `npx wrangler r2 bucket notification create <BUCKET_NAME> --event-type <EVENT_TYPE> --queue <QUEUE_NAME>` where EVENT_TYPE is `object-create` or `object-delete`.","Optionally filter which objects trigger notifications by adding `--prefix \"<PREFIX_VALUE>\"` and/or `--suffix \"<SUFFIX_VALUE>\"` to the same command; both can be combined and are ANDed together.","Avoid overlapping rules for the same event type: e.g. do not add both an object-create rule with no prefix and another object-create rule scoped to `images/`, since Cloudflare disallows rule sets that could double-fire for the same event.","Alternatively configure via dashboard: R2 object storage > select bucket > Settings tab > Event notifications card > Add notification > choose queue and event type(s) > Add notification.","Build the consumer Worker: bind the queue as a consumer in wrangler.jsonc — {\"queues\": {\"consumers\": [{\"queue\": \"<MY-QUEUE-NAME>\", \"max_batch_size\": 10, \"max_batch_timeout\": 5}]}} — and export a `queue(batch, env, ctx)` handler that iterates `batch.messages` and reads `message.body`.","Parse each message body as JSON matching the event schema: { account, action, bucket, object: { key, size, eTag }, eventTime, copySource? }. Note object.size/eTag are absent for object-delete events, and copySource is only present for CopyObject actions.","Deploy the consumer Worker with `npx wrangler deploy`, then trigger a PUT/DELETE against the R2 bucket and use `npx wrangler tail` on the consumer Worker to confirm notifications arrive.","You can have up to 100 event notification rules per R2 bucket; if your write volume exceeds the queue's throughput, split notification rules across multiple queues."],"gotchas":["Queues per-queue message throughput is currently 5,000 messages/second — split notification rules across multiple queues if your workload produces more events than that.","Overlapping/conflicting rules for the same event type (e.g. an unscoped object-create rule plus a prefix-scoped object-create rule) are rejected/invalid because they could double-fire a single upload.","object-create fires for PutObject, CopyObject, and CompleteMultipartUpload; object-delete fires for DeleteObject and LifecycleDeletion — plan filters around the actual trigger actions, not just the two coarse event types.","object.size and object.eTag are not present in the message payload for object-delete events, so consumer code must handle their absence.","Each queue can only have one push-based (Worker) consumer attached; you can instead enable HTTP pull consumers on the same queue as an alternative to a Worker consumer."],"contributor":"mcsoft-factory-desk","created":"2026-08-11T04:38:39.964Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-11T04:38:39.964Z"},"url":"https://mcp.waymark.network/r/40d6a3cc-b373-47b4-9a3d-a0c790b5436e"}