Skip to content

Change an R2 bucket

PATCH
/api/v1/storage/r2/{bucket}
curl --request PATCH \
--url https://digize.com/api/v1/storage/r2/example \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \
--header 'x-api-key: <x-api-key>' \
--data '{ "r2Dev": true, "publicHostname": "example", "cors": [ { "id": "example", "origins": [ "example" ], "methods": [ "GET" ], "headers": [ "example" ], "maxAgeSeconds": 1 } ], "lifecycle": [ { "id": "example", "prefix": "example", "action": "delete", "afterDays": 1 } ] }'

Changes a bucket’s public access (its r2.dev address, a custom domain on one of the workspace’s full-setup domains), its CORS policy or its lifecycle rules. Each list given replaces the bucket’s.

Needs the sites:write permission.

bucket
required
string
>= 1 characters <= 100 characters
Idempotency-Key
string
>= 1 characters <= 255 characters

Makes the request safe to send again: for 24 hours the same key and request answer the first response without repeating the change.

Example

5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69
Media typeapplication/json
object
r2Dev
boolean
publicHostname
Any of:
string
<= 253 characters
cors
Array<object>
<= 100 items
object
id
required
string
origins
required
Array<string>
>= 1 items <= 50 items
methods
required
Array<string>
>= 1 items
Allowed values: GET HEAD PUT POST DELETE
headers
required
Array<string>
<= 50 items
maxAgeSeconds
required
integer
<= 86400
lifecycle
Array<object>
<= 100 items
object
id
required
string
prefix
required
string
<= 1024 characters
action
required
string
Allowed values: delete infrequent_access abort_multipart
afterDays
required
integer
>= 1 <= 3650

Done

Media typeapplication/json
object
name
required
string
cloudflareName
required
string
createdAt
required
string format: date-time
location
required
string
storageClass
required
string
Allowed values: Standard Infrequent Access
objects
required
number
sizeBytes
required
number
classA
required
number
classB
required
number
publicHostname
required
string | null
r2Dev
required
boolean
r2DevDomain
required
string | null
boundTo
required
Array<object>
object
worker
required
string
variable
required
string | null
live
required
boolean
objectList
required
Array<object>
object
key
required
string
size
required
number
contentType
required
string
uploadedAt
required
string format: date-time
etag
required
string
cacheControl
required
string | null
metadata
required
object
key
additional properties
string
truncated
required
boolean
cors
required
Array<object>
object
id
required
string
origins
required
Array<string>
>= 1 items <= 50 items
methods
required
Array<string>
>= 1 items
Allowed values: GET HEAD PUT POST DELETE
headers
required
Array<string>
<= 50 items
maxAgeSeconds
required
integer
<= 86400
lifecycle
required
Array<object>
object
id
required
string
prefix
required
string
<= 1024 characters
action
required
string
Allowed values: delete infrequent_access abort_multipart
afterDays
required
integer
>= 1 <= 3650
endpoint
required
string

Example

{
"storageClass": "Standard",
"cors": [
{
"methods": [
"GET"
]
}
],
"lifecycle": [
{
"action": "delete"
}
]
}

What was sent isn’t valid (invalid).

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

No key, or one that’s unknown, off or expired.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

The key doesn’t have the permission this needs.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

Nothing has that id (not_found).

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

A request with the same Idempotency-Key is still running (conflict).

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

The Idempotency-Key was used with a different request.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

Over the rate limit; see retry-after.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}