Skip to content
Swarmetry

Automate

Service accounts

Give a CI pipeline or a script its own access, rotate and revoke its tokens.

A service account is an account of your organization that belongs to no person. Give one to each CI pipeline, script or integration that calls Swarmetry (the REST API, the command line swarmetry, the MCP server): it keeps working when the person who set it up leaves the organization or changes role, and the audit shows what the service account did, under its own name.

A personal API token (page 12) acts as you. Use it for your own scripts. Use a service account for anything shared or automated.

Only the organization's owners and administrators manage service accounts, in Administration → People → Service accounts (/admin/service-accounts).

What a service account may do

  • Its role: Member reaches only the projects you add it to (see "One project only" below); Administrator reaches every project; a custom role of your organization works too. Owner is never possible.
  • Its permissions: everything its role allows, or only the permissions you select. You can never give more than you hold yourself.
  • Never: managing people, roles, groups, plans, billing, security policies, quotas, domain verification or the assistant, deciding approvals, or anything of the platform. These stay with people, whatever the role.
  • It never signs in to the web app, never receives e-mail and is never listed among the members.

It uses a seat of your plan, like a member, while it is enabled. When the seats are full, the creation is refused with "A service account uses a seat of your plan": disable or delete an account, or add seats to your plan (page 24). A disabled service account frees its seat.

Create a service account

  1. Create a service account, then give it a name that says what uses it (for example ci-pipeline) and, if you like, a description.
  2. Choose its role and its access: Everything the role allows or Selected permissions only. For a pipeline that starts tests and reads their results, Member with the project roles it needs is enough.
  3. Name its first token (where it is used, for example github-actions) and choose its lifetime: from 1 to 365 days, 90 by default, never longer than your organization's maximum (Security policies).
  4. Create. The secret of the token (it starts with sw_sat_) is shown once: copy it now and store it where your pipeline keeps its secrets, for example a variable SWARMETRY_TOKEN. Swarmetry keeps only a fingerprint of it and can never show it again.

If you protect your account with two-step verification, Swarmetry may ask you to confirm it before creating a token. If the first token is refused, the service account is still created: its page says why and lets you create a token.

Use the token

Send the token as a bearer token:

curl -H "Authorization: Bearer $SWARMETRY_TOKEN" https://swarmetry.io/api/v1/projects

With the command line: swarmetry login --token-stdin, then paste the token. The command line says "Logged in … as service account ci-pipeline".

Your organization's allowed IP ranges (Security policies) apply to service accounts too: a CI runner outside them is refused.

One project only

To let a service account reach one project, give it the Member role, then copy its address for project roles (sa-…@service-account.invalid, on its page) and add it to the project's members with the project role it needs (Project → Members). No e-mail is ever sent to that address.

Tokens: rotate, revoke, expiry

A service account has at most two working tokens at once.

  • Rotate replaces a token by a new one with the same name. The old secret keeps working during the overlap you choose (0 to 168 hours, 24 by default; 0 stops it at once), so you can update the pipeline's secret without a failed run. During the overlap the old token shows Ending after rotation.
  • Revoke stops a token at once. Use it when a secret may have leaked.
  • Expiry: the organization's owners and administrators are told 7 days and again 1 day before a token expires, in the app and by e-mail (topic "Service account tokens that expire", which each person can turn off in their notification settings, see page 26). The token's page also shows how many days are left. Rotate it before it expires.
  • The last use (time and address) of each token and of the account tells you whether it is still needed.

Disable or delete

  • Disable refuses its tokens at once and frees its seat. Enable brings them back (the tokens that have not expired work again) and uses a seat again.
  • Delete revokes its tokens, removes its project roles and frees its seat. The audit keeps its name. This cannot be undone.

Every change is recorded in the audit (Administration → Audit), and the requests a service account makes are shown as "Service account ".