> For the complete documentation index, see [llms.txt](https://docs.netmap.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.netmap.dev/api/api-key-permissions.md).

# API-Key Permissions

API keys have no per-key scopes. Every key resolves to its owning `User`, and route dependencies check that user's live role and permissions.

If the owner is disabled, the key returns `401`.

If the owner lacks a required permission, the key returns `403`.

## Permission Evaluation

`get_current_user` checks the `X-API-Key` header first. When the key is valid, NetMap loads the owning user from the database and returns that user to the route dependency chain.

That means existing route guards apply without special API-key code:

* `require_super_admin`
* `require_topology_write`
* `require_security_view`
* `require_tools_passive`
* `require_tools_active`
* `require_inventory_export`
* `require_firewall_export`
* `require_report_export`
* `require_alert_write`
* `require_ipam_write`

Monitoring write checks are enforced in `monitoring.py` using the role permission cache.

## Role Changes Apply Immediately

Because the key resolves the owner on every request, these changes affect existing keys immediately:

* user deactivation;
* role changes;
* custom role permission changes;
* SuperAdmin removal from the owning account.

## Practical Pattern

Create a dedicated automation user for each integration. Give that user only the needed permissions, then create an API key from that account.

Examples:

| Task                 | Permission                                         |
| -------------------- | -------------------------------------------------- |
| Read inventory       | authenticated user                                 |
| Edit inventory       | `topology_write`                                   |
| Export inventory     | `inventory_export`                                 |
| Search syslog        | `security_view`                                    |
| Export firewall logs | `security_view` and `firewall_export` where needed |
| Manage IPAM          | `ipam_write`                                       |
| Configure alerts     | `alert_write`                                      |
| Manage users         | SuperAdmin                                         |

## Related Pages

* [Permissions](/security/permissions.md)
* [API Keys](/api/api-keys.md)
* [Capability Matrix](/api/capability-matrix.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.netmap.dev/api/api-key-permissions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
