# API key scopes

Every Defined Networking [API key](/docs/glossary/api-key/) is granted a set of **scopes** (also called permission scopes). A scope authorizes an API key to perform one specific action against one resource. Each API endpoint requires a particular scope, so a key can only call an endpoint if it has been granted that endpoint's scope.

Scopes are written as `resource:action`, for example `hosts:read` or `roles:create`. When you [create an API key](https://admin.defined.net/settings/api-keys/add) in the admin panel, you choose which scopes it should have. A key can hold any combination of scopes, and a few endpoints require more than one (see [Multi-scope endpoints](#multi-scope-endpoints) below).

We recommend granting each key the fewest scopes it needs. For example, a monitoring script that only reads audit logs should have `audit-logs:list` and nothing else. If a key is ever leaked, limited scopes limit the damage — and you should still [rotate the key](/docs/guides/rotating-api-keys/) immediately.

Each operation in the [API reference](/docs/api/) lists the exact scope it requires under **Token scope required**. The tables below summarize every scope an API key can have.

## Hosts

Scopes for managing [hosts](/docs/glossary/host/), including lighthouses and relays.

| Scope           | Grants                                                              |
| --------------- | ------------------------------------------------------------------- |
| `hosts:create`  | Create hosts, lighthouses, and relays.                              |
| `hosts:read`    | View the details of an individual host.                             |
| `hosts:list`    | List the hosts in your organization.                                |
| `hosts:update`  | Edit a host                                                         |
| `hosts:delete`  | Delete a host.                                                      |
| `hosts:enroll`  | Create enrollment codes so a host can be enrolled into the network. |
| `hosts:block`   | Block a host, cutting off its access to the network.                |
| `hosts:unblock` | Unblock a previously blocked host.                                  |
| `hosts:debug`   | Send [debug commands](/docs/guides/host-diagnostics/) to a host.    |

## Roles

Scopes for managing [roles](/docs/glossary/role/) and their firewall rules.

| Scope          | Grants                                  |
| -------------- | --------------------------------------- |
| `roles:create` | Create a role.                          |
| `roles:read`   | View the details of an individual role. |
| `roles:list`   | List the roles in your organization.    |
| `roles:update` | Edit a role and its firewall rules.     |
| `roles:delete` | Delete a role.                          |

## Routes

Scopes for managing routes to networks beyond your overlay hosts.

| Scope           | Grants                                   |
| --------------- | ---------------------------------------- |
| `routes:create` | Create a route.                          |
| `routes:read`   | View the details of an individual route. |
| `routes:list`   | List the routes in your organization.    |
| `routes:update` | Edit a route.                            |
| `routes:delete` | Delete a route.                          |

## Networks

Scopes for managing networks.

| Scope             | Grants                                        |
| ----------------- | --------------------------------------------- |
| `networks:create` | Create a network.                             |
| `networks:read`   | View the details of an individual network.    |
| `networks:list`   | List the networks in your organization.       |
| `networks:update` | Edit a network, including adding CIDRs to it. |
| `networks:delete` | Delete a network.                             |

## Tags

Scopes for managing [tags](/docs/guides/configuring-hosts-with-tags/).

| Scope         | Grants                                 |
| ------------- | -------------------------------------- |
| `tags:create` | Create a tag.                          |
| `tags:read`   | View the details of an individual tag. |
| `tags:list`   | List the tags in your organization.    |
| `tags:update` | Edit a tag.                            |
| `tags:delete` | Delete a tag.                          |

## Join keys

Scopes for managing [join keys](/docs/guides/enrolling-hosts-with-join-keys/), the reusable enrollment codes that let many machines enroll as new hosts.

| Scope              | Grants                                                       |
| ------------------ | ------------------------------------------------------------ |
| `join-keys:create` | Create a join key.                                           |
| `join-keys:read`   | View the details of an individual join key.                  |
| `join-keys:list`   | List the join keys in your organization.                     |
| `join-keys:update` | Edit a join key's name and expiration.                       |
| `join-keys:delete` | Revoke a join key, so machines can no longer enroll with it. |

## Endpoint OIDC providers

Scopes for managing the OIDC providers that endpoint users sign in with to enroll their devices. See [Setting up SSO](/docs/guides/setting-up-sso/) for details. These scopes don't cover the SSO provider admins use to log in to the admin panel, which can't be managed with an API key.

| Scope                            | Grants                                                    |
| -------------------------------- | --------------------------------------------------------- |
| `endpoint-oidc-providers:create` | Create an endpoint OIDC provider.                         |
| `endpoint-oidc-providers:read`   | View the details of an individual endpoint OIDC provider. |
| `endpoint-oidc-providers:list`   | List the endpoint OIDC providers in your organization.    |
| `endpoint-oidc-providers:update` | Edit an endpoint OIDC provider.                           |
| `endpoint-oidc-providers:delete` | Delete an endpoint OIDC provider.                         |

## Audit logs

| Scope             | Grants                                                    |
| ----------------- | --------------------------------------------------------- |
| `audit-logs:list` | List [audit log](/docs/guides/using-audit-logs/) entries. |

## Multi-scope endpoints

Some endpoints require a key to hold more than one scope. If your key is missing any of the required scopes, the request is rejected.

- **Create host & enrollment code** — requires both `hosts:create` and `hosts:enroll`.
