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:
--expires-at, the key gets the maximum allowed lifetime.
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 thekosli_service_account resource and their API keys with the kosli_service_account_api_key resource:
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.