Skip to main content
An API key is a credential that lets a pipeline, script, or coding agent act in Earnie without using a person’s account. You need one whenever something other than a person signs in, for example a CI pipeline running the Earnie CLI, or a coding agent connected over MCP. This page explains how to create a key, choose what it can do, use it, and revoke it when it’s no longer needed. Before you start: Creating keys needs the Admin or Operator role. Operators can see and manage only the keys they created. Admins can manage every key in the organisation. Viewers can’t see the API keys page. See Team and roles.

Why API Keys

A pipeline or script shouldn’t sign in as a person. An API key gives it its own identity, so Earnie records its actions against the key, not against whoever set it up. A person always creates a key, and Earnie records that person as the key’s Owner. When you create a key, you decide what it can do (its permissions), which projects it can reach, and when it stops working (its expiry). You can’t change any of these afterwards. To change them, generate a new key and revoke the old one. To replace a key’s secret and keep everything else, rotate it.

Creating a Key

  1. Go to Settings → API Keys and select Generate key.
  2. Enter a Key name. Name it after the pipeline or agent that will hold it, for example ci-main.
  3. Choose its permissions, projects, and expiry, as described below.
  4. Select Generate, then copy the key straight away.

Permissions

Under What this key will hold, choose what the key may do. These are the same permissions that roles are built from. Three presets tick the boxes for common jobs: A preset only ticks boxes for you. The key stores its scopes, not the preset. To add or remove scopes, open Adjust exact permissions, which lists each area with a Read and a Write box. If your deployment doesn’t offer a scope that a preset lists, the preset leaves that scope out. You can only grant a key permissions you hold yourself, so a key never reaches further than the person accountable for it. The list of scopes can include ones your role doesn’t hold, but Earnie refuses to generate a key that asks for more than you have. The panel shows “Failed to generate API key”, and the API returns 403 scope_exceeds_creator.

Scope Reference

These are all the scopes a key can hold: Earnie refuses a request that needs a scope the key doesn’t hold with 403 forbidden, and the message names the missing permission. The API reference lists every operation an API key can call.

What Only a Person Can Do

A key can never hold some permissions. Earnie refuses them with 400 scope_not_grantable:
  • deciding Policy Approvals (policies:approve): approving, rejecting, or revoking one, and confirming or promoting a pending resolution
  • managing members (members:*)
  • SSO (sso:*)
  • changing organisation settings (organization:write)
  • connecting or disconnecting integrations (integrations:write)
  • creating or revoking API keys (apikeys:*)
A few actions also need a signed-in person, whatever the key holds: archiving or restoring a project, connecting or disconnecting its repository, resetting a project’s scan history, and requesting a Policy Approval. A key with projects:write can still create projects and update their details, and a key with projects:import can import repositories through a connection a person already made. Reading isn’t restricted in the same way. You can grant a key read access to integrations or the audit log.

Letting an Agent Triage

When a key holds all five Coding agent (MCP) scopes, you can also turn on Allow agents to triage findings. It’s off by default, and it adds the findings:write permission. The Coding Agent (MCP) preset, with triage left off
Think before turning this on. A key with triage permission can suppress, reopen, assign, and resolve findings, including with reasons that stop a finding counting towards a pull request’s gate. An automation can then turn a failing gate green without a person checking it.A resolution the key records stays pending human review. A person with the Admin role confirms it, or anyone with triage permission reverts it, which reopens the finding and puts it back in the gate. A key can’t accept a violation it agrees is real either: that needs a Policy Approval request, and only a signed-in person can make one.

Projects

Under Projects, choose All projects, which also covers projects created after the key, or Specific to tick a set, which doesn’t. Earnie refuses a key that tries to act on a project outside its set. A key that imports repositories needs All projects, because an import creates new projects. The Coding agent (MCP) preset switches to Specific with no project ticked, so Generate stays off until you tick at least one project or choose All projects. A line under Projects says so.

How a Project-Scoped Key Is Refused

Earnie checks a key limited to specific projects on every request. When it calls the API directly, it can get one of two 403 errors: The event history for a single finding or other item (GET /v1/audit/events) can’t be narrowed to a project, so a project-scoped key can’t read it. Some lists don’t need a filter. Listing projects, the scan posture overview, the pending-review queue, the audit log, and a policy’s attachments return only the key’s own projects. When a request identifies something by its own ID rather than by project, such as a scan, a finding, or an SBOM snapshot, and it belongs to a project outside the key’s set, the key gets 404, as if it didn’t exist.

Expiry

Every key expires. Under Expires in, choose 30 days, 90 days (the default), 365 days, or Custom to pick a date. 365 days is the longest allowed.

Copying the Key

Earnie shows the key only once. In Your new API key, select Copy key, then I have saved this key. You can’t retrieve the key afterwards.
A key starts with sk_earnie_. The API keys page shows only its last four characters. When the key holds the coding-agent scopes, the same dialog shows Connect your coding agent, with a tab for each client: Claude Code, Cursor, VS Code, Codex, and Claude.ai / ChatGPT. Each snippet uses your own Earnie address. Copy the one you need and paste it where that client expects it. The Claude.ai / ChatGPT tab explains why those clients connect differently instead of offering a snippet. Connecting an AI client explains each client’s snippet. When the key covers more than one specific project, you can choose a Default project for this client, which the snippet sends as an X-Earnie-Project header. A key with exactly one project uses it as the default. Like the key, the snippets disappear once you close the dialog. If you need one later, generate a new key. The install snippet for each client, built with your own Earnie address

Using a Key with the Earnie CLI

On your own machine, sign in and enter the key when prompted. Give your Earnie address with --api-url, or set it in EARNIE_API_URL:
In CI, pipe the key in rather than passing it as a command argument, so it doesn’t appear in logs or process lists:
The CLI stores the key in your operating system’s keychain when one is available, or otherwise in a local file that only your user can read. It never writes the key to its own configuration file or to your repository. EARNIE_API_KEY can supply a key for a single run, and the CLI doesn’t store it. If you’ve connected a coding agent, the agent’s user-level configuration holds the key too, and signing in again updates it there. See the Earnie CLI reference for scanning, verdicts, policies, and connecting a coding agent over MCP.

Managing Keys

The API keys page lists your keys. Above the list, summary cards count the keys that are Active, Expiring in 30 days, Never used, and Can write. For each key, the list shows: Use the status filter to show Active keys (the default), keys Expiring within 30 days, Revoked keys, or All, which also shows expired keys. To search, type a name, key prefix, or owner. Select a key to see its full details, including its Owner and its permissions. Earnie keeps revoked keys for the audit log rather than deleting them, and hides them from the default view.

Revoking a Key

To revoke a key, select Revoke key from its row menu or its details, then select Revoke to confirm. Revoking takes effect immediately, and you can’t undo it. Anything using the key stops working until you give it a new one: its requests get 401 key_revoked, just as an expired key’s get 401 key_expired. A revoked key stays in the audit log, so past actions keep naming it.
Give each consumer its own key. Use one key per pipeline, named for that pipeline, with only the permissions that pipeline needs. Then, when something needs revoking, you revoke exactly one thing, and the audit log tells you which automation did what.

Rotating a Key

Rotating replaces a key with a new one that has the same name, permissions, and projects, so you don’t pick them again. The old key keeps working for a grace period, so a pipeline keeps running while you swap in the new key. Rotate a key on a schedule, or when its secret may have leaked. Rotation is available through the API. A person rotates a key, with the same rights as revoking one: an Admin can rotate any key, and an Operator can rotate the keys they created. A key can’t rotate keys, its own included. Call the API from your signed-in session, sending the session cookie your browser holds for Earnie:
$KEY_ID is the key’s ID, which its details show. Both fields are optional: Earnie returns 201 with the new key in key, its ID in key_id, and when the old key stops working in previous_key_expires_at. As on creation, it shows the new key only once. The grace period never lets the old key outlive its own expiry. The new key belongs to the person who rotated it, who becomes its Owner. The audit log records the rotation with both keys, and the new key’s details name the key it replaced.

What a Pipeline Sees During the Grace Period

  1. Until the grace period ends, both keys work. Requests with the old key go on succeeding.
  2. Replace the key in your pipeline’s secret store before the period ends.
  3. After the grace period, the old key gets 401 key_expired. With a grace period of 0 it gets 401 key_revoked straight away.
Choose a grace period long enough to update every place that holds the key.

When Earnie Refuses a Rotation

When a Key Changes Hands

  • Removing a member revokes every key they created. To keep their automation running, generate new keys under a current member before you remove the member.
  • Lowering a member’s role doesn’t change their keys. A key keeps the scopes it was created with. Review the keys the member created, and replace any that carry more than their new role allows.
Older keys can show two other states:
  • No active owner: Earnie never recorded who created the key.
  • None under Access: the key was made before permissions existed and can’t do anything. Generate a replacement.
Some older keys are also limited to particular scanners. That limit is deprecated. Such a key gets 403 module_scope_forbidden for data from any other scanner. Generate a replacement to remove the limit.

What’s Next

To call the Earnie API with a key, see Using the API.