Service Accounts¶
A service account is a principal for a machine, not for a person. A CI pipeline, a script, or an Imbi service uses a service account to call the Imbi API.
Like a user, a service account gets permissions from its role in each organization that it is a member of. A service account without a membership has no permissions. A service account is never a platform administrator.
A service account authenticates with one of two credentials:
| Credential | How it works | Use it for |
|---|---|---|
| API key | A static bearer token. Send it on each request | Simple scripts and services that cannot do an OAuth token request |
| Client credential | A client id and a secret. Exchange them for a short-lived access token with the OAuth 2.0 client_credentials grant |
Services that can refresh a token |
To manage service accounts, open Admin > Global Admin > Service Accounts. The Admin item shows only for platform administrators.
Permissions¶
| Permission | Lets you | Roles that have it |
|---|---|---|
service_account:create |
Create service accounts | admin |
service_account:read |
View service accounts | admin |
service_account:update |
Update service accounts | admin |
service_account:delete |
Delete service accounts | admin |
service_account:update also covers the memberships, the API keys, and
the client credentials of a service account. The service account routes
are not organization routes. They use the union of your roles in all your
organizations. See
Permissions across organizations.
Create a service account¶
- Open Admin > Global Admin > Service Accounts.
- Click New Service Account.
- Enter the fields in the table below.
- Click Create Service Account.
| Field | What to enter |
|---|---|
| Display name | Required. Imbi makes the slug from the name |
| Slug | Required. You cannot change the slug later |
| Description | Optional. What the account does and who owns it |
| Account active | On by default. An inactive account cannot authenticate |
| Organization | Required. The first organization of the account |
| Role | Required. The role of the account in that organization |
A new service account has no credentials. Add an API key or a client credential after you create the account.
Organization memberships¶
A service account can be a member of many organizations, with one role in each.
- Open the service account.
- Under Organization Memberships, click Add to Organization.
- Select the organization and the role.
To change a role, select a different role in the row of the organization. To remove a membership, click the remove button in the row.
API keys¶
- Open the service account.
- Under API Keys, click Create API Key.
- Enter a Key name, for example
production. - Click Create.
- Copy the key from the API Key Created dialog. Imbi shows the key one time only. Imbi stores only a hash of the secret.
The key has the form ik_<key id>_<secret>. Send it as a bearer token:
The dialog creates a key with no scopes and no expiry. The API
(POST /service-accounts/{slug}/api-keys) also accepts these fields:
| Field | Meaning |
|---|---|
scopes |
A list of permission names, for example ["project:read"]. The key gets only the permissions that are both in this list and in the roles of the account. An empty list means all the permissions of the roles. An unknown permission name gives 400 |
expires_in_days |
The days until the key expires. The maximum is IMBI_AUTH_API_KEY_MAX_LIFETIME_DAYS (default 365). Empty means the key does not expire |
Each row in the key list has two actions:
- Rotate API key makes a new secret for the same key id. The old secret stops working. Imbi shows the new key one time only.
- Revoke API key stops the key. Imbi keeps the revoked key in the list for audit.
A rotated or revoked key stops at once.
Client credentials¶
- Open the service account.
- Under Client Credentials, click Create Credential.
- Enter the fields in the table below.
- Click Create.
- Copy the client id and the client secret. Imbi shows the secret one time only.
| Field | What to enter |
|---|---|
| Name | Required. For example production-api |
| Description | Optional |
| Scopes | Optional. Permission names, separated by commas, for example project:read, project:write. An unknown permission name gives 400 |
| Expires in (days) | Optional. Empty means the credential does not expire. The maximum is IMBI_AUTH_API_KEY_MAX_LIFETIME_DAYS |
The client id has the form cc_<random>. To get an access token, send a
form-encoded request to POST /auth/token under the API prefix:
curl --fail -X POST https://imbi.example.com/api/auth/token \
-d grant_type=client_credentials \
-d client_id=cc_... \
-d client_secret=...
The response has an access token and a refresh token. The lifetimes are
the same as for users. See Tokens. Send the
access token as Authorization: Bearer <token>. To get a new pair, send
the refresh token with grant_type=refresh_token.
You can send scope (permission names, separated by spaces) in the token
request. If the credential has scopes, the token gets the scopes that are
in both lists. Imbi writes the granted scopes into the token, and a token
refreshed from it keeps them. The token gets only the permissions that are
both in its scopes and in the roles of the account. A token with no scopes
gets all the permissions of the roles, as an API key with no scopes does.
Rotate credential and Revoke credential work like the actions for API keys.
Delete or disable a service account¶
To stop an account without deleting it, open it, turn off Account active, and save. Imbi then refuses its API keys, its client credentials, and its tokens.
To delete an account:
- Open the service account.
- Under Danger zone, click Delete account.
- Confirm.
Imbi deletes the account, its API keys, and its client credentials. If
the account is the credential of a runner pool, Imbi refuses the delete
with 409 service_account_in_use. Change the pool first. See
Agent Runners.
Agent service accounts¶
Imbi makes a service account for each agent when you create the agent. The agent acts as this account when it calls the Imbi API. See Agents.
| Property | Value |
|---|---|
| Slug | agent-<agent id> |
| Display name | The name of the agent |
| Membership | The organization of the agent, with no role |
A membership with no role gives no permissions. To let an agent use the
Imbi API tools, give its service account a role in the organization of
the agent (see Organization memberships).
The Organization Memberships card shows such a membership as
No role, and the API returns its role as null.
Keep the agent's service account in one organization only. If it is a
member of more than one organization, Imbi gives the agent no API token
(service_account_in_other_organizations). See
Agent Runners.
When you delete the agent, Imbi deletes its service account and the credentials of that account.
Imbi service accounts¶
Five Imbi services call imbi-api as their own service account:
| Service account | Role | Credential | Environment variables |
|---|---|---|---|
imbi-scheduler |
imbi-scheduler |
Client credential | IMBI_SCHEDULER_SA_CLIENT_ID, IMBI_SCHEDULER_SA_CLIENT_SECRET |
imbi-gateway |
imbi-gateway |
API key | IMBI_GATEWAY_API_TOKEN |
imbi-workflows |
imbi-workflows |
Client credential | IMBI_WORKFLOWS_SA_CLIENT_ID, IMBI_WORKFLOWS_SA_CLIENT_SECRET |
imbi-assistant |
imbi-assistant |
API key | IMBI_ASSISTANT_API_TOKEN |
imbi-slackbot |
imbi-slackbot |
API key | IMBI_SLACKBOT_API_TOKEN |
The assistant and the Slack bot use their accounts only to get the token of their AI provider (workload identity). For tool calls, they send the token of the caller to imbi-api. imbi-mcp has no service account.
imbi-api setup creates the accounts in the organization that it
creates. For an install that already exists, or for another organization,
run this command:
Run imbi-api setup-permissions first, because the command gives each
account the seeded role of the same name. When only one organization
exists, you can omit --organization.
For each credential, the command does one of these:
| Case | What the command does |
|---|---|
| The environment variables of the account are set | Writes the credential to match them. For a client credential, set both variables. One variable without the other is an error |
| The variables are not set and the account has a credential | Keeps the credential |
| The variables are not set and the account has no credential | Makes a credential and prints the variable assignments one time. Put them in the environment of the service |
The command does not change the role of an account that already has a membership in the organization. It does not change Account active.
For the extra setup of imbi-workflows, see
Workflows.