Skip to main content
Manage R2 buckets, objects, and bucket configurations from the command line.

Commands

Bucket Management

Create a new R2 bucket.
wrangler r2 bucket create <name>
name
string
required
The name of the new bucket
Options:
--location
string
The optional location hint that determines geographic placement of the R2 bucket. Options: wnam, enam, weur, eeur, apac
--storage-class
string
The default storage class for objects uploaded to this bucket (alias: -s)
--jurisdiction
string
The jurisdiction where the new bucket will be created (alias: -J)
--update-config
boolean
Automatically update your wrangler configuration file with the new bucket binding
--binding-name
string
The name of the binding to use in your wrangler configuration file
Example:
wrangler r2 bucket create my-bucket
wrangler r2 bucket create my-bucket --location=wnam --storage-class=InfrequentAccess
wrangler r2 bucket create eu-bucket --jurisdiction=eu
Note: You cannot provide both --location and --jurisdiction.
List all R2 buckets in your account.
wrangler r2 bucket list
Options:
--jurisdiction
string
The jurisdiction to list (alias: -J)
Example:
wrangler r2 bucket list
wrangler r2 bucket list --jurisdiction=eu
Get information about an R2 bucket.
wrangler r2 bucket info <bucket>
bucket
string
required
The name of the bucket to retrieve info for
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--json
boolean
default:"false"
Return the bucket information as JSON
Example:
wrangler r2 bucket info my-bucket
wrangler r2 bucket info my-bucket --json
Delete an R2 bucket.
wrangler r2 bucket delete <bucket>
bucket
string
required
The name of the bucket to delete
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket delete my-bucket
wrangler r2 bucket delete eu-bucket --jurisdiction=eu
Update the default storage class of an existing R2 bucket.
wrangler r2 bucket update storage-class <name> --storage-class <class>
name
string
required
The name of the existing bucket
Options:
--storage-class
string
required
The new default storage class for this bucket (alias: -s)
--jurisdiction
string
The jurisdiction of the bucket to be updated (alias: -J)
Example:
wrangler r2 bucket update storage-class my-bucket --storage-class=InfrequentAccess

Object Management

Fetch an object from an R2 bucket.
wrangler r2 object get <objectPath>
objectPath
string
required
The source object path in the form of {bucket}/{key}
Options:
--file
string
The destination file to create (alias: -f)
--pipe
boolean
Enables the file to be piped to a destination (alias: -p)
--local
boolean
Interact with local storage
--remote
boolean
Interact with remote storage
--persist-to
string
Directory for local persistence
--jurisdiction
string
The jurisdiction where the object exists (alias: -J)
Example:
wrangler r2 object get my-bucket/file.txt --file=./downloaded.txt
wrangler r2 object get my-bucket/file.txt --pipe > output.txt
Create an object in an R2 bucket.
wrangler r2 object put <objectPath>
objectPath
string
required
The destination object path in the form of {bucket}/{key}
Options:
--file
string
The path of the file to upload (alias: -f)
--pipe
boolean
Enables the file to be piped in (alias: -p)
--content-type
string
A standard MIME type describing the format of the object data (alias: --ct)
--content-disposition
string
Specifies presentational information for the object (alias: --cd)
--content-encoding
string
Specifies what content encodings have been applied to the object (alias: --ce)
--content-language
string
The language the content is in (alias: --cl)
--cache-control
string
Specifies caching behavior along the request/reply chain (alias: --cc)
--expires
string
The date and time at which the object is no longer cacheable
--storage-class
string
The storage class of the object to be created (alias: -s)
--local
boolean
Interact with local storage
--remote
boolean
Interact with remote storage
--persist-to
string
Directory for local persistence
--jurisdiction
string
The jurisdiction where the object will be created (alias: -J)
Example:
wrangler r2 object put my-bucket/file.txt --file=./local-file.txt
wrangler r2 object put my-bucket/image.jpg --file=./image.jpg --content-type=image/jpeg
cat file.txt | wrangler r2 object put my-bucket/file.txt --pipe
Delete an object in an R2 bucket.
wrangler r2 object delete <objectPath>
objectPath
string
required
The destination object path in the form of {bucket}/{key}
Options:
--local
boolean
Interact with local storage
--remote
boolean
Interact with remote storage
--persist-to
string
Directory for local persistence
--jurisdiction
string
The jurisdiction where the object exists (alias: -J)
Example:
wrangler r2 object delete my-bucket/file.txt

CORS Configuration

List the CORS rules for an R2 bucket.
wrangler r2 bucket cors list <bucket>
bucket
string
required
The name of the R2 bucket to list the CORS rules for
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket cors list my-bucket
Set the CORS configuration for an R2 bucket from a JSON file.
wrangler r2 bucket cors set <bucket> --file <path>
bucket
string
required
The name of the R2 bucket to set the CORS configuration for
Options:
--file
string
required
Path to the JSON file containing the CORS configuration
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--force
boolean
default:"false"
Skip confirmation (alias: -y)
Example:
wrangler r2 bucket cors set my-bucket --file=cors-config.json
The JSON file should contain a rules array following the R2 CORS API format.
Clear the CORS configuration for an R2 bucket.
wrangler r2 bucket cors delete <bucket>
bucket
string
required
The name of the R2 bucket to delete the CORS configuration for
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--force
boolean
default:"false"
Skip confirmation (alias: -y)
Example:
wrangler r2 bucket cors delete my-bucket

Lifecycle Rules

List lifecycle rules for an R2 bucket.
wrangler r2 bucket lifecycle list <bucket>
bucket
string
required
The name of the R2 bucket to list lifecycle rules for
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket lifecycle list my-bucket
Add a lifecycle rule to an R2 bucket.
wrangler r2 bucket lifecycle add <bucket>
bucket
string
required
The name of the R2 bucket to add a lifecycle rule to
Options:
--name
string
A unique name for the lifecycle rule (alias: --id)
--prefix
string
Prefix condition for the lifecycle rule (leave empty for all prefixes)
--expire-days
number
Number of days after which objects expire
--expire-date
string
Date after which objects expire (YYYY-MM-DD)
--ia-transition-days
number
Number of days after which objects transition to Infrequent Access storage
--ia-transition-date
string
Date after which objects transition to Infrequent Access storage (YYYY-MM-DD)
--abort-multipart-days
number
Number of days after which incomplete multipart uploads are aborted
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--force
boolean
default:"false"
Skip confirmation (alias: -y)
Example:
wrangler r2 bucket lifecycle add my-bucket --name=expire-old --expire-days=30
wrangler r2 bucket lifecycle add my-bucket --name=transition --ia-transition-days=90 --prefix=logs/
Remove a lifecycle rule from an R2 bucket.
wrangler r2 bucket lifecycle remove <bucket> --name <rule-name>
bucket
string
required
The name of the R2 bucket to remove a lifecycle rule from
Options:
--name
string
required
The unique name of the lifecycle rule to remove (alias: --id)
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket lifecycle remove my-bucket --name=expire-old
Set the lifecycle configuration for an R2 bucket from a JSON file.
wrangler r2 bucket lifecycle set <bucket> --file <path>
bucket
string
required
The name of the R2 bucket to set lifecycle configuration for
Options:
--file
string
required
Path to the JSON file containing lifecycle configuration
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--force
boolean
default:"false"
Skip confirmation (alias: -y)
Example:
wrangler r2 bucket lifecycle set my-bucket --file=lifecycle-config.json

Custom Domains

List custom domains for an R2 bucket.
wrangler r2 bucket domain list <bucket>
bucket
string
required
The name of the R2 bucket whose connected custom domains will be listed
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket domain list my-bucket
Get custom domain connected to an R2 bucket.
wrangler r2 bucket domain get <bucket> --domain <domain>
bucket
string
required
The name of the R2 bucket whose custom domain to retrieve
Options:
--domain
string
required
The custom domain to get information for
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket domain get my-bucket --domain=assets.example.com
Connect a custom domain to an R2 bucket.
wrangler r2 bucket domain add <bucket> --domain <domain> --zone-id <zone-id>
bucket
string
required
The name of the R2 bucket to connect a custom domain to
Options:
--domain
string
required
The custom domain to connect to the R2 bucket
--zone-id
string
required
The zone ID associated with the custom domain
--min-tls
string
Set the minimum TLS version for the custom domain (defaults to 1.0 if not set). Options: 1.0, 1.1, 1.2, 1.3
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--force
boolean
default:"false"
Skip confirmation (alias: -y)
Example:
wrangler r2 bucket domain add my-bucket --domain=assets.example.com --zone-id=abc123 --min-tls=1.2
Remove a custom domain from an R2 bucket.
wrangler r2 bucket domain remove <bucket> --domain <domain>
bucket
string
required
The name of the R2 bucket to remove the custom domain from
Options:
--domain
string
required
The custom domain to remove from the R2 bucket
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
--force
boolean
default:"false"
Skip confirmation (alias: -y)
Example:
wrangler r2 bucket domain remove my-bucket --domain=assets.example.com
Update settings for a custom domain connected to an R2 bucket.
wrangler r2 bucket domain update <bucket> --domain <domain>
bucket
string
required
The name of the R2 bucket associated with the custom domain to update
Options:
--domain
string
required
The custom domain whose settings will be updated
--min-tls
string
Update the minimum TLS version for the custom domain. Options: 1.0, 1.1, 1.2, 1.3
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket domain update my-bucket --domain=assets.example.com --min-tls=1.3

Event Notifications

List event notification rules for an R2 bucket.
wrangler r2 bucket notification list <bucket>
bucket
string
required
The name of the R2 bucket to get event notification rules for
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket notification list my-bucket
Create an event notification rule for an R2 bucket.
wrangler r2 bucket notification create <bucket> --event-types <types> --queue <queue>
bucket
string
required
The name of the R2 bucket to create an event notification rule for
Options:
--event-types
string[]
required
The type of event(s) that will emit event notifications (alias: --event-type)
--queue
string
required
The name of the queue that will receive event notification messages
--prefix
string
The prefix that an object must match to emit event notifications
--suffix
string
The suffix that an object must match to emit event notifications
--description
string
A description that can be used to identify the event notification rule after creation
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket notification create my-bucket --event-types=object-create --queue=my-queue
wrangler r2 bucket notification create my-bucket --event-types=object-create --event-types=object-delete --queue=my-queue --prefix=uploads/
Delete an event notification rule from an R2 bucket.
wrangler r2 bucket notification delete <bucket> --queue <queue>
bucket
string
required
The name of the R2 bucket to delete an event notification rule for
Options:
--queue
string
required
The name of the queue that corresponds to the event notification rule. If no rule is provided, all event notification rules associated with the bucket and queue will be deleted
--rule
string
The ID of the event notification rule to delete
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket notification delete my-bucket --queue=my-queue
wrangler r2 bucket notification delete my-bucket --queue=my-queue --rule=rule-123

Sippy (Incremental Migration)

Enable Sippy on an R2 bucket for incremental migration from cloud storage.
wrangler r2 bucket sippy enable <name>
name
string
required
The name of the bucket
Options:
--provider
string
Cloud storage provider. Options: AWS, GCS
--bucket
string
The name of the upstream bucket
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
AWS Options:
--region
string
The region of the upstream bucket (AWS only)
--access-key-id
string
The secret access key id for the upstream bucket (AWS only)
--secret-access-key
string
The secret access key for the upstream bucket (AWS only)
GCS Options:
--service-account-key-file
string
The path to your Google Cloud service account key JSON file (GCS only)
--client-email
string
The client email for your Google Cloud service account key (GCS only)
--private-key
string
The private key for your Google Cloud service account key (GCS only)
R2 Credentials:
--r2-access-key-id
string
The secret access key id for this R2 bucket
--r2-secret-access-key
string
The secret access key for this R2 bucket
Example:
wrangler r2 bucket sippy enable my-bucket --provider=AWS --bucket=source-bucket --region=us-west-2 --access-key-id=KEY --secret-access-key=SECRET --r2-access-key-id=R2KEY --r2-secret-access-key=R2SECRET
Disable Sippy on an R2 bucket.
wrangler r2 bucket sippy disable <name>
name
string
required
The name of the bucket
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket sippy disable my-bucket
Check the status of Sippy on an R2 bucket.
wrangler r2 bucket sippy get <name>
name
string
required
The name of the bucket
Options:
--jurisdiction
string
The jurisdiction where the bucket exists (alias: -J)
Example:
wrangler r2 bucket sippy get my-bucket

Build docs developers (and LLMs) love