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

# Authentication

* Create a key at [https://app.diagramkit.ai/settings/api](https://app.diagramkit.ai/settings/api) and send it on every request, downloads included: `Authorization: Bearer aid_…`. A key is shown once; store it as a secret and revoke it there if it leaks.
* Call the API from your server or a script. Browsers are not allowed to call it from other sites, and a key in a web page is a leaked key.

| Status | Meaning |
| - | - |
| `401 unauthorized` | No key, a malformed one, or a revoked one. |

## The MCP

![Diagram: one API key, created and revoked at app.diagramkit.ai/settings/api, is used by your server or script to call the API at app.diagramkit.ai/api/v1 and by your agent to connect to the MCP server at mcp.diagramkit.ai/mcp, both as a bearer token. Both reach the same account, with the same diagrams and credit balance. After revoking, the API answers 401 at once and the MCP cuts the agent off within a minute.](https://mintcdn.com/diagramkit/sWlxT_qLaDK7vTGW/images/api-key.png?fit=max\&auto=format\&n=sWlxT_qLaDK7vTGW\&q=85\&s=6ea87e5bc82074fddf7805b5937bb4a4)

One key opens both the API and the MCP, and both reach the same diagrams and credits.

An agent you build can use diagramkit as a tool through its MCP server instead of calling these endpoints. Connect it to `https://mcp.diagramkit.ai/mcp` and send the same API key as the bearer token: `Authorization: Bearer aid_…`. No sign-in window opens; the key decides whose diagrams and credits it uses, and revoking the key cuts the agent off within a minute. (People connecting their own Claude or ChatGPT use the connector's sign-in instead.)

A key that is not valid, or was revoked, is refused with `401` and the message to make a new one; the key is never sent to the model, only to diagramkit.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.