API keys and scopes

Create personal API keys for scripts, CI and AI assistants, limit what each key can do, and revoke keys you no longer need.

An API key lets code call the mlflow REST API on your behalf: a CI job that retrains a model, a service that calls a deployment, your own scripts or the MCP server used by an AI assistant. People signing in to the web app use a session instead; see Authentication.

How keys work

  • A key acts as you. It belongs to the user who created it and has that user's workspace and project roles. A key can never do more than you can; scopes can make it do less.
  • It is shown once. mlflow stores only a SHA-256 hash of the key. The plaintext appears a single time, right after you create it.
  • It looks like pck_ followed by 43 random characters. The first 12 characters (for example pck_3fA9x2Lm) are the key's prefix; the app shows the prefix so you can tell keys apart.
  • It can expire. You choose a lifetime from 1 to 3650 days, or no expiry.
  • It can be revoked at any time. A revoked key stops working on the next request. Revoking keeps the key in the list (and in the audit trail) with the status revoked.

Keys are personal: they are not tied to a single workspace, and they reach every workspace you are a member of.

Create a key

Open your API keys

Open the user menu at the bottom of the sidebar and select API keys. This opens Account on the API keys tab.

Fill in the form

Under New API key:

  • Name (required): what the key is for, for example ci-bot or laptop-local. You will see this name in the list.
  • Expires in (days): from 1 to 3650. Leave it blank for a key that never expires.
  • Scopes: leave every box unchecked for a key with default access (read, write and predict), or check predict (call deployed models) for a key that can only call deployments. See Scopes.

Select Create key.

Copy the key now

The card API key created — copy it now shows the full key. Select Copy and store it in a secret manager or your CI's secret store. When you select I've saved it, the key disappears from the page and cannot be shown again.

Treat a key like a password

Anyone with the key can act as you within its scopes. Do not commit it to a repository or paste it in a chat. If a key leaks, revoke it and create a new one.

Use a key

Send the key in the X-API-Key header on every request:

bash
export MLFLOW_API_KEY=pck_...
curl -s https://app.mlflow.es/api/v1/auth/me -H "X-API-Key: $MLFLOW_API_KEY"

On a self-hosted server, replace https://app.mlflow.es with your server's address. The older header X-PyCaret-Key is still accepted for existing integrations; use X-API-Key for anything new.

If a request carries both a session token (Authorization: Bearer ...) and an API key, the session token is used and the key is ignored.

Scopes

A scope limits which requests a key may make. There are four:

ScopeAllowsNotes
readGET, HEAD and OPTIONS requests: list and inspect workspaces, datasets, runs, models, deploymentsAlso a few read-like POST calls, such as waiting for a run (POST /runs/{id}/wait) and validating a pipeline
writeEverything read allows, plus creating, changing and deleting resources, plus predictionswrite includes read and predict
predictCalling deployments only: online predictions, batch prediction jobs and reading their results, and a pipeline's input schemaThe right scope for a service that only consumes a model
adminPlatform administration routes (/api/v1/admin/...)Only a platform superuser can grant it; it does not include read or write

A key created with no scopes gets read, write and predict: everything you can do except platform administration.

Scopes are checked from the request itself: every GET needs read, every other method needs write, and the prediction routes accept predict. New API routes are covered automatically.

Choosing scopes in the app

The Scopes section of the form offers predict and, for platform superusers, admin. To create a key with another combination, for example a read-only key, use the API from a signed-in session (below).

Give each key the narrowest scope

  • A service that calls a deployed model: predict.
  • A dashboard or an AI assistant that only looks at runs and leaderboards: read.
  • A CI job that uploads data, trains and deploys: default access (no scopes), or write.
  • Platform maintenance scripts run by a superuser: admin, plus read or write if they also touch workspaces.

A superuser's key without admin is treated as a regular member, so everyday keys of administrators do not carry platform powers.

Requests a key cannot make

Some actions need an interactive session, even with a full-access key. With a key they return 403 "this endpoint needs an interactive session; API keys are not accepted":

  • creating API keys (POST /api/v1/auth/api-keys), so a leaked key cannot mint new ones;
  • changing your password, deleting your account or exporting your data;
  • opening billing checkout or the billing portal.

Manage keys

The Your keys list on the same tab shows each key's Name, Prefix, Status (active, revoked or expired), Expires and Created date. Select Revoke and confirm to disable a key; this cannot be undone.

From the API, list your keys with GET /api/v1/auth/api-keys (the response includes each key's scopes and last_used_at) and revoke one with DELETE /api/v1/auth/api-keys/{id}. Revoking twice is harmless.

Create a key from the API

Creating a key needs a session token, which you get by signing in. Pass scopes to choose any combination:

bash
TOKEN=$(curl -s -X POST https://app.mlflow.es/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "..."}' | jq -r .access_token)

curl -s -X POST https://app.mlflow.es/api/v1/auth/api-keys \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "dashboard", "scopes": ["read"], "expires_in_days": 90}'

The response contains the key once, in the token field. Unknown scope names are rejected with 422.

Errors

StatusMeaningWhat to do
401 "missing Authorization or X-API-Key header"No credentials were sentAdd the X-API-Key header
401 "invalid API key"The key does not exist, or was mistypedCheck the value; create a new key if it was lost
401 "API key revoked" / "API key expired"The key was revoked or reached its expiry dateCreate a new key
403 "this API key lacks the required scope ('write')"The request needs a scope the key does not haveUse a key with the right scope
403 with code: "email_unverified"The key's owner has not verified their email addressVerify the email, then retry
429 "API key rate limit exceeded"Too many requests in the current windowWait for the Retry-After delay; see Errors and rate limits

Each key is limited to 600 requests per 60 seconds by default (your server's operator can change this). Responses made with a key carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers so your code can slow down before it is limited.

Learn the theory

Lessons on learning.mlflow.es that explain the ideas behind this page.

Updated 2026-11-21