# Signed URLs and keys

> Short-lived links to private files, links to upload one file, and the keys servers use.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://files.docs.sypnia.com/access/signed-urls-and-keys/

For agents: Files signed URLs and keys: signedUrl(path, {expiresIn 1 s–7 days default 1 h, download name}) checked against select policies, transform options can be signed; signedUploadUrl(path, {expiresIn}) for one path, once, without session; keys: publishable (policies apply), secret (bypasses policies, servers only, refused from browsers with Origin), S3 access keys scoped to buckets/actions; in Cloud publishable/secret keys shared with Data per project.

## Signed download URLs

```ts
const { url } = await files.bucket('receipts').signedUrl('order-1042.pdf', { expiresIn: 300, download: 'recibo-1042.pdf' });
```

A signed URL works for anyone who has it until it expires (1 second to 7 days; 1 hour by default). Creating one is checked against your `select` policies. Image transform options can be part of the signature, so a signed thumbnail cannot be turned into the full image.

## Signed upload URLs

```ts
const { url, token } = await files.bucket('uploads').signedUploadUrl('forms/42/id.jpg', { expiresIn: 7200 });
// give url+token to a browser or device that has no session; it can upload exactly this path, once
```

## Keys

| Key             | Who uses it                            | What it can do                                           |
| --------------- | -------------------------------------- | -------------------------------------------------------- |
| publishable key | browsers and apps, with a user's token | only what policies allow to `anon` or the user           |
| secret key      | your servers                           | everything: bypasses policies; never put it in a browser |
| S3 access key   | S3 tools                               | the buckets and actions you scope it to                  |

In Sypnia Cloud, a project's publishable and secret keys are the same for Data and Files. A secret key sent from a browser (`Origin` header present) is refused.
