Authentication
Session tokens (JWT) for people, API keys for code, and which one wins when both are sent.
Every request to the mlflow API must say who is calling. There are two ways to do it. People who sign in to the web app use a session token. Code, scripts and services use an API key. Both lead to the same user record, so roles and permissions work the same way for both.
Two ways to authenticate
| Session token | API key | |
|---|---|---|
| For | The web app, and short interactive scripts | CI jobs, services, notebooks, AI assistants |
| Header | Authorization: Bearer <token> | X-API-Key: <key> |
| Lifetime | Access token: 60 minutes by default. Refresh token: 30 days by default | Until it expires or is revoked; you choose |
| Limited by scopes | No | Yes |
| Rate limited per key | No | Yes |
Your server's operator can change the default token lifetimes.
For anything that runs unattended, use an API key. See API keys and scopes.
Session tokens
A session token comes from signing in with your email and password.
curl -s -X POST https://app.mlflow.es/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com", "password": "..."}'The response contains three values you need:
{
"access_token": "eyJ...",
"refresh_token": "...",
"token_type": "bearer",
"expires_in": 3600
}access_tokenis a signed JSON Web Token (JWT). Send it asAuthorization: Bearer <access_token>.expires_inis its lifetime in seconds.refresh_tokenis a random string. Keep it private. Use it to get a new access token before the old one expires.
Refresh and sign out
Send {"refresh_token": "..."}. You receive a new access token and a new refresh token. The old refresh token stops working at once (rotation), so always store the new one.
If an old refresh token is presented again after it was exchanged, mlflow treats it as a possible theft: it revokes every session of that user and every access token already issued. Two browser tabs that refresh at almost the same moment are tolerated and only get a plain 401.
Send {"refresh_token": "..."} to revoke it. The response is 204. The access token cannot be revoked one by one; it expires on its own. Changing or resetting your password revokes all sessions and all access tokens of your account.
Rate limits on sign-in
Sign-in is limited to protect accounts. By default, one IP address may try 10 times per minute, and one email address from one IP address 5 times per minute; repeated failures lead to a longer wait. A limited request gets 429 with a Retry-After header. The answer is the same whether or not the account exists. Your server's operator can change these limits.
API keys
Create a key in the app under Account, on the API keys tab, and send it in the X-API-Key header:
curl -s https://app.mlflow.es/api/v1/auth/me -H "X-API-Key: $MLFLOW_API_KEY"A key acts as the user who created it, with that user's roles, and its scopes (read, write, predict, admin) can only reduce what it may do. Some actions always need a session and refuse API keys: creating API keys, changing your password, exporting or deleting your account, and billing checkout. The whole story is on API keys and scopes.
An older header name, X-PyCaret-Key, is still accepted for existing scripts. Use X-API-Key for new code.
Precedence
If one request carries both a bearer token and an API key, the bearer token is used and the key is ignored. This matches a common situation: a developer has a key in an environment variable and is also signed in to the app. If the bearer token is invalid or expired, the request fails with 401; mlflow does not fall back to the key.
Email verification
On servers that require email verification, a new account must confirm its address before it can use the API.
- Sign-up (
POST /auth/signup) answers202and sends a link by email. No tokens are returned; the user then signs in with the password they chose. The answer is the same for an address that is already registered, so the response does not reveal which addresses have accounts. - Until the address is verified, the account can sign in, call
GET /auth/me, redeem the link (POST /auth/verify-emailwith the token from the email) and ask for a new link (POST /auth/resend-verification). All other endpoints answer403withcode: "email_unverified". - API keys do not bypass this. A key whose owner is unverified gets the same
403on every route, includingGET /auth/me. Verification is done in a browser session.
GET /auth/me returns email_verification_pending, which is true while the account still has to verify. If email verification is off on your server, sign-up returns 201 with tokens and an address that is already taken returns 409. If public sign-up is disabled, it returns 403.
Errors
| Status and message | Meaning | What to do |
|---|---|---|
401 "missing Authorization or X-API-Key header" | No credentials were sent | Add one of the two headers |
401 "invalid credentials" | Wrong email or password at sign-in | Check them |
401 "access token expired" | The access token is older than its lifetime | Refresh it, or sign in again |
401 "invalid access token" or "wrong token type (expected access)" | The token is damaged, or you sent a refresh token as an access token | Send the access token |
401 "access token revoked" | You changed your password, or the sessions were revoked | Sign in again |
401 "invalid refresh token" | The refresh token is unknown, expired, revoked or already used | Sign in again |
401 "invalid API key", "API key revoked", "API key expired" | The key cannot be used | Create a new key |
403 "user inactive" | An administrator deactivated the account | Contact your administrator |
403 email_unverified | The address is not verified yet | Verify the email |
429 | Too many attempts | Wait for Retry-After seconds |
All error bodies are described in Errors and rate limits.
Related
Updated 2026-11-22