Cloudflare R2 is an S3-compatible object storage service with zero egress fees. Use the API to manage buckets and configure storage settings.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/cloudflare-typescript/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Access the R2 API:Buckets
Manage R2 storage buckets.Create a bucket
Create a new R2 bucket.Your Cloudflare account ID
Bucket name (3-63 characters, lowercase, alphanumeric, and hyphens)
Data jurisdiction for the bucket (e.g., ‘eu’ for EU data residency)
Storage class: ‘Standard’ or ‘InfrequentAccess’
The bucket name
ISO 8601 timestamp when the bucket was created
The bucket’s location/jurisdiction
List buckets
Retrieve all R2 buckets in your account.Your Cloudflare account ID
Filter buckets by jurisdiction
Pagination cursor
Number of buckets per page (default: 1000, max: 1000)
Array of bucket objects
Get a bucket
Retrieve details about a specific bucket.The bucket name
Your Cloudflare account ID
Update a bucket
Update bucket configuration.The bucket name
Your Cloudflare account ID
Storage class: ‘Standard’ or ‘InfrequentAccess’
Delete a bucket
Delete an R2 bucket. The bucket must be empty.The bucket name to delete
Your Cloudflare account ID
CORS
Manage Cross-Origin Resource Sharing (CORS) policies.Get CORS configuration
Retrieve the CORS configuration for a bucket.Update CORS configuration
Set CORS rules for a bucket.Array of CORS rule objects
Array of allowed origin URLs
Array of allowed HTTP methods
Array of allowed headers (use [’*’] for all headers)
Cache duration for preflight requests in seconds
Delete CORS configuration
Remove CORS configuration from a bucket.Lifecycle policies
Manage object lifecycle rules.Get lifecycle configuration
Update lifecycle configuration
Set lifecycle rules to automatically delete or transition objects.Array of lifecycle rule objects
Unique identifier for the rule
Rule status: ‘Enabled’ or ‘Disabled’
Object key prefix to match
Expiration settings
Number of days after which objects expire
Event notifications
Configure event notifications to trigger Workers or send to queues.Get event notifications
Update event notifications
Array of event notification rules
Array of S3 event types (e.g., ‘PutObject’, ‘DeleteObject’)
Cloudflare Queue ID to send notifications to
Object key prefix filter
Object key suffix filter
Temporary credentials
Generate temporary S3-compatible credentials for bucket access.Create temporary credentials
Your Cloudflare account ID
The bucket name
Array of permissions: ‘read’, ‘write’, or ‘delete’
Time-to-live in seconds (default: 3600, max: 43200)
S3-compatible access key ID
S3-compatible secret access key
Session token for temporary credentials
ISO 8601 timestamp when credentials expire