Skip to main content
A service account is a machine user. Use service accounts for any non-human caller — CI pipelines, runtime reporters, scripts, and other automation — so that credentials and audit trails are tied to a system rather than a person.
Service accounts are only available in shared organizations.

Create a service account

1

Open the organization's settings

Sign in to Kosli and select the organization where the service account should live. Navigate to Settings → Service accounts.
2

Add the service account

Click Add new service account, give it a descriptive name (e.g. ci-github-actions), and click Add.
3

Generate an API key

On the new service account, click Add API key. Choose a Time-To-Live (TTL), add a label that identifies where the key will be used, and click Add.
4

Copy the key immediately

Kosli stores only a cryptographic hash of the token. The original value is shown once and cannot be retrieved later — paste it directly into your secret store.

Assign a role

Service accounts have the same role model as users: Admin, Member, Snapshotter, or Reader. The role determines what the service account can do in the organization. Pick the least-privileged role that fits the workload. See Roles in Kosli for the full permissions matrix. As a starting point:
  • Member — CI/CD systems that report attestations, manage flows, and create resources.
  • Snapshotter — runtime reporters that record environment snapshots and create and tag environments (for example, CLI callers using --auto-environment).
  • Reader — read-only systems such as dashboards or query tooling.
  • Admin — rarely needed; reserve for automation that manages users, roles, or organization-wide settings (for example, Terraform-driven org bootstrap).

Manage service accounts with the CLI

You can create and manage service accounts and their API keys with the Kosli CLI instead of the UI. These commands assume that --api-token and --org are set, and the API token belongs to a user or service account allowed to manage service accounts. Create a service account with --privilege set to admin, member, snapshotter, or reader:
API keys are created separately. The key value is shown only once, so store it in your secret store straight away. Without --expires-at, the key gets the maximum allowed lifetime.
To inspect, change, or remove service accounts:
To list a service account’s API keys, or revoke one:
kosli list api-keys shows each active key’s metadata, including its ID, but never the key value. kosli delete api-key revokes the key immediately and also deletes every key that was created with it. kosli update service-account changes only the flags you pass. kosli delete service-account permanently deletes the service account and its API keys. It asks for confirmation, so pass --assume-yes in CI or other non-interactive shells. See the reference pages for all flags: kosli create service-account, kosli list service-accounts, kosli get service-account, kosli update service-account, kosli delete service-account, kosli create api-key, kosli list api-keys, and kosli delete api-key.

Manage service accounts with Terraform

The Kosli Terraform provider manages service accounts with the kosli_service_account resource and their API keys with the kosli_service_account_api_key resource:
The raw key is returned only when Terraform creates the key, and is stored in Terraform state as a sensitive value, so protect your state. API keys are immutable: changing description, expires_at, or service_account_name revokes the key and creates a new one. To read an existing service account without managing it, use the kosli_service_account data source.

Refuse personal API keys

By default, an organization accepts both service account API keys and members’ personal API keys. An admin can make the organization accept only service account API keys. This applies to shared organizations only.
1

Open the general settings

Sign in to Kosli as an admin and select the organization. Navigate to Settings → General.
2

Refuse personal keys

In the API keys panel, set Personal API keys to Refused.
3

Confirm

In the Refuse personal API keys? dialog, click Refuse personal keys.
The change takes effect immediately. Kosli rejects every request to the organization made with a personal API key, including from admins, with HTTP 403 and this message:
Before you refuse personal keys, move the CLI, CI pipelines and scripts that use them to service account keys. Personal keys keep working in the member’s other organizations, and signing in to the Kosli app in a browser is not affected. To accept personal keys again, set Personal API keys back to Accepted, and in the Accept personal API keys? dialog, click Accept personal keys. The setting restricts which type of key works, not who holds one. A member who is allowed to manage service accounts can still create one and an API key for it. To read or change the setting through the API, send GET or PATCH to /api/v2/organizations/<org>/settings with an API key that has the Admin role. Once personal keys are refused, that must be a service account key. The refuse_personal_api_keys field is a boolean:

Refuse old personal API keys

Instead of refusing all personal API keys, an admin can refuse only those issued before a cut-off. For example, after a key leaks, ask members to create new keys, then set a cut-off so the old keys stop working in the organization. This applies to shared organizations only. Set the cut-off in one of two ways:
  • Issued on or after a date: Kosli accepts keys issued from 00:00 UTC on that date. The date can be at most 60 days in the past.
  • Issued no more than a number of days ago: Kosli accepts keys issued within the last 1 to 3650 days. Each key stops working that many days after it was issued. Members then need to create a new key, or regenerate one, from their Profile page: rotating a key from the CLI keeps its issue date.
1

Open the general settings

Sign in to Kosli as an admin and select the organization. Navigate to Settings → General.
2

Turn the cut-off on

In the API keys panel, set Oldest personal key accepted to On.
3

Set the cut-off and confirm

In the Turn on the cut-off? dialog, choose Issued on or after a date or Issued no more than a number of days ago, and enter the date or number of days. The dialog opens on the saved cut-off, if there is one. Click Save and turn on.
The cut-off takes effect immediately, including for the CLI and CI pipelines. Kosli rejects a request to the organization made with a personal API key issued before the cut-off with HTTP 403 and a message that says when the key was issued and asks the member to create a new key in the Kosli web app. Kosli also refuses a personal API key with no recorded issue date while the cut-off is on. A key’s issue date is when its secret was issued:
  • A key you create or regenerate from your Profile page is issued at that moment.
  • A key created or rotated with another API key, for example with kosli create api-key --personal or kosli rotate api-key --personal, counts as issued when that API key was. A leaked key can’t create a fresh key that gets past the cut-off.
  • During a rotation’s grace period, the replaced secret keeps its own issue date.
Service account keys and signing in to the Kosli app in a browser are not affected. To change the cut-off, click Edit next to Oldest personal key accepted, enter the new date or number of days, and click Save. While the cut-off is on, confirm the change in the Apply this cut-off? dialog by clicking Apply cut-off. To stop applying the cut-off, set Oldest personal key accepted to Off, and in the Turn off the cut-off? dialog, click Turn off. The saved cut-off stays and applies again when you turn it back on. If you also refuse all personal API keys, that setting takes precedence. To set the cut-off through the API, send PATCH to /api/v2/organizations/<org>/settings with an API key that has the Admin role. Set personal_api_key_cutoff to an object with exactly one of issued_on_or_after (a YYYY-MM-DD date) or issued_within_days (a whole number), and personal_api_key_cutoff_enabled to true or false. Fields you leave out keep their saved values. The API can replace a saved cut-off but not clear it, so send "personal_api_key_cutoff_enabled": false to stop applying it.

Rotate or revoke keys

For zero-downtime rotation and the API-driven flow, see:
Last modified on December 4, 2026