# Upload keys

Create keys for scripts that upload files to the CDN on their own, like screenshot-basic screenshots, each one locked to a folder.

Source: https://fivedash.fivex.gg/docs/en/cdn/upload-keys

An upload key is a courier's badge: it lets a script send files to the CDN with nobody from the staff in the panel, but only into one folder. It's what screenshot scripts (like screenshot-basic), in-game cameras and report attachments use. This page is for whoever sets up the CDN and the scripts that upload files.

[Video: how to do it in under 20 seconds](https://fivedash.fivex.gg/docs/videos/cdn-upload-keys-en.mp4)

## Before you start

* **CDN created:** see [CDN](https://fivedash.fivex.gg/docs/en/cdn/overview).
* **A folder for the key:** first create the folder where the files will land (for example, `screenshots`).
* **Access level** on **Settings** (CDN):

| What to do             | Level needed  |
| ---------------------- | ------------- |
| See the list of keys   | **View**      |
| Create and revoke keys | **Configure** |

## Create a key

### Open the keys

Go to **CDN → Settings** and scroll to **Upload keys** (or click **Upload keys** under "On this page").

### Start a new key

Click **New key**.

### Fill it in

In **Name**, write what the key is for (for example, "Game camera"). In **Uploads to**, pick the folder. Tick **Can also delete** only if the script needs to clean up what it uploaded.

### Create it

Click **Create key**.

### Copy the key now

In the **Key created** window, click **Copy key**. The **screenshot-basic (Lua)** and **HTTP (cURL)** tabs already have the key in the code; use **Copy code**. Click **Done**.

> The full key is shown only once. Afterwards, the list shows only its start and end. If you lose the key, create another one and revoke the old one.

### Key fields

| Field               | What it does                                                            | Default                                                               |
| ------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------- |
| **Name**            | So you know which script uses the key. Up to 40 characters.             | —                                                                     |
| **Uploads to**      | The folder where the key's files land. **All files** is the CDN's root. | The `screenshots` folder, if there is one; otherwise the first folder |
| **Can also delete** | Lets the script delete the files **it** uploaded.                       | Unticked                                                              |

## What a key can do

| Can                                                             | Can't                                                   |
| --------------------------------------------------------------- | ------------------------------------------------------- |
| Upload one file at a time, up to 20 MiB, to its folder          | Pick another folder or another server                   |
| Delete a file it uploaded itself, if it has **Can also delete** | Delete files uploaded by people or by other keys        |
| Upload the formats the CDN accepts                              | See the file list, change settings or create other keys |

Each key only uploads to its own folder: if it leaks, the damage stays there.

> With screenshot-basic the key ships with the client-side script (players can see it). That's why it only uploads to its folder. Use a folder just for screenshots.

## Key format

The key starts with `fdm_` followed by 64 letters and numbers, like `fdm_xxxxxxxx…`. It goes in each upload's `Authorization` header:

```http
Authorization: Bearer fdm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

See the full examples in [Integrations](https://fivedash.fivex.gg/docs/en/cdn/integrations).

## The list of keys

| What shows                  | What it means                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------- |
| Name                        | The key's **Name**.                                                                                |
| **Can delete**              | The key has **Can also delete**.                                                                   |
| `fdm_xxxxxx…xxxxxx` · in …  | The key's start and end and the folder it uploads to ("removed folder" if the folder was deleted). |
| **… uploads**               | How many files the key has uploaded.                                                               |
| **used …** / **never used** | When the key was last used.                                                                        |

## Revoke a key

### Find the key

In **CDN → Settings → Upload keys**, find the key in the list.

### Revoke it

Click the trash icon next to it (**Revoke …**) and confirm with **Revoke**.

Scripts using this key stop uploading right away. Files already uploaded stay on the CDN.

## Replace a key (rotation)

There's no rotate button. To replace a key without stopping the script:

### Create the new key

Click **New key**, with the same folder in **Uploads to**, and copy the key.

### Swap it in the script

Paste the new key into the script and restart it in the server console.

### Revoke the old one

Check that uploads arrive with the new key (its **… uploads** counter goes up) and revoke the old one.

## Limits

| Item                              | Limit  |
| --------------------------------- | ------ |
| Keys per server                   | 50     |
| Size per file uploaded with a key | 20 MiB |
| Files per upload                  | 1      |

Uploads with keys count toward the same plan allowances as uploads from the panel. See [Usage and limits](https://fivedash.fivex.gg/docs/en/cdn/usage-and-limits).

## FAQ

**I deleted the key's folder. What happens?**
The key stops uploading (the API answers `404` with "A pasta da chave não está disponível."). If the folder only went to the trash, restore it. If it was deleted forever, creating a folder with the same name doesn't bring the key back: create a new key for the new folder.

**Can I use the same key in several scripts?**
You can, but one key per script is better: you can revoke one without stopping the others and see each one's uploads.

**Does a file uploaded with a key get the usual link?**
Yes. It lands in the key's folder and gets the normal public link, `https://cdn.fivex.sh/<address>/<folder>/<file>`. In the file list, **Uploaded by** shows "Chave: …".

## Next steps

[Integrations](https://fivedash.fivex.gg/docs/en/cdn/integrations)screenshot-basic and HTTP uploads.
[Upload files](https://fivedash.fivex.gg/docs/en/cdn/upload-files)Create the key's folder.
[CDN API](https://fivedash.fivex.gg/docs/en/developers/cdn-api)Technical details for developers.
[Usage and limits](https://fivedash.fivex.gg/docs/en/cdn/usage-and-limits)The plan's upload allowances.
