> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Create a Mammoth API token for scripts and apps

> When you need a Mammoth API token, how to create one in Workspace Settings, keep its secret safe and fix one that fails, and where to add your own AI key.
>
> Applies to: Roles: Workspace Owners and Workspace Members (tokens); Workspace Owners (external AI keys). Where: Workspace Settings › API Keys

API tokens let scripts, integrations and CI use Mammoth; external AI keys let you choose the AI provider. Both live in **Workspace Settings** > **API Keys**. Workspace Owners and Workspace Members can create tokens; only Workspace Owners add external keys.

## Decide whether you need API access

| You want to | Need a token? |
| --- | --- |
| Run Mammoth from a script, CI job or scheduled job, build custom apps that read or change Mammoth data, or automate workflows from external systems | Yes |
| Use an AI assistant (through the [Mammoth MCP server](https://mammoth.io/docs/agents/mcp/)) or the Mammoth CLI ([Authentication](https://mammoth.io/docs/build/auth/)) | No: they sign in with your Mammoth account. Both work on every plan |
| Feed a BI tool | No: use an export (for example **Tableau Server/Cloud**), or publish the view to a Mammoth-managed database and use **Show credentials** ([Set up an export](https://mammoth.io/docs/learn/share-and-export/send-to-destinations/)) |
| Use only the web app at first | No: skip this step. Workspace Owners and Workspace Members can create tokens later |

![API Keys section with the API tokens card, a Generate key button, and a token row with a masked key](https://mammoth.io/docs/images/20261009_101001_APIKeysTokensCard.webp)

### Create an API token

1. Open the **API Keys** section and click **Generate key** in the **API tokens** card.
2. In the **Create API key** dialog, enter a **Name**, such as "Nightly export script" or "Production Automation".
3. Optionally tick **Project scoped** and select a project to limit the key to it.
4. Click **Create key**.
5. In **API key created**, click **Copy secret**, then **Done**.
6. Store the secret in your password manager or secrets management system.

The secret shows only once: "After this dialog closes, the secret is gone." If you lose it, remove the key and generate a new one. Treat tokens like passwords: never commit them to code, share them over unsecured channels or keep them in plain text, and delete unused ones.

### Add an external AI key (optional)

AI features such as Generative AI use a key Mammoth provides. A Workspace Owner can add your own OpenAI, Anthropic, Google or xAI key to choose the provider and model: see [Add your own AI provider key](https://mammoth.io/docs/learn/workspace/external-ai-keys/).

## Troubleshooting an API token

| Symptom | Cause | Fix |
| --- | --- | --- |
| An API token doesn't work | Copy error, removed key, or wrong project | Check the token has no extra spaces or line breaks and wasn't removed in **API Keys**. If it's **Project scoped**, check the request is for that project. Send it as `Authorization: Bearer mm_...`. See [Authentication](https://mammoth.io/docs/build/auth/) |

## Related

- [Set up your workspace](https://mammoth.io/docs/learn/start/set-up-your-workspace/): the other setup steps.
- [Authentication](https://mammoth.io/docs/build/auth/): how the CLI and API sign in.
- [Mammoth MCP server](https://mammoth.io/docs/agents/mcp/): connect an AI assistant without a token.

---
Source: https://mammoth.io/docs/learn/start/api-tokens.md · Updated: 2026-11-08
