Service Accounts
A service account is a non-human identity (a technical identity) in a CodeNOW account. Use it wherever something should act with its own, limited permissions instead of a person's:
- every agent runs as a service account,
- an API key with a service account as its subject calls the CodeNOW API with the service account's permissions, never with those of the person who created the key,
- a Git token or SSH key of a service account lets a CI pipeline or script clone and push repositories as the service account — see Clone repositories as a service account.
A service account is a regular account member with the role User. It never becomes an account Owner or Admin and never receives grants made to all users.
Service accounts, their keys, tokens and secrets are created and managed in the CodeNOW UI. The public CodeNOW API and the CodeNOW MCP server can read them: list and look them up (for example to pick the service account of an agent) and audit their credentials — see Audit service-account credentials.
Where to find them
| Place | What you see |
|---|---|
| Profile › SERVICE ACCOUNTS (user menu › Profile) | Service accounts you own. Create Service Account creates a new one owned by you or by one of your teams. |
| Account Settings › SERVICE ACCOUNTS | All service accounts of the account — an overview for account Owners and Admins, without a create button. |
| User detail › Service Accounts card | Service accounts owned by that user. |
| Team detail › MEMBERS › Service Accounts card | Service accounts owned by the team. |
The list shows the state icon, Name (with the username), Description, Owner, CodeNOW API keys (1 active, …), Git credentials (2 credentials, …), Deployment tokens and actions — Disable / Enable, detail, delete. A column says None active when there is nothing; when an API key, Git token or SSH key expires within 14 days it shows a warning icon and expires in N days. Actions are available to the service account's managers.
Identity
| Property | Value |
|---|---|
| Name | 3–40 characters: lowercase letters, digits and single dashes, starting and ending with a letter or digit; unique in the account |
| Username | sa-<accountId>_<name> — shown under the name field while creating; used in tokens (preferred_username), permission listings and integrated tools |
<username>@service-accounts.codenow.com — a technical address, not a mailbox |
The service account gets its own identity in the account's integrated tools that manage identities (for example CodeNOW GitLab and Artifactory), just like a user.
Creating a service account
Create Service Account opens a page with two cards:
- Service Account — Name, Owner and Description. The owner is Me (<username>) or one of your teams; account Owners and Admins can pick any team, other users only teams where they are Admin or Service Account Manager. Nobody — account Owners and Admins included — can create a service account owned by another user.
- Permissions — the levels to grant. Only levels the selected owner has are offered (Rows below are what <owner> has. Nothing is granted until you add it.); when the owner can do everything, any permission group can be granted, except Agent Gateway. Agent Gateway rights are never offered. Changing the owner after picking levels clears them.
Click Create service account. The permissions are granted right after the account is created; progress is shown on its PERMISSIONS tab.
Owner
Every service account has an owner — a user or a team. The owner sets the limit of what the service account may do and decides who manages it; it does not grant anything by itself.
A team-owned service account belongs to its owning team and gets the team's permissions on other resources according to its permission mode. It holds no permission on the team itself (it can never manage a team) and cannot be a member of any other team. A user-owned service account belongs to no team.
A user-owned service account always belongs to the person who created it. It can't be handed over to another user — not even by an account Owner or Admin; Change owner… offers only Me and teams. A service account can be moved to a team (account Owners and Admins can pick any team) and back to yourself.
Who manages a service account
Managing means editing, changing the owner, managing permissions, keys and tokens, secrets and integrations, disabling and deleting.
| Owner | Managers |
|---|---|
| User | that user, account Owner/Admin |
| Team | team members with the Admin or Service Account Manager level on the owning team, account Owner/Admin |
Creating credentials — CodeNOW API keys, Git HTTPS tokens and SSH keys — is reserved for the owner: the owning user, or for a team-owned service account the team's Admins and Service Account Managers. Account Owners and Admins who are not the owner can view, suspend, revoke and delete a service account's credentials, but not create new ones; Create token, Add SSH key and Create API key are disabled for them (Only the owner <name> can create credentials.).
- Creating a service account for a team requires the same team level.
- Changing the owner does not affect existing keys, tokens or running deployments.
Permission modes
What a service account may do is always limited by its owner's current permissions:
- team owner — the grants made to that team;
- user owner — everything the user can do right now: own permissions, their teams' permissions and what everyone in the account has (for an account Owner/Admin everything).
admin lifts the limit for its resource. When the owner holds admin on a resource — directly, through a team or everyone, through an All … grant or through a parent resource (for example admin on an application covers its components) — the service account can be granted any level of that resource type, edit-permissions included. admin contains every other level, so nothing on that resource is out of reach.
Exception: the Agent Gateway. A service account never has Agent Gateway rights, whatever its owner has and in either permission mode: no Viewer or Admin level (account-wide or per gateway) and no Agent Gateway Permission Manager account permission. Rights granted earlier no longer count. Earlier Viewer and Admin levels are not listed here but on the gateway's Permissions page, where they can only be removed; an earlier Agent Gateway Permission Manager can be shown here as No effect: Service accounts can’t have Agent Gateway permissions (Agent Gateway Permission Manager). The editor does not offer Agent Gateway rights; in the account permissions checklist the hint is Service accounts can’t have Agent Gateway permissions (if one is stored: … uncheck to remove it.). A refused save or a failed job row shows Service accounts can't have Agent Gateway permissions. Remove them from your changes. Agents do not need them, and service accounts can still be allowed callers of agents.
| Mode (UI) | Effective permissions | Available for |
|---|---|---|
| Custom (default) | Only its own grants, limited to what the owner holds. A grant must fit the owner's permissions when it is made — where the owner holds admin, every level of that resource type fits; a grant on all resources of a type requires the owner to hold that too. | user- and team-owned |
| Follow team | Exactly the owning team's permissions (except Agent Gateway rights), now and as they change. Read only — no direct grants. | team-owned only |
- The limit is evaluated on every request, so a service account loses whatever its owner loses.
- Grants that no longer fit (for example after an owner change) are kept but have no effect — marked ⚠︎ and listed under No effect (n), from where you can remove them.
- Switching from Follow team to Custom lets you start with the team's levels (without Agent Gateway rights) or empty (Saved empty, agents using this service account lose all access.).
- Moving a service account to a user owner switches it to Custom; use Copy owner's permissions to start from the owner's levels.
- If the owner is deleted, the service account has no effect at all until it gets a new owner (its grants are kept).
The Permissions tab
The Service Account Permissions card shows the owner (Owner · sets the limit) with Change owner…, the mode switch (Follow team / Custom), Copy owner's permissions, Add permission and No effect (n). Copying never brings Agent Gateway rights. Each row is a resource with its access levels:
| Chip | Meaning |
|---|---|
| ✓ Granted | Held by the service account. Click to revoke. |
| ↳ Inherited | Comes from All … or the parent resource. Click to grant directly. |
| + Available | The owner has it. Click to grant. |
| ⚠︎ No effect | Granted, but the owner does not have it. Click to remove. |
| ✎ Unsaved / − Removed | Pending change. Click to undo. |
| ✕ Failed | Saving failed — see the row. |
Changes — including an owner or mode change — are collected as a draft and saved together with Save changes; one save runs one Update Service Account job. While it runs, editing is locked and the banner links to the job.
Service account detail
The title is the service account's name. Tiles: Actions (Choose Action), State, Owner (with the creation date), Access and Description. The Access tile has one line per kind of access, each linking to its tab:
| Line | Shows |
|---|---|
| Permissions | Custom or Follows team … |
| CodeNOW API keys | 1 active, …; with a warning icon and expires in N days when an API key expires within 14 days |
| Git credentials | 2 credentials, …; with a warning icon and expires in N days when a Git token or SSH key expires within 14 days (the HTTPS tokens / SSH keys tab is marked too) |
| Deployment tokens | The active deployment tokens |
A line says None active when there is nothing of that kind.
| State | Meaning |
|---|---|
| Active | The service account works. |
| Disabling… / Enabling… | Disable or enable is in progress. |
| Disabled | See Disable and delete. |
| Deleting… | Delete is in progress. |
Actions: Edit service account (description), Add secret, Revoke all deployment tokens (deployment tokens only — not API keys or Git credentials), Disable service account / Enable service account, Delete service account. The owner and the permission mode are changed on the PERMISSIONS tab.
| Tab | Content | Visible to |
|---|---|---|
| USED IN | Deployments using the service account: agent swarm, environment, configuration version, deployed, agent, token state | anyone who can open the page |
| PERMISSIONS | Permission modes and grants | managers |
| KEYS & TOKENS | Git access (HTTPS tokens, SSH keys) and CodeNOW API keys of the service account | managers |
| THIRD PARTY INTEGRATIONS | Connected identities and accounts in external systems — the same as a user's. Sign in to the provider as the service account's technical account, not your personal one. | managers |
| ENVIRONMENT SECRETS | Secrets injected into agents | managers |
Deployment tokens
Deployment tokens are issued automatically when an agent is deployed — one per deployment of an agent:
- a redeploy reuses the deployment's token (so the agent's
AI_GATEWAY_REFRESH_TOKENstays the same); - undeploying the agent, removing it from the swarm or switching it to another service account releases the token.
The tokens are long-lived refresh tokens without an expiry date. Access tokens obtained with them are valid for 10 minutes. In USED IN each token is Active, Released (the deployment was undeployed or redeployed; the token idles out within 30 days or at the next revoke) or Revoked.
- Revoke token on a row stops that agent's token immediately; the agent gets a new token on its next deployment.
- Revoke all deployment tokens cuts off every deployment using the service account until it is redeployed; the service account stays enabled.
Deployment tokens are not part of the credential audit.
API keys
The CodeNOW API keys card on the KEYS & TOKENS tab. An API key whose subject is a service account works like a personal API key — Create API key (name, Expires: 30, 90 or 365 days, a custom date or no expiry), Suspend / Resume, Delete — but API keys act with this service account's permissions, never those of the user who created them:
- its own grants and those of its team (per the permission mode), never Owner/Admin;
- where it has no grant, details and writes return
403and lists are filtered.
The list shows Status, Name, Created, Created by, Expires (UTC), Last used and the actions. A key stops working at 00:00 UTC on its expiry date (keys created before this rule may show an end-of-day time). From 14 days before expiry the key is marked with a warning icon and <date> · in N days. Last used is recorded by CodeNOW and can lag by up to 5 minutes; use from before recording started isn't shown.
The key is shown only once after it is generated. Only the owner can create API keys. Typical use: give an automation or an external agent least-privilege access to the CodeNOW API or the MCP server. API keys don't work for Git — use Git access.
Git access
The Git access card on the KEYS & TOKENS tab holds the service account's Git credentials — HTTPS tokens (Create token) and SSH keys (Add SSH key). They act in CodeNOW Git with the service account's permissions, never those of the person who created them, and both expire (at most 365 days by default). Nobody is e-mailed before they expire. Only the owner can create them. The step-by-step guide, including CI examples, rotation and what disable/delete do, is Clone repositories as a service account.
Environment secrets
Secrets are sensitive values mapped as environment variables into every agent the service account is assigned to. Use Add Secret:
| Field | Rules |
|---|---|
| Environment Variable Name | Upper-case letters, digits and underscores (names are case-sensitive), not starting with a digit; at most 128 characters. Reserved names are refused. |
| Description (optional) | At most 1024 characters |
| Value | Required, not blank, up to 64 KiB (UTF-8), multi-line allowed. Write-only — the value can't be viewed after saving. When updating, leave it empty to keep the current value. |
Changes apply on the next deployment of agents using the service account. An expired secret blocks the deployment of agents that use the service account. If a secret has the same name as an environment variable of the agent component (for example from codenow/config/environment-variables), the secret wins; the deployment reports it as a warning.
Reserved names
CodeNOW sets these variables in the agent itself (see Agent Runtime), so a secret cannot use them — saving such a secret is refused with <NAME> is reserved for CodeNOW — agents would never receive it.
| Rule | Names |
|---|---|
| Prefix | AI_GATEWAY_, OIDC_, CONSOLE_, CN_, CODENOW_ |
| Exact name | A2A_AGENTS, AGENT_PUBLIC_URL |
| Suffix | _A2A_URL |
Secrets saved before this rule was introduced may still use such a name. They are not injected and the list marks them with Reserved name — not passed to agents. Rename it. Their update drawer unlocks the name field (otherwise the name is read-only on update) and they can't be saved until renamed.
Using a service account in an agent
When saving an agent's configuration you can select only service accounts that you own, or that are owned by a team you are a member of; account Owners and Admins can select any service account. Disabled service accounts are shown but cannot be selected. The check is made when the configuration is saved, not when it is deployed — someone else can deploy the configuration as saved.
Deploying an agent fails when its service account does not exist, is disabled, or has expired secrets.
In the public API and the MCP server, the agent's service account is set in agentGateway.serviceAccountId of the agent swarm deployment configuration. It accepts either the service account's ID (UUID) or its username (sa-<accountId>_<name>) and is always stored as the ID:
- an unknown value is rejected with
400— service account '…' not found; serviceAccountId must be the service account UUID or username (sa-<account>_<name>); - an existing service account you may not use is rejected with
403; - the deployment configuration detail also returns the read-only
serviceAccountUsernameandserviceAccountTeam; they are left out when the service account is unknown, andserviceAccountTeamalso when it is user-owned.
Finding service accounts in the API and MCP
You don't need to look up the ID in the UI — list the service accounts instead:
| API | MCP tool | Returns |
|---|---|---|
GET /service-accounts?usable=true | service_account_list (usable: true) | Service accounts you may set as an agent's service account — the same set as in the UI: your own and those of teams you are a member of; account Owners and Admins get all. |
GET /service-accounts | service_account_list | Service accounts you may manage — your own and those of teams where you are Admin or Service Account Manager (account Owners and Admins: all) — the same as who manages a service account. |
GET /service-accounts/{idOrUsername} | service_account_get | One service account by ID or username, if it is in the usable set; otherwise 404. |
Add team=<team> to list only service accounts owned by that team. Disabled service accounts are listed too. Each entry has id, username, name, team (owning team, or null), owner (owning user, or null) and status (ENABLED / DISABLED).
When the caller is itself a service account (for example an API key of a service account or an agent), usable=true returns an empty list and the detail returns 404.
Disable and delete
- Disable — Disabling signs the service account out of CodeNOW at once: its CodeNOW API keys stop working and all deployment tokens issued to it are revoked. Its Git tokens and SSH keys stop working as soon as its GitLab user is blocked, normally within seconds. A disabled service account gets no new API keys or Git credentials (revoking still works); its KEYS & TOKENS tab says so. Agents referencing a disabled service account fail on their next deploy.
- Enable — restores the API keys, Git tokens and SSH keys that haven't expired or been revoked; deployments get new deployment tokens the next time they are deployed.
- Delete — confirm by typing the username. Deleting revokes all tokens (including every Git token and SSH key), removes all stored secrets and credentials, deletes the identity in CodeNOW and in the integrated tools, and removes its permissions. It does not check whether deployed agents still use the service account — their calls simply start failing, so switch those agents to another service account first.
- Deleting a user also deletes the service accounts the user owns.
- A team that owns service accounts cannot be deleted — delete them or move them to another owner first.