Skip to content
Start here

Lifecycle

Get Object Lifecycle Rules
GET/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle
Put Object Lifecycle Rules
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle
ModelsExpand Collapse
LifecycleGetResponse { rules }
rules: optional array of { id, conditions, enabled, 3 more }
id: string

Unique identifier for this rule.

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

Transition to abort ongoing multipart uploads.

condition: optional { maxAge, type }

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

maxAge: number
type: "Age"
deleteObjectsTransition: optional { condition }

Transition to delete objects.

condition: optional { maxAge, type } or { 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: optional array of { condition, storageClass }

Transitions to change the storage class of objects.

condition: { maxAge, type } or { 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