Skip to content

Service accounts

A service account is a machine principal that your tenant owns. Terraform, a CI pipeline, or awctl in a script authenticates as the service account rather than as a person, and every call it makes is recorded under the account’s own subject. It has no browser login and no password; it holds a client secret, and it exchanges that secret for a token with the OAuth 2.0 client_credentials grant.

Technically, a service account is a client of the estate’s admin issuer, seated as a member of your tenant. Its token, requested for the admin audience, is accepted by the Admin API the same way an administrator’s is. What it can do is decided by the roles you bind to it at your tenant, and a new account holds none, so it can do nothing until you give it a role.

Service accounts are a tenant administrator’s surface. An operator needs none: the operator’s credential is the machine credential minted at install. If you are automating a tenant you administer, this page is for you.

  • The owner seat at the tenant. Creating, deleting, and minting secrets for a service account, and setting its roles, need the tenant’s owner seat (tenancy.owner). A member administrator can list the tenant’s accounts and nothing more. See Administrators and owners.
  • A path to the central install. Service accounts live on the central install of the estate, where every seat lives. The console reaches it for you. With awctl, run these commands against central’s Admin API; a satellite refuses them and names central in the error.
  • Identity server 1.43 or later on the central install, awctl 0.17 or later, and provider 0.11 or later. Setting roles from awctl and the provider needs awctl 0.18 and provider 0.12.

A service account is created with a display name and nothing else. It comes back seated at your tenant, with no role and no secret.

In the console, open your tenant’s Access page and choose Create a service account in the Service accounts section. The new account appears in the list with its client identifier (c-…), its secret state, and the roles it holds at this tenant.

With awctl, the tenant is your identity context’s, or --tenant-id:

Terminal window
awctl identity service-accounts create --display-name terraform
c-01j9x4h2k7m3p terraform no secret no roles

With Terraform:

resource "authwise_service_account" "ci" {
display_name = "terraform"
}

The display name is unique among your tenant’s accounts. Nothing about an account changes in place: in Terraform, changing any argument replaces it, and with awctl you delete and create. An optional --expires-at (expires_at in Terraform) makes the token endpoint refuse the account after a date, for an account that should stop existing with the project that needed it.

Each tenant can hold at most 100 service accounts unless the operator raised the limit.

A new service account can do nothing. Bind it the least role that does the job, at your tenant:

RoleWhat it allows
tenant.viewerRead everything inside the tenant. The right role for drift detection, reporting, and terraform plan.
tenant.adminManage the tenant’s identity catalog: domains, issuers, realms, providers, users, clients, roles, and bindings. The role for terraform apply and provisioning pipelines.
guardcontrol.adminAdminister the Authwise Guard tenant linked under this tenant, on estates where Guard is enabled.

Only these roles can be set on a service account. A service account is never an owner, never an operator, and never reads the audit trail beyond the tenant’s own rows that tenant.admin already sees. A request for any other role is refused with the role named.

In the console, choose the roles in the account’s row. With awctl:

Terminal window
awctl identity service-accounts set-roles --service-account c-01j9x4h2k7m3p --roles tenant.admin

With Terraform, add roles to the resource:

resource "authwise_service_account" "ci" {
display_name = "terraform"
roles = ["tenant.admin"]
}

The roles you pass are the whole set, comma-separated. Passing a shorter list removes the roles left out, and --roles '' removes them all. A role an operator bound to the account outside this list is left as it is and shows in the account’s roles.

The secret is minted on request and shown once. Authwise stores a hash and cannot show it again, so store it before you leave the screen.

In the console, open the account and choose Mint a secret. The dialog shows the secret once, with the token URL, client identifier, and audience a pipeline needs beside it. The expiry defaults to 90 days; clear it for a secret that does not expire.

With awctl, the secret goes to stdout alone, or to --out, which is written with mode 0600 and never over an existing file. The other three values the client-credentials grant needs go to stderr:

Terminal window
awctl identity service-accounts secrets mint --service-account c-01j9x4h2k7m3p --out sa.secret
secret cs-01j9x4j… minted for c-01j9x4h2k7m3p, written to sa.secret
AWCTL_TOKEN_URL=https://admin.example.com/oauth/token
AWCTL_CLIENT_ID=c-01j9x4h2k7m3p
AWCTL_AUDIENCE=a-01

With Terraform, the secret is a resource of its own. The plaintext lives in the state, so treat the state as sensitive:

resource "authwise_service_account_secret" "ci" {
service_account = authwise_service_account.ci.name
expires_at = "2027-01-01T00:00:00Z"
}
output "ci_credential" {
value = {
token_url = authwise_service_account_secret.ci.token_url
client_id = authwise_service_account.ci.client_id
client_secret = authwise_service_account_secret.ci.secret
audience = authwise_service_account_secret.ci.audience
}
sensitive = true
}

Put the four values in your CI system’s secret store under the names the consumer expects: AUTHWISE_TOKEN_URL, AUTHWISE_CLIENT_ID, AUTHWISE_CLIENT_SECRET, and AUTHWISE_AUDIENCE for the Terraform provider, and the same names with the AWCTL_ prefix for awctl. The audience is the admin audience’s identifier, a-01 on every install; it is an identifier, not a URL.

Every consumer of a service account works the same way: it exchanges the secret for a token at the token URL on each run and sends the token to the Admin API. Nothing is stored between runs.

With awctl, set the four variables and the endpoint, and every command authenticates as the account. Pass the tenant explicitly in CI, where no context exists. On the Authwise service, the endpoint is api.authwise.com:443 and the token URL is https://admin.authwise.com/oauth/token; on your own install, see Point it at an install. The tenant’s ID is in the console’s address bar when you open the tenant, as /tenants/TENANT_ID:

Terminal window
export AWCTL_ENDPOINT=API_HOST:443
export AWCTL_TOKEN_URL=https://admin.example.com/oauth/token
export AWCTL_CLIENT_ID=c-01j9x4h2k7m3p
export AWCTL_CLIENT_SECRET="$(cat sa.secret)"
export AWCTL_AUDIENCE=a-01
awctl identity realms list --tenant-id t-01hzx3k9r2m7q

With the Terraform provider, export the AUTHWISE_ variables and leave the provider block to scope defaults, as described in Configure the provider. A pipeline that runs terraform plan on pull requests and terraform apply on the main branch can use two accounts, one holding tenant.viewer and one holding tenant.admin, so a plan can never change anything.

A call the account’s roles do not allow is refused with PermissionDenied. A call against a satellite install for something that lives at central, such as the tenant’s administrators, is refused and names central.

Rotate by minting again. With rotate on, which is the default, the older live secrets keep working for a grace period and then lapse, so a pipeline holding the old secret has that long to pick up the new one. The grace defaults to 24 hours.

Terminal window
awctl identity service-accounts secrets mint --service-account c-01j9x4h2k7m3p \
--rotate --grace 48h --out sa.secret

In Terraform, change a keeper on the secret resource to rotate it. The new secret is minted, the old one lapses after grace, and the output picks up the new value:

resource "authwise_service_account_secret" "ci" {
service_account = authwise_service_account.ci.name
grace = "48h"
keepers = {
rotation = "2026-10"
}
}

Two secret resources on one account with rotate left on would rotate each other out on every apply; set rotate = false on all but one.

awctl identity service-accounts describe --service-account c-01j9x4h2k7m3p lists the account’s live secrets by identifier and expiry, never their material, and the roles it holds. The console shows the same in the account’s Service account secrets card.

There is no revoke of one secret. A secret stops working when it expires, when a later mint rotates it out, or when the account is deleted. Destroying an authwise_service_account_secret in Terraform forgets the secret and revokes nothing; the documentation of that resource says so.

To revoke an account’s access at once, delete the account. Deleting takes its secrets, its roles, and its seat with it:

Terminal window
awctl identity service-accounts delete --service-account c-01j9x4h2k7m3p

delete asks first; --yes skips the prompt. In the console, the delete action is in the account’s row. In Terraform, removing the authwise_service_account resource deletes it, and because the secret resource references the account, Terraform destroys the secret first.

A delete is refused while the account holds a role that an operator bound outside the roles you can set, and the message lists those bindings. Remove them first.

SymptomCause and fix
PermissionDenied on every call the account makesThe account holds no role, or not the one the call needs. Set a role; see Give it a role.
The token request fails with invalid_clientThe secret has expired, was rotated out past its grace, or the account was deleted. Mint a new secret.
The token request fails on the audienceAUTHWISE_AUDIENCE or AWCTL_AUDIENCE holds a URL. It is the admin audience’s identifier, a-01.
Every call fails with 405 Method Not Allowed and a text/html content typeThe endpoint is the admin issuer host (admin.authwise.com), which serves the token endpoint and not the Admin API. Use api.authwise.com:443 on the Authwise service, or the install’s Admin API host.
The account has no way to learn its tenant’s IDThe token carries no tenant claim, and awctl has no whoami yet (awctl#56). Read the ID from the console’s address bar, /tenants/TENANT_ID, and pass it as --tenant-id.
InvalidArgument naming a role when setting rolesThe role is not one a service account can hold, or this estate does not seed it (guardcontrol.admin without Guard). Choose one of the listed roles.
A create or mint is refused and names another installYou sent it to a satellite. Service accounts live at central; point awctl at central’s Admin API.
ResourceExhausted on createThe tenant holds its maximum number of service accounts. Delete one you no longer use, or ask the operator to raise the limit.
FailedPrecondition on delete, listing bindingsAn operator bound a role outside the settable list. Have it removed, then delete again.