> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scanoss.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Service Accounts

> Give a pipeline an identity that belongs to the organisation, so its API keys keep working when the person who set it up leaves.

A **service account** is an identity for a pipeline or another automation that belongs to the organisation, not to a person. It holds a set of permissions and the API keys that use them. Its keys keep working when the member who created them is removed, so offboarding someone never breaks a pipeline they set up.

Use a service account for any automation that has to outlive the person who configured it, such as a release pipeline or a nightly export. A personal [API key](https://docs.scanoss.com/en/latest/earnie/administration/api-keys.md) is still fine for a script on your own machine.

**Before you start:** Only the Admin role can see and manage service accounts. An API key can never create, change, or read service accounts, whatever it holds. See [Team and roles](https://docs.scanoss.com/en/latest/earnie/administration/team-and-roles.md).

## How a Service Account Differs from a Personal Key

| | Personal API key | Service account key |
| - | - | - |
| Belongs to | The member who created it | The organisation |
| When its creator is removed | Revoked | Keeps working |
| Where its permissions come from | Chosen on the key | The service account, or a subset of them |
| Who manages it | Its creator (Operator) or any Admin | Admins |
| How to stop all of its keys at once | Revoke each key | Disable the service account |

## Creating a Service Account

1. Go to **Settings → Service accounts** and select **Create service account**.
2. Enter a **Name**, for example `release-pipeline`, and optionally a description of what uses it. The name must be unique among the organisation's active service accounts.
3. Choose its permissions with a preset (**CI pipeline**, **Coding agent (MCP)**, or **Read-only reporter**) or under **Adjust exact permissions**. These are the same scopes a key can hold. See the [scope reference](https://docs.scanoss.com/en/latest/earnie/administration/api-keys.md#scope-reference).
4. Choose **All projects** or **Specific** projects.
5. Select **Create**.

> [!NOTE]
>
> **Permissions and projects are fixed at creation.** You can rename a service
> account and change its description later, but not what it may do. To change
> that, create a new service account and disable the old one.

You can only give a service account permissions you hold yourself. Some permissions are never available to it, the same ones no API key can hold: managing members, SSO, API keys, or service accounts, changing organisation settings, connecting integrations, and deciding Policy Approvals. See [What only a person can do](https://docs.scanoss.com/en/latest/earnie/administration/api-keys.md#what-only-a-person-can-do).

## Giving It a Key

1. Open the service account and select **Generate key**.
2. Enter a **Key name** and choose its expiry (at most 365 days).
3. Leave **Same as the account** selected, or choose **Narrow it** to give this key fewer permissions or fewer projects than the service account holds.
4. Select **Generate**, then copy the key. Earnie shows it only once.

The key holds the service account's permissions and projects, or the subset you chose. A key can never hold a permission or a project the service account doesn't. The API refuses one with `400 scope_exceeds_service_account`.

Use the key like any other: send it as `Authorization: Bearer <key>`, or sign the [Earnie CLI](https://docs.scanoss.com/en/latest/earnie/using-earnie/earnie-cli.md) in with it. To replace a key's secret, [rotate it](https://docs.scanoss.com/en/latest/earnie/administration/api-keys.md#rotating-a-key): the new key stays with the service account.

## Managing Service Accounts

The **Service accounts** page lists the organisation's accounts with their permissions, number of active keys, when one of their keys was last used, and who created them. Use the status filter to show **Active** accounts (the default), **Disabled** ones, or **All**.

Select a service account to see its permissions, projects, and every key it holds, including revoked and expired ones. From there you can rename it, generate or revoke keys, and disable it.

On the **API keys** page, a key that belongs to a service account names the account as its holder. Its details also show which member generated it.

## Disabling a Service Account

Select **Disable service account**, then **Disable** to confirm. Earnie revokes every live key of the account in the same step, so anything using them stops working at once with `401 key_revoked`.

Disabling can't be undone. A disabled service account stays on the page as a read-only record, so the audit log keeps naming it, and its name becomes free for a new account.

## What the Audit Log Records

* Creating, renaming, and disabling a service account, with the member who did it and, for disabling, the keys it revoked.
* Generating a key for it, as for any key, naming the service account.
* Every action a service account key takes, shown as the service account and the key, for example `release-pipeline · deploy`.

## Using the API

Admins can manage service accounts from a signed-in session through the API. An API key gets `403` on these endpoints.

| Operation | Endpoint |
| - | - |
| List service accounts (`?include_disabled=true` adds disabled ones) | `GET /v1/service-accounts` |
| Create one | `POST /v1/service-accounts` with `name`, `scopes`, and optionally `description` and `project_ids` |
| Read one with its keys | `GET /v1/service-accounts/{id}` |
| Rename it or change its description | `PATCH /v1/service-accounts/{id}` |
| Generate a key | `POST /v1/service-accounts/{id}/keys` with `name`, and optionally `scopes`, `project_ids`, and `expires_at` |
| Disable it and revoke its keys | `POST /v1/service-accounts/{id}:disable` |

| Status | Error code | When it happens |
| - | - | - |
| `400` | `scope_exceeds_service_account` | A key asks for a permission or project the service account doesn't hold |
| `403` | `scope_exceeds_creator` | You asked for a permission you don't hold |
| `409` | `service_account_name_taken` | An active service account already has this name |
| `409` | `service_account_disabled` | The service account is disabled, so it can't be changed or given keys |

## What's Next

To call the Earnie API with a key, see [Using the API](https://docs.scanoss.com/en/latest/earnie/api/using-the-api.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.