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

# S3 storage for archived sessions

> Configure an S3-compatible bucket so Cake Agents can archive session data when users end sessions.

Cake Agents can upload each archived session's persistent volume to S3-compatible object storage as a compressed archive. Configure a bucket at the organization level so users can [archive sessions](/user/archive-sessions) without losing their files.

## When to configure S3

* You want users to be able to archive sessions and retain the underlying files.
* You want a durable, off-cluster copy of session data before pods and volumes are released.

If S3 is not configured, archive actions still stop the session and preserve message history, but the session's files are not saved.

## Prerequisites

* An S3-compatible bucket (AWS S3, or any S3-API-compatible service such as MinIO or Cloudflare R2).
* Credentials available to the control plane with permission to `PutObject` into the bucket.
* Admin access to Cake Agents.

## Configure S3 in the UI

1. Go to **Settings → Organization → AWS**.
2. Toggle **S3** on.
3. Fill in the fields:
   * **Bucket** — the bucket name. Required.
   * **Region** — the AWS region where the bucket lives. Defaults to `us-east-1`.
   * **Endpoint** — optional. Set this when using a non-AWS S3-compatible service.
   * **Prefix** — optional. A key prefix prepended to every object (useful for sharing a bucket across environments).
4. Save.

Each archived session is uploaded under the configured prefix, keyed by session ID.

## Configure S3 with environment variables

You can also configure storage on the control plane deployment using environment variables. UI values override environment variables when both are set.

| Setting  | Environment variable                                        | Default     |
| -------- | ----------------------------------------------------------- | ----------- |
| Enabled  | `CAKE_S3_ENABLED` or `S3_ENABLED`                           | `false`     |
| Bucket   | `CAKE_S3_BUCKET` or `S3_BUCKET`                             | —           |
| Region   | `CAKE_S3_REGION`, `S3_REGION`, or `AWS_REGION`              | `us-east-1` |
| Endpoint | `CAKE_S3_ENDPOINT`, `S3_ENDPOINT`, or `AWS_ENDPOINT_URL_S3` | —           |
| Prefix   | `CAKE_S3_PREFIX` or `S3_PREFIX`                             | `""`        |

Example Helm values snippet:

```yaml theme={null}
env:
  - name: CAKE_S3_ENABLED
    value: "true"
  - name: CAKE_S3_BUCKET
    value: cake-agents-archives
  - name: CAKE_S3_REGION
    value: us-west-2
  - name: CAKE_S3_PREFIX
    value: prod/
```

Provide AWS credentials via the standard AWS SDK mechanisms (`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, an instance role, IRSA on EKS, or Workload Identity).

## What gets uploaded

For each archived session, Cake Agents packages the session's persistent volume into a compressed tarball and uploads it to:

```
s3://<bucket>/<prefix><session-id>.tar.gz
```

Message history is stored in the database, not in S3.
