---
title: "API keys"
description: "An API key lets your server use CloudPDF for your workspace. Give it only what it needs, keep it on your server, and revoke it when it leaks."
source: "https://www.cloudpdf.com/docs/platform/app/api-keys"
---

# API keys

An API key lets your server use CloudPDF for your workspace: upload documents, make tokens for your
users, and manage grants. It stays on your server. Browsers never get it: they open documents with
a grant or a token your server makes.

![The API keys page: the Connect your server card, and the Keys card listing a key](https://www.cloudpdf.com/docs/platform/api-keys.png)

Owners and admins make and revoke keys. Everyone in the workspace sees the list.

## Make one

Click **New API key**, name it after where it runs ("Production server", "Fernquill app"), and
choose how long it lives: 30, 60 or 90 days.

![The New API key dialog: named Fernquill app, Restricted, with Documents and folders on Write, Inside documents on Write and Viewer tokens on](https://www.cloudpdf.com/docs/platform/api-key-dialog.png)

Then choose what it can do:

- **Full access**: everything you can do in the dashboard. Right for your own scripts.
- **Restricted**: only what you turn on below. Right for an app in production.

| Row                       | Lets the key                                                                                                                                        | Choices           |
| :------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------- |
| **Documents and folders** | List them (Read), and upload, rename and move them, and make [upload tokens](https://www.cloudpdf.com/docs/platform/app/browser-uploads.md) (Write) | None, Read, Write |
| **Delete**                | Delete documents and folders                                                                                                                        | Off, On           |
| **Inside documents**      | Pages, text, annotations, forms and attached files: read them, download and copy text (Read), or also change, print and sign (Write)                | None, Read, Write |
| **Viewer tokens**         | Make [tokens](https://www.cloudpdf.com/docs/platform/app/tokens.md) for your users, and revoke them                                                 | Off, On           |
| **Grants**                | Make, change and end [grants](https://www.cloudpdf.com/docs/platform/grants.md)                                                                     | Off, On           |

A key's viewer tokens and grants give only what the key itself may do inside documents. So with
either one on, **Inside documents** can't be None. Set it to Write for tokens and grants that let
people comment, fill in forms, sign or print.

When your workspace has an add-on, each of its permissions gets a row too, Off or On. A key keeps
what it was made with, so an add-on added later needs a new key.

## Copy it once

The key is shown once, right after it's made:

![The Keys card with the new key Fernquill app, its value shown once, and a button to copy it](https://www.cloudpdf.com/docs/platform/api-key-created.png)

Store it as a secret on your server, such as `CLOUDPDF_API_KEY`, and give it to the SDK:

```ts
const cloudpdf = new CloudPDFClient({
  token: process.env.CLOUDPDF_API_KEY,
});
```

Every call also names the workspace, as `tenantId`. Copy it from **Tenant ID** on the **Connect
your server** card, at the top of the page. The key works only for that workspace.

## When it leaks, or expires

**Revoke** stops a key within a minute, for good. If a key ends up in a repository, a log or a
browser, revoke it and make a new one.

A key also stops at its expiry date. The date turns orange a week before, so you can make the next
key and switch your server over first. Revoked and expired keys are under **Show revoked and
expired keys**.

## Good to know

- **One key per place.** A key each for production, staging and your scripts means you can revoke
  one without stopping the others.
- **Give a key only what it needs.** A server that only makes tokens for documents you uploaded in
  the dashboard needs **Viewer tokens** on, **Inside documents** at what its tokens give, and
  **Documents and folders** at None.

* [Tokens for your users](https://www.cloudpdf.com/docs/platform/app/tokens.md) — What your server does with a key that has Viewer tokens on.
* [Uploading from your server](https://www.cloudpdf.com/docs/platform/app/uploads.md) — Upload PDFs with a key that has Documents and folders on Write.
