> For the complete documentation index, see [llms.txt](https://doc.dastra.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.dastra.eu/en/features/settings/api-keys.md).

# API key management

Create and manage your organization's API keys: workspace, expiration, permissions, MCP server access.

This page explains what Dastra API keys are used for and how to create and manage them. Only organization owners have access to them.

## Uses of API keys

* **Create a Dastra API client** to retrieve or modify data outside the application. This client can be server-to-server (Client credential) or JavaScript (Authorization code). To find out more, please [read the Dastra API authentication documentation](https://doc.dastra.eu/en/api/authentication.md).
* **Configure a data subject request widget** (public key only). Read the [documentation about DSR forms](https://doc.dastra.eu/en/features/requests/widget.md).
* **Configure a cookie widget** (public key only). Read the [documentation related to cookies](https://doc.dastra.eu/en/features/cookies/banner/configure.md).
* **Connect an AI tool to the Dastra MCP server**. Read the [MCP server documentation](https://doc.dastra.eu/en/dastra-ai/ai-assistant/mcp.md).

## Where to manage API keys

Click the gear icon in the top bar (**Organization settings**), then **Api keys & MCP** in the left menu. The direct address is <https://app.dastra.eu/general-settings/api>.

The page has three tabs:

* **API keys**: the list of keys. For each key it shows the name, the last use (**Never** if the key has not been used) and the workspace. The **Expired** badge marks a key whose expiration date has passed, and the `MCP` badge a key allowed to access the MCP server.
* **MCP Server**: connect an AI tool to the Dastra MCP server. See [The MCP server](https://doc.dastra.eu/en/dastra-ai/ai-assistant/mcp.md).
* **tenantId & workspaceId**: the identifier of the organization (**TENANT ID**) and of each workspace (**WORKSPACE ID**), with a button to copy them. API calls that ask for these identifiers use them.

## Create an API key

1. In the **API keys** tab, click **Create a new Api key**.
2. Enter the **Name** of the key.
3. To restrict the key to one workspace, choose it in **Select a specific workspace**. If you choose none, the key applies to **All workspaces**.
4. Choose the **Expiration**: **Unlimited**, 30 days, 180 days, 365 days or **Custom date**.
5. For **Give this api key full permissions?**, answer **Yes** for a key without restrictions, or **No** to tick only the permissions the key can use.
6. Click **Create**.

<figure><img src="https://2697025545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LvBxs22wUMicv9uWp6C-1972196547%2Fuploads%2Fgit-blob-b10f737eaaf6b856cb0df152fa2c9334b1921e4c%2Fsettings-api-keys-1.png?alt=media" alt="The API key creation window with the name, workspace, expiration and permissions"><figcaption><p>Creating an API key</p></figcaption></figure>

The **API key details** panel opens. It shows:

* the public key (`client_id`) and the private key (`client_secret` or API key), which is masked and can be copied from the panel;
* the **Regenerate private key** button, which generates a new private key without deleting the API key;
* the workspace, the MCP server access, the last use and the expiration of the key;
* the **Permissions** of the key, which you can adjust with the edit button;
* the allowed CORS origins and the allowed redirect URIs, to fill in if you use the API in JavaScript with OAuth2 (Authorization code).

<figure><img src="https://2697025545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LvBxs22wUMicv9uWp6C-1972196547%2Fuploads%2Fgit-blob-32c29ba6594cfcedca3fc5175742cdb9b40ab1b7%2Fsettings-api-keys-2.png?alt=media" alt="The API key details panel with the private key masked"><figcaption><p>The details of an API key</p></figcaption></figure>

{% hint style="info" %}
The expiration and the MCP server access are chosen when the key is created and cannot be changed afterwards. To change either of them, create a new key.
{% endhint %}

## Use a key with the MCP server

If your plan includes the MCP server (Dastra AI Pro), the creation window offers the **Allow this key to access the MCP server (requires a specific workspace)** option. Turn it on and choose a workspace: the MCP server refuses a key without this option or without a workspace. Allowed keys carry an `MCP` badge in the list. See [The MCP server](https://doc.dastra.eu/en/dastra-ai/ai-assistant/mcp.md).

## Replace or delete a key

{% hint style="warning" %}
Keep your API keys safe. The private key must never be made public.

If the security of your API key is compromised, click **Regenerate private key** in the details panel, or delete the key from the list (three-dot menu > **Delete**) and create a new one.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.dastra.eu/en/features/settings/api-keys.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
