API keys

Creating a key for the management API, choosing its scope and role, what it can and cannot do, and replacing or revoking it.

An API key authenticates a script, a CI job or an infrastructure-as-code tool to the management API. Its secret starts with mc_sk_ and is sent as a bearer token:

Authorization: Bearer mc_sk_…

API keys are managed under the organization's Settings → API Keys. Only owners and admins can see, create, replace and revoke them.

Creating a key

Choose Create API key and set:

  • Name: 1 to 64 characters, for example github-actions.
  • Scope: Whole organization, or one database.
  • Role: Admin or Member.

The secret is shown once, in a dialog. Copy it into your CI's secrets before closing it. The service stores only a hash of it and cannot show it again.

API keys can be created only in the dashboard, by a person. The management API has no endpoint for them: a key cannot create or manage keys.

Scope

ScopeReaches
Whole organizationEvery database of the organization, and creating new ones
One databaseThat database only

A key scoped to one database:

  • sees only that database. GET /v1/databases returns just it, and any other database reads as not found;
  • cannot create a database, and so cannot restore a backup, which creates one;
  • cannot read the organization's usage, because that covers the other databases too. It can read its own database's activity.

Prefer a key scoped to one database for anything that works on a single database, such as a job that rotates its keys.

Role

Both roles manage databases and their credentials. The one difference is creating databases.

ActionAdminMember
List and read databases, operations and backupsYesYes
Rename, suspend, resume, delete, restore and retry a databaseYesYes
Create, rotate and revoke database keysYesYes
Register and revoke token keysYesYes
Read usage and activityYesYes
Create a databaseYesNo
Restore a backup into a new databaseYesNo

A key's role is not the same as a person's role of the same name: see below.

What no API key can do

Whatever its role and scope, an API key cannot:

  • manage members or invitations;
  • create, replace, list or revoke API keys;
  • read the audit log;
  • read or write documents.

These need a signed-in person with the right role.

The key list

ColumnMeaning
NameThe name you gave it
ScopeWhole organization, or the database's name
RoleAdmin or Member
Secretmc_sk_… and the secret's last four characters
Last usedWhen a request last authenticated with it, or Never
CreatedWhen it was created
StatusActive or Revoked

Last used is a quick way to find keys that nothing uses any more.

Replacing a lost secret

A secret cannot be shown again. If one was lost, choose Replace secret: the key gets a new secret, shown once, and keeps its ID, name, role and scope.

The old secret stops working at once. There is no overlap, so deploy the new secret straight away.

Rotating an API key

To rotate without a gap, use two keys:

Create a second key

Give it the same scope and role as the one it replaces.

Deploy its secret

Switch your pipelines to the new secret. Both keys work in the meantime.

Revoke the old key

Once Last used on the old key stops advancing, revoke it.

The advisor flags an admin key for the whole organization once it is 180 days old.

Revoking a key

Choose Revoke key. Requests with it fail from then on, and it cannot be undone. A request that was already in progress when the key was revoked, or when its secret was replaced, does not complete a change afterwards.

When a database or organization is deleted

A key scoped to one database reaches nothing once that database is gone: every request with it reads as not found. The key list then shows its scope as Deleted database; revoke it. Deleting an organization removes all of its API keys.