> ## Documentation Index
> Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure S3 bucket automatic cleanup

> Sets up automatic object expiration for an S3 bucket. All objects in the bucket will be automatically deleted after the specified number of days to help manage storage costs and meet compliance requirements. This applies a global lifecycle rule to the entire bucket - all existing and future objects will be subject to the expiration policy.

Deprecated: Use PATCH /v4/`object_storages`/{`storage_id`}/buckets/{`bucket_name`} with {"lifecycle": {"expiration_days": N}} instead.



## OpenAPI

````yaml /api-reference/services_documented/object_storage_api.yaml post /storage/provisioning/v1/storage/{storage_id}/s3/bucket/{bucket_name}/lifecycle
openapi: 3.1.0
info:
  title: Gcore OpenAPI – Object Storage API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: '2026-05-11T15:10:30.328297+00:00'
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: Notifications
    x-displayName: Notifications
  - name: SSHKeys
    x-displayName: SSHKeys
  - name: Storage Locations
    x-displayName: Storage Locations
  - name: Storage
    x-displayName: Storage
  - name: Storage Statistics
    x-displayName: Storage Statistics
  - name: S3-Compatible Storage
    x-displayName: S3-Compatible Storage
  - name: SFTP Storage
    x-displayName: SFTP Storage
paths:
  /storage/provisioning/v1/storage/{storage_id}/s3/bucket/{bucket_name}/lifecycle:
    post:
      tags:
        - Storage
      summary: Configure S3 bucket automatic cleanup
      description: >-
        Sets up automatic object expiration for an S3 bucket. All objects in the
        bucket will be automatically deleted after the specified number of days
        to help manage storage costs and meet compliance requirements. This
        applies a global lifecycle rule to the entire bucket - all existing and
        future objects will be subject to the expiration policy.


        Deprecated: Use PATCH
        /v4/`object_storages`/{`storage_id`}/buckets/{`bucket_name`} with
        {"lifecycle": {"expiration_days": N}} instead.
      operationId: storageBucketLifecycleCreateHttp
      parameters:
        - name: storage_id
          in: path
          description: Unique identifier for the storage instance
          required: true
          schema:
            type: integer
            format: int64
        - name: bucket_name
          in: path
          description: Name of the S3 bucket to configure lifecycle policy for
          required: true
          schema:
            type: string
      requestBody:
        description: Lifecycle configuration for automatic object cleanup
        content:
          application/json:
            schema:
              type: object
              properties:
                expiration_days:
                  type: integer
                  description: >-
                    Number of days after which objects will be automatically
                    deleted from the bucket.

                    Must be a positive integer. Common values: 30 for monthly
                    cleanup, 365 for yearly retention.
                  format: int64
                  example: 30
        required: true
      responses:
        '204':
          description: >-
            A SuccessResponse is a response that shows that operations was
            completed successfully
          content: {}
        '400':
          description: ErrResponse
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrResponse'
      deprecated: true
components:
  schemas:
    ErrResponse:
      type: object
      properties:
        error:
          type: string
      description: ErrResponse is an error response
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234$abcdef`
      type: apiKey
      in: header
      name: Authorization

````