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

# S3 API and access keys

> Connect the AWS CLI, AWS SDKs, rclone or any S3 client to Pxxl Storage with scoped access keys.

Pxxl Storage speaks the S3 API. Any tool that lets you set a custom endpoint works: create an access key, point the tool at the endpoint, and use it as you would with AWS S3.

## Connection settings

| Setting | Value |
| - | - |
| **Endpoint** | `https://storage.pxxl.app/s3` (Lagos) or `https://eu.storage.pxxl.app/s3` (Europe) |
| **Region** | `auto` |
| **Addressing** | Path-style (`/s3/<bucket>/<key>`). Turn on "force path style" in your client. |
| **Signing** | AWS Signature Version 4 |
| **Bucket** | The bucket's ID (on its **Overview**) or its name |

Use the endpoint of the bucket's region for the best speed. Every endpoint accepts every bucket.

> [!WARNING]
>
> Never send your Pxxl API key to the S3 endpoint. S3 clients use storage access keys, described below.

## Access keys

There are two kinds of key:

| | Bucket key | Account key |
| - | - | - |
| **Reaches** | One bucket | Every bucket in your account |
| **Create in** | Bucket page > **Access Keys** | **Settings > API keys > Account access keys** |
| **Can create and delete buckets** | No | Yes, with `read_write` and no folder limit |
| **Use it for** | An app that uses one bucket | Tools that manage many buckets, such as backup scripts or rclone |

Each key has a permission and an optional folder:

| Permission | Can |
| - | - |
| **Read** (`read`) | List and download. |
| **Append** (`append`) | List, download and upload new objects. It can never overwrite or delete, which suits logs, journals and audit trails. |
| **Read and write** (`read_write`) | Everything, including changing bucket settings. The default. |

**Limit to folder** scopes a key to one prefix, such as `tenants/acme/`. Requests outside it are refused with `403`. Changing bucket settings (versioning, CORS, lifecycle, policy) needs a `read_write` key with no folder limit.

The access key ID starts with `pxxlak_` and the secret with `pxxlsk_`. **The secret is shown once.** Store it straight away, for example in your project's environment variables or the [Vault](https://docs.pxxl.app/vault/overview.md). Afterwards, only its first and last characters are listed.

From the CLI:

```bash theme={null}
pxxl storage key-create <bucket-id> --name api            # read and write
pxxl storage key-create <bucket-id> --name cdn --read-only
pxxl storage keys <bucket-id>
pxxl storage key-delete <bucket-id> <key-id>
```

Deleting a key stops it working at once.

## AWS CLI

```bash theme={null}
aws configure --profile pxxl
# AWS Access Key ID: pxxlak_...
# AWS Secret Access Key: pxxlsk_...
# Default region name: auto

export AWS_PROFILE=pxxl
export S3=https://storage.pxxl.app/s3

aws s3 ls s3://my-bucket --endpoint-url $S3
aws s3 cp ./report.pdf s3://my-bucket/reports/report.pdf --endpoint-url $S3
aws s3 sync ./public s3://my-bucket/site --endpoint-url $S3
aws s3 presign s3://my-bucket/reports/report.pdf --expires-in 3600 --endpoint-url $S3
```

## SDKs

> [tab] Node.js
>
> ```js theme={null}
> import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
> import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
>
> const s3 = new S3Client({
>   endpoint: "https://storage.pxxl.app/s3",
>   region: "auto",
>   forcePathStyle: true,
>   credentials: {
>     accessKeyId: process.env.PXXL_S3_ACCESS_KEY_ID,
>     secretAccessKey: process.env.PXXL_S3_SECRET_ACCESS_KEY,
>   },
> });
>
> await s3.send(new PutObjectCommand({ Bucket: "my-bucket", Key: "a.txt", Body: "hello" }));
>
> const url = await getSignedUrl(s3, new GetObjectCommand({ Bucket: "my-bucket", Key: "a.txt" }), {
>   expiresIn: 900,
> });
> ```
>
> The Pxxl SDK wraps this for you:
>
> ```js theme={null}
> import { Pxxl } from "@pxxlapp/pxxl";
>
> const pxxl = new Pxxl({ apiKey: process.env.PXXL_API_KEY });
> const bucket = pxxl.storage.s3({
>   endpoint: "https://storage.pxxl.app/s3",
>   bucket: process.env.PXXL_S3_BUCKET,
>   accessKeyId: process.env.PXXL_S3_ACCESS_KEY_ID,
>   secretAccessKey: process.env.PXXL_S3_SECRET_ACCESS_KEY,
> });
>
> await bucket.put("avatars/u_1.png", bytes, { ContentType: "image/png" });
> const link = await bucket.signedGetUrl("avatars/u_1.png", 600);
> ```
>
> See [SDK: CDN and storage](https://docs.pxxl.app/integrations/sdk/cdn-storage.md).

> [tab] Python
>
> ```python theme={null}
> import os
> import boto3
> from botocore.config import Config
>
> s3 = boto3.client(
>     "s3",
>     endpoint_url="https://storage.pxxl.app/s3",
>     region_name="auto",
>     aws_access_key_id=os.environ["PXXL_S3_ACCESS_KEY_ID"],
>     aws_secret_access_key=os.environ["PXXL_S3_SECRET_ACCESS_KEY"],
>     config=Config(s3={"addressing_style": "path"}, signature_version="s3v4"),
> )
>
> s3.upload_file("report.pdf", "my-bucket", "reports/report.pdf")
> url = s3.generate_presigned_url(
>     "get_object", Params={"Bucket": "my-bucket", "Key": "reports/report.pdf"}, ExpiresIn=900
> )
> ```

> [tab] Go
>
> ```go theme={null}
> cfg, _ := config.LoadDefaultConfig(ctx,
>     config.WithRegion("auto"),
>     config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
>         os.Getenv("PXXL_S3_ACCESS_KEY_ID"), os.Getenv("PXXL_S3_SECRET_ACCESS_KEY"), "")),
> )
> client := s3.NewFromConfig(cfg, func(o *s3.Options) {
>     o.BaseEndpoint = aws.String("https://storage.pxxl.app/s3")
>     o.UsePathStyle = true
> })
> ```

> [tab] Laravel
>
> In `config/filesystems.php`, use the `s3` driver:
>
> ```php theme={null}
> 'pxxl' => [
>     'driver' => 's3',
>     'key' => env('PXXL_S3_ACCESS_KEY_ID'),
>     'secret' => env('PXXL_S3_SECRET_ACCESS_KEY'),
>     'region' => 'auto',
>     'bucket' => env('PXXL_S3_BUCKET'),
>     'endpoint' => 'https://storage.pxxl.app/s3',
>     'use_path_style_endpoint' => true,
> ],
> ```

> [tab] rclone
>
> ```ini theme={null}
> [pxxl]
> type = s3
> provider = Other
> access_key_id = pxxlak_...
> secret_access_key = pxxlsk_...
> endpoint = https://storage.pxxl.app/s3
> region = auto
> force_path_style = true
> ```
>
> ```bash theme={null}
> rclone sync ./backups pxxl:my-bucket/backups
> ```

## Presigned URLs

A presigned URL lets someone download or upload one object without a key, until it expires. Use them to serve files from a private bucket, or to let browsers upload straight to storage without the file passing through your server.

* They last up to **7 days**.
* `GET` URLs download, `PUT` URLs upload one object.
* Browser form uploads with a signed POST policy also work.
* Your server's clock must be right: signed requests more than 15 minutes old are refused.

For browser uploads, add a [CORS rule](https://docs.pxxl.app/storage/bucket-settings.md#cors) that allows your site's origin and the `PUT` method.

## Large files

| Limit | Value |
| - | - |
| One `PUT` | Up to 5 GB |
| Multipart upload | 1 to 10,000 parts, each at least 5 MB except the last |
| Object metadata | Up to 2 KB |
| Objects per list page | Up to 1,000 |

The AWS CLI and SDKs switch to multipart automatically for big files.

## What's supported

| Area | Supported |
| - | - |
| **Buckets** | List, create and delete (account keys), head, location |
| **Objects** | Get (with ranges and conditions), head, put, copy, delete, delete many, POST uploads, tagging |
| **Listing** | ListObjects v1 and v2, ListObjectVersions, ListMultipartUploads |
| **Multipart** | Create, upload part, upload part copy, complete, abort, list parts |
| **Bucket settings** | Versioning, lifecycle, policy, CORS, tagging, encryption (SSE-S3 only) |
| **ACLs** | `private` only. Make objects public with a public bucket or a [bucket policy](https://docs.pxxl.app/storage/bucket-settings.md#bucket-policies). |

Not supported: storage classes other than `STANDARD` (and so transitions and restores), object lock, retention and legal hold, replication, static website hosting, SSE-KMS and SSE-C, requester pays, transfer acceleration, and MFA delete. Unsupported calls return `NotImplemented`.

## Troubleshooting

| Error | Fix |
| - | - |
| `SignatureDoesNotMatch` | Wrong secret, or the client isn't using path-style addressing. Check the endpoint ends in `/s3`. |
| `RequestTimeTooSkewed` | Your machine's clock is off. Sync it. |
| `AccessDenied` | The key is for another bucket, is read-only or append-only, or the object is outside its folder. A bucket policy `Deny` can also block it. |
| `NoSuchBucket` | Use the bucket ID or exact name. |
| `BucketNotEmpty` | Delete every object, and every version if versioning is on, first. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.