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

# Tenant API keys

> Create tenant API keys, give each one a role, and see exactly which API operations it can call

With **[Tenant API keys](https://app.plerion.com/settings/api-keys)**, you can call the [Plerion API](/api-reference/index) from scripts, pipelines, and other tools without a user signing in. Every key holds a role, so a key can do only what its role allows, on the integrations the role covers.

<Warning>
  Treat an API key like a password. Plerion shows the key once, when it is created. Do not store it as plain text or commit it to a code repository.
</Warning>

***

## Roles for API keys

Each user can hold two keys per tenant. A key is created with one role and keeps it until you change it. The roles a key can hold are the tenant-level roles of its tenant:

* **Tenant admin** *(default)*: every operation of the API, on every integration in the tenant. Keys created before roles existed hold this role.
* **Tenant read-only**: reads within the tenant.
* **Custom roles**: any role an organization admin has created for this tenant. A custom role can hold a subset of permissions and can limit them to specific integrations or integration groups.

<Note>
  Organization-level roles do not apply, because a key lives in one tenant.
</Note>

<Warning>
  A role that grants `ApiKey:Modify` can create keys, including keys with Tenant admin access, and change what existing keys are allowed to do, so it is a path to full access on the tenant. The role editor says so whenever a role being saved includes it.
</Warning>

A request the assigned role does not allow is refused with `403 Forbidden`. A role change applies from the next request made with the key.

***

## Steps to create a key

<Steps>
  <Step title="Go to Settings > API keys and click Create">
    <Frame>
      <img src="https://mintcdn.com/pleriondocs/74zIjBsfPXS4kgXC/images/administration/api-keys-list.jpg?fit=max&auto=format&n=74zIjBsfPXS4kgXC&q=85&s=5aa2a6b9bc235b3dae6f7bfae2de3e78" alt="The tenant API keys list with the Create button" width="1940" height="485" data-path="images/administration/api-keys-list.jpg" />
    </Frame>
  </Step>

  <Step title="Name the key">
    Enter an **API key name** of 2 to 64 characters that says what the key is for.
  </Step>

  <Step title="Choose the role">
    Use the **Role** dropdown. **Tenant admin** is selected by default.

    Under the form, the **Permissions** panel shows the role's actions and the integrations they apply to, and the **Operations** panel lists every API operation the key can call. Tick **Show N operations this key cannot call** to list the refused ones too. Click a refused operation to see the permission it needs. You can click `Download OpenAPI spec` here too, which saves the API reference limited to the selected role.

    <Frame>
      <img src="https://mintcdn.com/pleriondocs/74zIjBsfPXS4kgXC/images/administration/api-key-create-role.jpg?fit=max&auto=format&n=74zIjBsfPXS4kgXC&q=85&s=3ef998fc190798faf5d65ed994109ab6" alt="The create page with a role selected and the access panel below it" width="1940" height="1074" data-path="images/administration/api-key-create-role.jpg" />
    </Frame>
  </Step>

  <Step title="Click Create and copy the key">
    The key is shown once. Copy it and store it in your secrets manager.

    Below the key, the same **Permissions** and **Operations** panels describe the key you just created. `Download OpenAPI spec` saves the API reference limited to this key as a JSON file.

    <Frame>
      <img src="https://mintcdn.com/pleriondocs/74zIjBsfPXS4kgXC/images/administration/api-key-created.jpg?fit=max&auto=format&n=74zIjBsfPXS4kgXC&q=85&s=afaa89804ca0b93370764327d9b1e9a5" alt="The newly created key, hidden, with the role it holds and the example usage" width="1940" height="1075" data-path="images/administration/api-key-created.jpg" />
    </Frame>
  </Step>
</Steps>

***

## Managing existing keys

The API keys list shows each key's **Name**, **Status**, **Role**, **Created By**, and **Created on**. If a key's role has been deleted, the **Role** column shows a warning, and the key's requests are refused until you give it another role.

Click a key's row to open it. The key page shows its details, its **Role**, and the **Permissions** and **Operations** panels for the selected role. To change the role, pick another one from the dropdown. The panels update to what that role allows, and `Save changes` applies it. The key holds its current role until you save.

<Frame>
  <img src="https://mintcdn.com/pleriondocs/74zIjBsfPXS4kgXC/images/administration/api-key-detail.jpg?fit=max&auto=format&n=74zIjBsfPXS4kgXC&q=85&s=509ac2d3d99666917833c92f80e63324" alt="A key's page with its details, the Role dropdown, Save changes, and the access panel" width="1940" height="1073" data-path="images/administration/api-key-detail.jpg" />
</Frame>

Each row has three buttons:

* **Edit**: opens the key page.
* **Disable** or **Enable**: a disabled key is refused until it is enabled again.
* **Delete**: removes the key permanently.

<Frame>
  <img src="https://mintcdn.com/pleriondocs/74zIjBsfPXS4kgXC/images/administration/api-key-row-actions.jpg?fit=max&auto=format&n=74zIjBsfPXS4kgXC&q=85&s=d3a4a9f82e2700acd554ec3f8e21082a" alt="A key's row with the Edit, Disable and Delete buttons at its end" width="1550" height="235" data-path="images/administration/api-key-row-actions.jpg" />
</Frame>

***

## Asking the API what a key can do

`GET /v1/tenant/openapi` returns the [API reference](/api-reference/index) as an OpenAPI 3.1 document limited to the calling key. Operations the role cannot call are left out. Each operation names the permission that authorizes it under `x-plerion-actions` and the integrations in scope under `x-plerion-integration-scope`. Send `Accept: application/yaml` to receive YAML instead of JSON.

```bash theme={"system"}
curl --request GET \
     --url "https://$PLERION_API_URL/v1/tenant/openapi" \
     --header "Authorization: Bearer $PLERION_API_KEY"
```

Use it to check a key before a pipeline runs, or to point an OpenAPI client at exactly the operations the key may call. See [Discover what an API key can call](/api-reference/tenant/discover) for the full response.
