Credentials

The three kinds of credential, who uses each, what each reaches, and the rules they all share.

There are three kinds of credential. They are not interchangeable: each is for a different caller and reaches a different thing.

Database keyDocument tokenAPI key
Used byYour backendYour application's usersCI, scripts, infrastructure as code
Sent toThe database's clusterThe database's clusterThe management API
ReachesOne databaseOne documentAn organization's databases, or one of them
Looks likemk_…A signed tokenmc_sk_…
LifetimeUntil revokedShortUntil revoked
Managed inDatabase → KeysIssued by your backendOrganization → Settings → API Keys
Who may manage itAny member—Owners and admins

Database keys

A database key authenticates your backend to one database, with the read, write or admin permission. It reaches every document in that database, so it stays on your servers.

See database keys.

Document tokens and token keys

A document token is what a browser or a mobile app presents: a short-lived credential for one document. Your backend decides who gets one.

Your backend can ask the database for a token each time, or sign tokens itself. To sign them itself, it needs a key pair, and you register the public half with the database as a token key.

See token keys.

API keys

An API key authenticates a script or a pipeline to the management API. It manages databases and their credentials; it never reaches documents, members or other API keys. The dashboard calls these API keys; this documentation also calls them management keys where that is clearer.

See API keys.

Rules that all secrets share

A secret is shown once. When you create a database key or an API key, its secret is displayed a single time. The service does not keep it: it keeps a hash of an API key's secret, and of either kind of secret only the last four characters. A database key's secret exists only in the database's cluster. If you lose a secret, it cannot be shown again: rotate the database key, or replace the API key's secret.

A key is told apart by its last characters. Lists show a key's prefix and the last four characters of its secret, for example mk_…a1B2, so you can match a key in the dashboard to one in your secret store.

Revoking is immediate and final. A revoked key stops working at once and cannot be reinstated. Revoked keys stay listed, marked as revoked.

Keys belong to the organization. They are not tied to the person who created them, and they keep working when that person leaves.

Every change is recorded. Creating, rotating and revoking a credential each write an entry to the audit log. Entries never contain a secret.

Which one do I need?

  • A server that reads and writes documents: a database key with the write permission.
  • A server that also defines collections: a database key with the admin permission.
  • A browser or mobile app: a document token, never a key.
  • A deployment pipeline that creates databases or rotates keys: an API key.