Zitadel service accounts for machine-to-machine access

Zitadel service accounts let backend services authenticate without a user. This page explains how to pick private key JWT, client credentials or personal access tokens, and how to rotate keys, scope roles and store secrets.

On this page

Zitadel service accounts for machine-to-machine access: when your services need their own identity

Service accounts give non-human callers their own identity, their own roles and their own audit trail, so a backend job, pipeline or service can call a Zitadel-protected API or the Zitadel management API without borrowing a person's session. The credential type you choose drives both the security and the operating burden of every automated caller, so that choice deserves the same care as the role design. Teams need this pattern when a scheduled job, deployment pipeline, integration or internal service must read or change data on its own schedule, often when nobody is logged in at all.

A user-based flow is the wrong tool for these callers. Authorization code flows and similar user flows assume a browser or device and a person who can approve consent, and tokens issued that way carry the user's identity and permissions. Using a personal account for automation means that when the person leaves, changes role or enables multi-factor authentication, the automation breaks or, worse, keeps running under an identity nobody reviews. It also blurs audit logs, since actions look like human actions. A service account keeps the caller's grants separate, so each one can be scoped to the minimum set of projects, roles and API actions it needs.

Before you build, confirm against the Zitadel documentation for the version you deploy how service accounts are created, which credential types they support (such as private key JWT, client credentials or personal access tokens), how keys are generated, rotated and revoked, and how roles are granted in each organization. Plan the rotation process and the secret store up front, and decide who may create and delete service accounts. Ask the vendor or your own platform team to confirm the exact behavior of each setting in your environment, because the details differ across releases and should not be assumed from older guides.

Which credential type fits each machine caller

A long-running service, such as a backend that calls a protected API or a worker that reads user data on a schedule, needs a credential that survives restarts and can be rotated without a code change. Client credentials and private key JWT are the usual choices here. With client credentials, the service holds a client ID and secret and exchanges them at the token endpoint for an access token. With private key JWT, the service signs a short-lived assertion with a private key it never shares, and Zitadel verifies it against the public key registered for the application.

  • Creation: Create a service account (machine user) in the right organization, then add a client secret or register a public key for private key JWT.
  • Presentation: Client credentials send the ID and secret to the token endpoint. Private key JWT sends a signed assertion instead, so no shared secret crosses the wire.
  • Good fit: Services with stable deployment, where the key can live in a secrets manager and be rotated on a planned schedule.
  • Poor fit: Environments where the secret would be copied into configuration files or images, which makes rotation and revocation difficult.
  • Key rotation: Plan an overlap window in which the old and new key or secret are both accepted, so the service can switch without downtime.

Confirm in the Zitadel documentation how each method is configured, what lifetimes apply to issued tokens, and how scopes and roles are evaluated for service accounts.

Configuration options and when each one fits

This table compares the four ways a service can authenticate in a Zitadel setup: private key JWT, client secret client credentials, personal access tokens and a machine user with project grants. Read each row against the workload's trust boundary and the team that will rotate its credentials. The main takeaway is that the option with the lowest setup effort is rarely the one with the smallest blast radius when a secret leaks.

OptionBest fitWhat it protects againstOperational burdenWhat to confirm
Private key JWTBackend services that call Zitadel or its APIs and can keep a private key in a secrets storeTheft of a reusable shared secret, since the private key never leaves the serviceKey pair generation, public key registration and a rotation schedule for each serviceWhich key formats and signing algorithms your Zitadel version accepts, and how keys are registered
Client secret client credentialsSimple server-side jobs where the team can store a secret securely and rotate it on a fixed cycleUnauthenticated callers, but a leaked secret can be replayed until it is rotatedLow setup, though every secret must be stored, distributed and rotated by hand or by automationHow secrets are shown, stored and regenerated in your Zitadel version, and whether old secrets can be revoked immediately
Personal access tokenShort-lived administrative scripts or local tooling tied to one user's accessExposure is limited to the owning user's permissions, but tokens can outlive the work they were created forLow to create, but tokens must be tracked, expired and removed when the person leaves or changes roleExpiry options, who can create tokens, and whether tokens can be scoped to a single service or project
Machine user with project grantsNon-human identities that need roles on specific projects in an organizationOver-broad access, because the machine user receives only the roles granted to its projectOngoing review of grants and roles as applications and projects changeHow grants are scoped per project and organization, and which roles the API audience check will enforce

How to set up a service account step by step

This sequence takes a machine identity from creation to a verified, least-privilege credential, so each calling service gets only the access it needs and you can prove that the boundary holds before go-live.

  1. Create the machine user in the correct organization

    In the Zitadel console, create a machine user inside the organization that owns the project the service will call, not in a shared or default organization. Your identity administrator performs this step, and the service should have a clear owner and a description that names the workload. It is done when the user appears under that organization's users with the machine type, and the organization name matches the one where the target project lives. Confirm this against your own tenant model before you create anything, because moving a machine user later is more work than creating it correctly first.

  2. Define project roles with least privilege

    In the project that exposes the API, define only the roles the calling service needs, such as one role for reading orders and a separate role for writing them. Your API owner and security reviewer agree on the role list, and each role should map to a specific permission in the API. This step is complete when the role list is written down, reviewed, and matches the scopes the API enforces. Avoid a catch-all administrator role for machine clients, since a leaked credential would then carry every permission the API offers.

  3. Grant only the required roles to the machine user

    Create a grant from the machine user to the project and select only the roles this workload uses. The identity administrator performs the grant, and a second person should check it against the role list from the previous step. Confirm the grant appears on the machine user with the expected roles and nothing else. Note any role that is granted for convenience during testing and remove it before the credential is issued to production.

  4. Generate the chosen credential and store it securely

    Create the credential type you selected for this workload, such as a private key for JWT-based authentication or a client secret for client credentials, and download it once. Store it in your secrets manager or a platform secret store with restricted read access, not in source code, container images or chat tools. Record the key identifier or creation date so rotation can be tracked. The step is done when the secret is stored in the vault, only the workload's runtime identity can read it, and the file has been removed from the administrator's workstation.

  5. Configure the calling service to request tokens

    Set the token endpoint, client identifier, requested audience or scope, and credential source in the calling service's configuration. Load the key or secret from the secrets manager at startup rather than from a static file in the deployment image. The service should request tokens only for the target API and should cache them until shortly before expiry. The step is complete when the service obtains a token in a test environment and logs show no secret values.

  6. Verify the token audience and claims

    Decode the issued access token in a test environment, or use the introspection endpoint, and confirm that the audience matches the target API and that the roles claim lists only the roles granted in step three. Check the expiry and issuer against your Zitadel instance. Failing any of these checks means the project, grant or audience configuration needs correcting before the credential is used anywhere else.

  7. Prove that out-of-scope calls are denied

    Run a test call with the service token against an endpoint that requires a role the machine user does not hold, and confirm the API returns an authorization failure. Then run a call against an allowed endpoint and confirm it succeeds. Keep both results as evidence for your access review. This sequence is finished only when the permitted call succeeds, the denied call fails, and both outcomes are recorded alongside the role list and grant.

How a service account obtains a token and calls an API

The flow starts when an administrator creates a service account in Zitadel and grants it project roles, then the service stores its credential in a secret store outside Zitadel. At runtime the service presents its credential to the Zitadel token endpoint and receives an access token, which it sends to the protected API. The API validates the token against Zitadel before acting. Check that the trust boundary is respected: the private key or client secret should never leave the service runtime, and the admin's role grant should be the only path to new permissions.

Credentials stay inside the service runtime while Zitadel issues and the API checks tokens.

How to rotate keys and secrets without outages

Rotating a Zitadel service account credential is mostly a coordination problem: the new secret has to be accepted before the old one stops working, and every consumer has to be known. The cards below cover the sequence, the ownership and logging around it, and the checks that show a rotation worked.

Overlap old and new credentials

Plan rotation so that the old and new keys are both valid for a short window. Load the new private key or secret into the service first, confirm a successful token request with it, then retire the old one. Zitadel's machine user keys can be added before the old key is removed, so there is no moment when the service has no valid credential. Ask your team to write down the overlap window before the first rotation, and to confirm that each consumer can hold two credentials at once.

Zitadel APIs docs

Set rotation triggers and owners

Every service account needs a named owner and a defined trigger for rotation. Common triggers include a scheduled interval set by your policy, a staff change on the owning team, a failed security review, and a suspected exposure. Without an owner, keys tend to outlive the people who created them. Record the owner in the same place as the service account, and confirm who approves a rotation that affects production.

Revoke a compromised key quickly

When a private key or client secret may be exposed, revoke it first and rotate second. Remove the key from the machine user, then issue a new one and deploy it to the service. Expect a short outage for that service, since the compromised credential will fail immediately. Check whether any other service used the same key, because a shared credential widens the blast radius. Keep a runbook that names who can revoke keys, so the step does not wait for a meeting.

Map each service to its credential

Keep a register that links each Zitadel service account to the workload that uses it, the project roles it holds, the secret store location, and the date of the last rotation. Without this map, a rotation can break a service nobody remembered depended on the key. Generate the register from your deployment manifests where possible, and review it when services are added or retired.

Test rotation in staging first

Run the full rotation in a non-production Zitadel instance before touching production. Confirm that the new key issues tokens, that the calling service picks up the new secret without a restart if that is your design, and that the old key fails after retirement. Staging should mirror the production role grants and the token type each API expects, since a mismatch there is a common cause of failures that only appear after rotation.

Check logs after each rotation

After rotation, review Zitadel and API logs for failed token requests, unexpected authentication errors from old credentials, and requests from unfamiliar sources. Look for a spike in 401 or 403 responses from a single service, which often means a consumer still holds the old secret. Confirm that the audit trail records who performed the rotation. Set a short review window, and keep the evidence with the change record so auditors can see that rotation happened and was checked.

Where to store service account secrets in your environment

Choose the secret store before you generate the first service account key, because the store decides who can read the private key, how it is rotated and what your auditors can see. The main options are a dedicated secrets manager such as OpenBao, which can be run in the infrastructure you control and offers access policies, audit logging and rotation workflows. Kubernetes Secrets are the simplest fit for workloads already running in a cluster, but they are only as protected as the cluster's configuration, so confirm that encryption at rest for the Secrets resource is enabled, that RBAC limits who can read it, and that the API server audit log records reads. CI/CD variables are convenient for pipelines, but they are usually readable by anyone who can edit the pipeline and are often copied into logs or caches, so they suit short-lived or low-privilege credentials better than long-lived private keys.

A private key used for private key JWT must never be committed to source control, copied into container images or pasted into tickets and chat. Keep the key in the store, mount it into the one workload that needs it, and make sure each service account's key can be read only by the identity that runs that service. Match store access to the service's role: a service that only reads users should not be able to read the key of a service that creates them, and human administrators should be able to rotate keys without being able to read them in plain text. Record which store holds each key, who owns it and the date it was last rotated, so that revoking a compromised key does not depend on memory.

Confirm the chosen store against your own compliance and audit requirements before rollout, since the controls that matter depend on your framework, your data classification and your hosting model. Ask your auditor which evidence they expect for key storage, access reviews and rotation, and check that the store can produce it. This is a decision for your security and compliance teams, and DeployOpen can help plan and test the setup, but the acceptance of the store remains yours.

Security and operational risks to control

Service accounts often outlive the people who created them and run with more access than their job needs. The six risks below share one cause: credentials and automated calls that nobody watches closely, so each card names the control that keeps it visible and limited.

Secret leakage in logs and CI output

Client secrets, private keys and access tokens often end up in CI logs, debug output, shell history or container environment dumps. Once captured, a machine credential works for any caller until it is revoked. Check that pipelines mask secret variables, that application logging excludes the token and client assertion fields, and that private keys are loaded from a secrets store at runtime rather than committed to repositories or baked into images.

Zitadel APIs docs

Over-broad project roles

A service account granted a broad role in a project can read or change far more than the one API it calls. This is common when a machine user is given the same role as an administrator for convenience. Map each service account to the narrowest project role and grant that its workload needs, use separate machine users per service, and review grants when a workload changes. Confirm in your Zitadel version how roles and grants apply across organizations before you rely on them.

Long-lived personal access tokens

Personal access tokens do not expire on their own schedule in the way a short-lived access token does, so a token copied into a script or spreadsheet can remain valid long after its purpose ends. Set an expiration date on each token, record the owner and the workload that uses it, and list active tokens on a schedule. Prefer private key JWT or client credentials where the integration allows it, and reserve personal access tokens for narrow cases you can name.

Missing audit trail for automated calls

When many services share one identity, logs show a machine user but not which deployment, pipeline or code path made a change. Incident response then stalls at attribution. Give each service account a clear name tied to its workload, keep administrative and API events in a central log store with retention set by your policy, and alert on machine users performing actions outside their normal pattern. Confirm which audit events your Zitadel deployment records and how long they persist.

Token caching in relying parties

Resource servers that cache validated tokens or signing keys keep honoring a token after it should stop working, and a revoked service account may keep calling APIs until the cache expires. Set cache lifetimes shorter than the token lifetime, refresh the JSON Web Key Set when a token carries an unknown key identifier, and test that revocation takes effect within the window you have agreed. Ask each API team what their cache duration is.

Clock skew and key-set rotation failures

Token validation fails when the clocks of Zitadel and a relying service drift apart, and it also fails when a service has the old signing key while tokens are already signed with the new one. Both show up as sudden authentication errors after a rotation. Synchronize time on every node with a managed time service, keep the old and new keys published in the key set during the overlap, and rehearse rotation in a non-production instance before changing production keys.

Questions teams ask before setting up service accounts

Can our own team set up Zitadel service accounts without a partner?

Yes, many teams can, provided they already run the Zitadel instance and have someone who understands OAuth 2.0 client credentials and JWT signing. The work itself is configuration: creating machine users, choosing between private key JWT, client credentials or personal access tokens, granting project roles and wiring each service to its secret store. The harder part is consistency across services. Ask whether the team has an owner for key rotation, a naming convention for service accounts and a review step before a new grant is approved. If those are missing, a partner can help design them, but the decision stays with your team.

What makes a service account setup take more effort?

The main drivers are the number of services that need access, the complexity of the role model and what secret storage already exists. Each service adds a machine user, a key or secret, a grant and a rotation procedure. Role design adds effort when services need different permissions across several projects or organizations. Existing secret stores shorten the work if they can issue and rotate credentials, and lengthen it if secrets live in configuration files or CI variables that must be migrated. Compliance evidence adds effort because each control needs a documented owner, a record of who approved access and proof that keys rotate on schedule.

What do we need to provide from our internal staff?

Expect to provide a named owner for the Zitadel instance, a list of the services and APIs that need machine access, and the people who approve access to each project. Your platform or security team should supply the secret store you intend to use, the network paths between services and Zitadel, and the environments that need separate service accounts, such as development, staging and production. Engineers who own each service must confirm which scopes and roles it really requires. Without these inputs, the work tends to stall at the design stage, because every grant depends on an approved answer to who needs what.

How long does it take before service accounts are safe to rely on?

No fixed duration applies, because the answer depends on the factors above. A small set of services with one project and an existing secret store can be configured and tested quickly. A multi-tenant design with many services, custom role models and new secret infrastructure takes longer, mainly because of design decisions and testing. Safe reliance also requires verification: confirming that tokens are issued only for the intended client, that revoked or expired keys are rejected, and that rotation works without downtime. Ask any provider to break the timeline into design, build, verification and handover, and to state which of those steps depend on your team's availability.

How is a quote built for service account work?

A quote follows from a written scope. DeployOpen agrees on the scope, deliverables and timeline in writing before work starts, so the quote should list the services in scope, the flows and credential types to configure, the role model to design, the secret store integration, the verification steps and the handover documentation. Ask whether the quote includes rotation runbooks and testing of revocation, and whether ongoing support or retesting is separate. Cost moves with the number of services, the number of environments and how much design work is needed before any configuration begins. Ask for the assumptions behind each line so you can see what changes if the scope grows.

How do service accounts differ from user login flows?

A user login flow involves a person who authenticates in a browser or app and receives tokens on their behalf, usually with authorization code and PKCE. A service account authenticates as a non-human identity, so no person signs in and no consent screen appears. The service presents its own credential, such as a private key signed JWT or a client secret, and receives a token that represents the service. This means credentials must be stored and rotated by machines and teams, not by users. Permissions are granted to the service itself, so a compromised key exposes the service's rights rather than a person's session, which is why least-privilege roles and rotation matter more here.

Where should machine credentials be stored and who should see them?

Store private keys and client secrets in a dedicated secret manager or a hardware-backed store, not in source code, container images or shared chat. Limit read access to the specific service that needs each credential, and log every retrieval. Only a small operations group should be able to create or revoke machine credentials. Confirm with your security team which secret manager is approved, how it authenticates workloads and how rotation is triggered. The exact supported options depend on your Zitadel version and your platform, so verify them against the Zitadel documentation for the version you run before you commit to a design.

How DeployOpen scopes and delivers Zitadel service account work

DeployOpen plans, builds, documents and supports Zitadel service accounts for machine-to-machine access inside your own infrastructure. Each engagement starts from a written scope that names the services, the Zitadel instance and organization, the authentication method for each caller, and the roles each one needs. The work is then built, tested and handed over so your team can run it.

How we scope

  • We inventory every service, job and script that calls Zitadel or a Zitadel-protected API today.
  • We record which authentication method each caller will use, such as private key JWT or client credentials, with the reason for each choice.
  • The written scope lists the instance, organizations, projects, roles and grants to be created, and who approves them.

How we build

  • We create one service account per workload, with the narrowest project roles and grants that workload needs.
  • We set up key generation, storage in your secrets manager and a documented rotation procedure before any service goes live.
  • We test token issuance, audience checks, denied-scope requests and failed key rotation in a staging environment before production cutover.

How we hand over

  • You receive a service account register listing each account, its owner, its roles and its key rotation schedule.
  • Runbooks cover adding a new service account, rotating or revoking a key, and responding to a suspected credential leak.
  • Your team walks through the configuration with us and confirms it can perform each procedure without DeployOpen present.

How we support

  • Engagements are fixed-scope, so changes to services or roles are agreed in writing before they are made.
  • Ongoing support, upgrades and continuous testing of Zitadel are available as a retainer.
  • Where your Zitadel version changes, we can plan and test the effect on existing service account tokens and keys before upgrading.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.