Set Bucket Lock Rules
client.r2.buckets.locks.update(stringbucketName, LockUpdateParams { account_id, rules, cfR2Jurisdiction } params, RequestOptionsoptions?): LockUpdateResponse
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/lock
Replaces the lock rules for an R2 bucket. Enabled rules prevent matching objects from being overwritten or deleted for a duration, until a date, or indefinitely. Rules apply to existing and newly uploaded objects.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
Set Bucket Lock Rules
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const lock = await client.r2.buckets.locks.update('example-bucket', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
});
console.log(lock);{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {},
"success": true
}