Authentication
Create an mv_live_ API key with your session token, send it as a bearer token, and revoke it when it is no longer needed.
Last updated 2026-08-06
Summary#
The public API is authenticated with a bearer key that begins with mv_live_. You create a key by calling POST /api/keys/create with your Metric Vault session token, and you then use that key on POST /api/v1/analyze in an Authorization: Bearer header. The full key is returned exactly once at creation. Each account can hold five active keys, and every key operation requires the Enterprise plan.
Note that there are two different credentials in play. The three key-management endpoints authenticate with your session token, because they are account operations. The analysis endpoint authenticates with the API key, because it is a machine operation.
Purpose#
An API key exists so a script can act for your account without a browser. It is deliberately dull: no scopes, no expiry, no per-key budgets, one capability. The management endpoints require a live human session precisely because minting a credential that can spend an account's credits should not itself be doable with a credential that spends credits.
Requirements#
- The Enterprise plan on the account that will own the key. The plan is checked at creation and again on every call the key makes.
- A signed-in Metric Vault session, so you can obtain a session token for the management calls.
- Fewer than five active keys on the account. Revoked keys do not count.
- Somewhere secure to store the returned key. It is shown once.
Permissions#
Keys belong to the account that created them. The account owner is the only person who can create, list or revoke that account's keys. Team members do not inherit access to a workspace owner's keys, they are not visible to members, and there is no administrator action that issues a key on a customer's behalf.
There are no scopes. Anyone holding the key can call the analysis endpoint and spend the owning account's credits. It cannot read your Library, change settings, manage a team, or touch billing.
Navigation Path#
There is no key-management screen in the dashboard. Authentication is set up entirely through three endpoints:
POST /api/keys/create → POST /api/keys/list → POST /api/keys/revoke
Enterprise customers who would rather not script this can ask support@metricvaultai.com to provision a key.
Step-by-Step Guide#
1. Get a session token#
The management endpoints take your Metric Vault session access token in the JSON body, as the field token. It is the same token your browser holds after you sign in.
To read it from a signed-in browser, open the developer console on https://metricvaultai.com/dashboard and run:
// The session is stored under the only key matching sb-<project>-auth-token
const k = Object.keys(localStorage).find(k => /^sb-.*-auth-token$/.test(k));
JSON.parse(localStorage.getItem(k)).access_token;Warning: A session token is a short-lived credential for your whole account. Use it for the three management calls and do not store it in a script, a repository or a shared document. If the token has expired, refresh the dashboard and read it again.
2. Create a key#
curl -X POST https://metricvaultai.com/api/keys/create \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.PASTE_YOUR_SESSION_TOKEN",
"name": "nightly-refresh"
}'A successful response:
{
"ok": true,
"key": "mv_live_3f9a1c7d4b28e05a6f13c9d720b48e1a5c6d7f0293a4b1c8",
"name": "nightly-refresh"
}| Field | Notes |
|---|---|
token | Required. Your session access token. |
name | Optional label. Trimmed to 60 characters. Defaults to API key. |
The response carries Cache-Control: no-store. Copy the key value now. This is the only time the full key is returned. The action is recorded on your account activity feed as Created an API key.
Key format: the literal prefix mv_live_ followed by 48 hexadecimal characters, 56 characters in total, generated from 24 cryptographically random bytes.
3. Use the key#
Send it as a bearer token on the analysis endpoint:
curl -X POST https://metricvaultai.com/api/v1/analyze \
-H "Authorization: Bearer mv_live_3f9a1c7d4b28e05a6f13c9d720b48e1a5c6d7f0293a4b1c8" \
-H "Content-Type: application/json" \
-d '{"url": "example.com"}'The header is parsed as the literal string Bearer followed by the key. Any other scheme, or a missing header, is rejected before the key is looked up. Full request and response detail is in POST /api/v1/analyze.
4. List your keys#
curl -X POST https://metricvaultai.com/api/keys/list \
-H "Content-Type: application/json" \
-d '{"token": "PASTE_YOUR_SESSION_TOKEN"}'{
"ok": true,
"keys": [
{
"id": 7,
"name": "nightly-refresh",
"masked": "mv_live_3f9a…b1c8",
"created_at": 1754438400000,
"last_used_at": 1754524800000,
"revoked": false
}
]
}| Field | Meaning |
|---|---|
id | The identifier you pass to revoke |
name | The label you gave it |
masked | First 12 characters, an ellipsis, last 4 |
created_at | Creation time in milliseconds since the epoch |
last_used_at | Most recent successful call in milliseconds, or null if never used |
revoked | Whether the key has been revoked |
Keys are returned newest first. The full key is never returned here. If you lose a key, revoke it and create a new one.
5. Revoke a key#
curl -X POST https://metricvaultai.com/api/keys/revoke \
-H "Content-Type: application/json" \
-d '{"token": "PASTE_YOUR_SESSION_TOKEN", "id": 7}'{ "ok": true }The key stops working immediately. Any later request using it receives Invalid or revoked API key with HTTP 401. Revocation is a soft delete: the key remains in the list marked revoked: true, so you keep the record, but it no longer counts against the five-key cap.
Warning: Revoking cannot be undone. A revoked key can never be reactivated. Create a replacement instead.
The action is recorded on your account activity feed as Revoked an API key.
6. Rotate on a schedule you choose#
Keys do not expire on their own. A safe rotation is: create the replacement, deploy it, watch the new key's last_used_at advance and the old key's go stale, then revoke the old key.
Errors#
| HTTP | Body | Cause | Fix |
|---|---|---|---|
| 401 | {"error":"Unauthorized"} | The session token was missing, expired, invalid, or belongs to an address whose email is not confirmed | Sign in again and take a fresh token |
| 403 | upgrade_required with required_plan: "enterprise" | The account is not on Enterprise | Upgrade, or ask the account owner |
| 400 | {"error":"Key limit reached (5 active keys). Revoke one first."} | Five keys are already active | Revoke one you no longer use |
| 400 | {"error":"id required"} | Revoke was called without an id | Take the id from the list response |
| 401 | {"error":"Missing API key. Send header: Authorization: Bearer mv_live_..."} | No Authorization header on the analysis call | Send the header |
| 401 | {"error":"Invalid or revoked API key"} | The key does not exist, was truncated, or was revoked | Check the value end to end, or create a new key |
| 503 | plan_check_failed | The plan lookup could not complete | Transient. Retry |
Every code the platform can return is listed in Error codes.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
Unauthorized from a management endpoint | Session token expired or copied incompletely | Reload the dashboard, read the token again, retry |
| Key creation returns an Enterprise plan message | The account is not on Enterprise | See Enterprise and custom agreements |
| Calls worked yesterday and now return a plan message | The account left Enterprise. Plans are re-checked per call | Restore the plan; the same keys resume working |
Invalid or revoked API key on a key you just created | The key was truncated in transit, or a shell mangled it | Compare length: mv_live_ plus 48 hex characters, 56 total |
| The sixth key creation fails | Five active keys already exist | Revoke an unused key |
Missing API key… even though a header was sent | The scheme was not exactly Bearer | Send Authorization: Bearer mv_live_... |
| A quota message instead of an analysis | The account has spent its monthly credits | See Rate limits and quotas and Quotas and rate limits |
FAQs#
Can I see a key again after creating it? No. POST /api/keys/list returns a masked form only. If the full value is lost, revoke that key and create a new one.
Do keys expire? No. They live until revoked, or until the account leaves the Enterprise plan, at which point calls fail while the key itself remains listed.
Can I restrict a key to one IP address, one domain or one endpoint? No. There are no scopes or restrictions of any kind. Protect the key the way you would protect a production database password.
Is the session token interchangeable with an API key? No. The three management endpoints accept only a session token, and the analysis endpoint accepts only an mv_live_ key. A session token sent to /api/v1/analyze is rejected as an invalid key.
Can a team member use the workspace owner's key? Only if the owner hands it to them. Keys are not shared through team membership.
Is there a test key or sandbox? No. There is one key type and calls run against live data and spend real credits.
What is logged when a key is used? The key's last_used_at timestamp is updated, and the credit spend appears in the account's monthly usage under the tool name domain_overview. Creation and revocation appear in the account activity feed.
See also
Was this article helpful?
Thanks — feedback noted for the docs team.