## Put Object Lifecycle Rules `client.r2.buckets.lifecycle.update(stringbucketName, LifecycleUpdateParamsparams, RequestOptionsoptions?): LifecycleUpdateResponse` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle` Set the object lifecycle rules for a bucket. ### Parameters - `bucketName: string` Name of the bucket. - `params: LifecycleUpdateParams` - `account_id: string` Path param: Account ID. - `rules?: Array` Body param - `id: string` Unique identifier for this rule. - `conditions: Conditions` Conditions that apply to all transitions of this rule. - `prefix: string` Transitions 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. - `enabled: boolean` Whether or not this rule is in effect. - `abortMultipartUploadsTransition?: AbortMultipartUploadsTransition` Transition to abort ongoing multipart uploads. - `condition?: Condition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `deleteObjectsTransition?: DeleteObjectsTransition` Transition to delete objects. - `condition?: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClassTransitions?: Array` Transitions to change the storage class of objects. - `condition: R2LifecycleAgeCondition | R2LifecycleDateCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `R2LifecycleAgeCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `maxAge: number` - `type: "Age"` - `"Age"` - `R2LifecycleDateCondition` Condition for lifecycle transitions to apply on a specific date. - `date: string` - `type: "Date"` - `"Date"` - `storageClass: "InfrequentAccess"` - `"InfrequentAccess"` - `jurisdiction?: "default" | "eu" | "fedramp"` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `"default"` - `"eu"` - `"fedramp"` ### Returns - `LifecycleUpdateResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const lifecycle = await client.r2.buckets.lifecycle.update('example-bucket', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(lifecycle); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ```