Skip to content
Start here

Lifecycle

Get Object Lifecycle Rules
client.r2.buckets.lifecycle.get(stringbucketName, LifecycleGetParams { account_id, jurisdiction } params, RequestOptionsoptions?): LifecycleGetResponse { rules }
GET/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle
Put Object Lifecycle Rules
client.r2.buckets.lifecycle.update(stringbucketName, LifecycleUpdateParams { account_id, rules, jurisdiction } params, RequestOptionsoptions?): LifecycleUpdateResponse
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle
ModelsExpand Collapse
LifecycleGetResponse { rules }
rules?: Array<Rule>
id: string

Unique identifier for this rule.

conditions: Conditions { prefix }

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 { condition }

Transition to abort ongoing multipart uploads.

condition?: Condition { maxAge, type }

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

maxAge: number
type: "Age"
deleteObjectsTransition?: DeleteObjectsTransition { condition }

Transition to delete objects.

condition?: R2LifecycleAgeCondition { maxAge, type } | R2LifecycleDateCondition { date, type }

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

One of the following:
R2LifecycleAgeCondition { maxAge, type }

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

maxAge: number
type: "Age"
R2LifecycleDateCondition { date, type }

Condition for lifecycle transitions to apply on a specific date.

date: string
formatdate-time
type: "Date"
storageClassTransitions?: Array<StorageClassTransition>

Transitions to change the storage class of objects.

condition: R2LifecycleAgeCondition { maxAge, type } | R2LifecycleDateCondition { date, type }

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

One of the following:
R2LifecycleAgeCondition { maxAge, type }

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

maxAge: number
type: "Age"
R2LifecycleDateCondition { date, type }

Condition for lifecycle transitions to apply on a specific date.

date: string
formatdate-time
type: "Date"
storageClass: "InfrequentAccess"
LifecycleUpdateResponse = unknown