Skip to content
Start here

Get Bucket Lock Rules

GET/accounts/{account_id}/r2/buckets/{bucket_name}/lock

Get lock rules for a bucket.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Path ParametersExpand Collapse
account_id: string

Account ID.

maxLength32
bucket_name: string

Name of the bucket.

maxLength64
minLength3
Header ParametersExpand Collapse
"cf-r2-jurisdiction": optional "default" or "eu" or "fedramp"

Jurisdiction where objects in this bucket are guaranteed to be stored.

One of the following:
"default"
"eu"
"fedramp"
ReturnsExpand Collapse
errors: array of ResponseInfo { code, message, documentation_url, source }
code: number
minimum1000
message: string
documentation_url: optional string
source: optional { pointer }
pointer: optional string
messages: array of string
result: { rules }
rules: optional array of { id, condition, enabled, prefix }
id: string

Unique identifier for this rule.

condition: { maxAgeSeconds, type } or { date, type } or { type }

Condition to apply a lock rule to an object for how long in seconds.

One of the following:
R2LockRuleAgeCondition { maxAgeSeconds, type }

Condition to apply a lock rule to an object for how long in seconds.

maxAgeSeconds: number
type: "Age"
R2LockRuleDateCondition { date, type }

Condition to apply a lock rule to an object until a specific date.

date: string
formatdate-time
type: "Date"
R2LockRuleIndefiniteCondition { type }

Condition to apply a lock rule indefinitely.

type: "Indefinite"
enabled: boolean

Whether or not this rule is in effect.

prefix: optional string

Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads.

success: true

Whether the API call was successful.

Get Bucket Lock Rules

curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/r2/buckets/$BUCKET_NAME/lock \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "rules": [
      {
        "id": "Lock all objects for 24 hours",
        "condition": {
          "maxAgeSeconds": 100,
          "type": "Age"
        },
        "enabled": true,
        "prefix": "prefix"
      }
    ]
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "rules": [
      {
        "id": "Lock all objects for 24 hours",
        "condition": {
          "maxAgeSeconds": 100,
          "type": "Age"
        },
        "enabled": true,
        "prefix": "prefix"
      }
    ]
  },
  "success": true
}