Protecting backend APIs with Zitadel token introspection

Validating Zitadel access tokens in your APIs means choosing between introspection for opaque tokens and local JWT validation with web keys, then checking audience and roles on every request. This page explains the trade-offs, the setup sequence and what to confirm in your environment.

On this page

How backend APIs validate Zitadel access tokens with introspection

An API has to decide, for every request, whether the caller's access token is valid, has not been revoked and was issued for this API. Token introspection answers that question by having the API send the token to the authorization server and receive a verdict, so the API does not have to interpret the token itself. In Zitadel, which implements OpenID Connect and OAuth 2.0 as described in its APIs introduction, introspection is the usual choice when an application is configured to issue opaque access tokens. The API calls the introspection endpoint of the Zitadel instance with its own client credentials, and Zitadel returns whether the token is active along with claims such as the subject, scopes and audience.

Teams choose introspection over local JWT validation when they need revocation to take effect immediately, when tokens must reveal little if they leak, or when the API should not hold signing keys or track key rotation. The trade-off is a network call to the identity provider on each validation, or on each cache miss if results are cached, so latency and availability of the Zitadel instance become part of the API's own availability. Local validation with web keys removes that dependency but accepts that a token stays valid until it expires. Decide per application, and confirm which token type the client application is configured to receive before writing the API's validation code.

Because this setup is self-hosted, the introspection endpoint, the database behind it and the TLS certificates belong to your infrastructure. Plan the API's path to the Zitadel domain, the trust chain for that domain and the credentials the API uses to call introspection as internal dependencies with owners and rotation procedures. Confirm the exact endpoint paths and client authentication methods (basic authentication or private key JWT) against the Zitadel documentation for your version, since the choice affects how secrets or keys are stored in the API's deployment.

How a request to your API is validated against Zitadel

The request starts when a client sends an access token to your API. The API then takes one of two paths: it calls the Zitadel introspection endpoint with its own client credentials, or it validates the JWT locally using web keys it has cached. Either way, the API checks the audience, the roles and the expiry before it serves the request. The trust boundary sits between your API and Zitadel, so you decide which validation path to trust and how long cached keys and results live.

Two validation paths for an API request, with the trust boundary to Zitadel and the cache layer marked.

Introspection, private key JWT and local JWT validation compared

This table compares the three ways a backend API can validate a Zitadel access token: introspection with basic auth, introspection with private key JWT, and local JWT validation against web keys. Read each row as a trade-off: the first two accept revocation at the cost of a network call, while local validation is fast but only as current as the keys and token lifetime allow.

FactorIntrospection with basic authIntrospection with private key JWTLocal JWT validation with web keys
Token type requiredOpaque access tokenOpaque access tokenJWT access token
Where the check happensZitadel answers each requestZitadel answers each requestAPI verifies signature locally
Revocation takes effectOn the next introspection callOn the next introspection callOnly at token expiry unless you add checks
Network dependency on ZitadelEvery uncached validationEvery uncached validationOnly to fetch and refresh keys
Client secret handlingShared secret stored on the APISigning key pair held by the APINo API credential needed for validation
Effect of key rotationNot applicable to the checkRotate the client key pair in stepRotate web keys; cache refresh must follow
Caching riskCached results can outlive revocationCached results can outlive revocationStale key sets can reject valid tokens
Best fitInternal APIs with few callers and a need for fast revocationStricter environments that avoid shared secretsHigh-volume APIs where latency matters more than instant revocation

Setting up token validation in an API step by step

This sequence takes an API from unprotected to validating Zitadel access tokens for signature or status, audience, roles and expiry, with bounded caching and tests that prove each rejection path works. Each step ends with a check you can run before moving on.

  1. Register the API as a resource in a project

    In the Zitadel console, create or select the project that owns the API, then add the API as an application of type API so Zitadel issues tokens with the API's identifier as an audience. The API owner or platform team does this, and the Zitadel administrator who controls the organization should approve the project structure. Confirm the audience value by requesting a test token from a client that has been granted access and decoding it, or by checking the introspection response, and record that exact string in your API configuration. Done means the audience in a real token matches the value your API will enforce.

  2. Set the access token type on the client

    Decide whether the calling application receives opaque tokens or JWTs, and set that on the client application in Zitadel. Opaque tokens require introspection on every call and support immediate revocation, while JWTs can be checked offline with the public keys. The application team makes this choice with the API team, because it determines which validation path the API must implement. Confirm the setting by requesting a token from the client and checking whether the value is a JWT with three dot-separated segments or an opaque string. Done means both teams agree on the token type in writing.

  3. Choose the validation method

    Select introspection for opaque tokens, or local JWT validation against the JWKS for JWT access tokens. Introspection calls the Zitadel introspection endpoint on each request or cache miss, which adds network latency and a dependency on Zitadel availability, but it reflects revocation and current status. Local validation keeps the API independent of a per-request call but accepts a token until it expires. Document the choice and the failure behavior if Zitadel is unreachable, since a fail-closed setting is the usual default for protected data. Done means the chosen method and its failure mode are written down and the API team has signed off.

  4. Configure introspection credentials or JWKS access

    For introspection, create a dedicated API client in Zitadel with the introspection-capable credentials, using basic authentication or private key JWT, and store the secret or private key in your secrets manager, not in source code. For local validation, configure the JWKS URL from your Zitadel instance and confirm your library refreshes keys when it sees an unknown key identifier. Restrict the API client to the minimum needed and plan rotation with the signing key lifecycle. Check the setup by calling introspection with a known valid token and confirming an active response with the expected audience. Done means the API can authenticate to Zitadel or fetch keys from a non-production environment.

  5. Implement audience and role checks

    After the signature or introspection result is accepted, verify the audience contains this API's identifier, the issuer matches your Zitadel instance URL, and the token has not expired. Then check the project roles or scopes the endpoint requires, reading them from the claims your configuration returns. Keep authorization decisions in the API code, deny by default, and map each endpoint to a required role. Administrator roles are often not in the access token, so confirm which role claims your project settings produce before relying on them. Done means a token missing the audience or a required role receives a 401 or 403 with no business logic executed.

  6. Add caching with a bounded lifetime

    For opaque tokens, cache successful introspection results keyed by a hash of the token, and set the cache lifetime to no longer than the token's remaining validity and a ceiling your security team approves. Cache negative results only briefly, if at all. For JWTs, cache the JWKS and refresh it on unknown key identifiers rather than on every request. Revocation becomes visible only after the cache entry expires, so the chosen ceiling is a risk decision to document. Test by revoking a token and confirming rejection after the cache window. Done means cache behavior, its maximum age and the revocation delay are recorded and tested.

  7. Test valid, expired, revoked and wrong-audience tokens

    Build an automated test suite that sends four token types to the API: a valid token, an expired token, a revoked token and a token issued for a different audience. The valid token should succeed for an authorized role, while the other three should fail with the expected status codes and no data returned. Also include a token missing the required role and a request with the Zitadel endpoint unreachable to confirm the fail-closed behavior. Run the suite in a non-production environment and keep it in the pipeline so future changes cannot silently weaken validation. Done means every case produces the expected result and the suite passes on each build.

Checking audience and roles so tokens work only where they belong

A valid signature or an active status does not tell an API that a token was meant for it. An API that accepts any token Zitadel issued for any application in the same instance will let a token minted for a front-end client or another API reach its endpoints. Your API should confirm that the audience in the token matches its own identifier, the value registered for it as an API resource in the project. Treat this as a separate check that runs after introspection or local JWT validation, and test it with a token issued for a different API to confirm it is rejected. Verify the exact claim names and how audience values are populated in your instance's token output, since these depend on the token type and project settings you chose.

Zitadel groups applications, roles and grants inside projects, and projects live inside organizations within an instance. A role your API enforces, such as a read or approve permission, is defined in a project and reaches a user only through a grant that assigns it to that user or to a user in a granted organization. Before you write authorization rules, map each endpoint to the project role it needs, then check in the Zitadel documentation for organizations and projects how roles and grants appear in tokens for your configuration. Confirm which scopes and project settings cause role claims to be included, because a token without the expected roles will fail closed in a correct API.

Administrator permissions are a special case. Instance and organization administrator roles may not appear as claims in the access token your application receives, so an API that depends on them should not assume they are present. Plan for an explicit call to Zitadel's management APIs, made with a service account that has least-privilege access, when an operation needs to confirm administrative rights. Document which endpoints need this lookup, add caching with short lifetimes, and test the behavior with a non-administrator user. Verify the relevant API methods and required permissions against the Zitadel APIs introduction and your own instance before you rely on them.

Security risks to design out when APIs validate tokens

Most failures in API token validation come from a few habits: hard-coded secrets, careless caching, loose audience checks, unverified JWTs, silent fallbacks and noisy logs. Each card below names one risk and the control that prevents it, so the review of your introspection or local validation design has a concrete checklist to work from.

Introspection secrets in code

The introspection call authenticates the API to Zitadel with a client identifier and secret, or with a private key JWT. If those credentials are committed to source code or baked into container images, anyone with repository access can call the introspection endpoint as your API. Load the credential at runtime from a secrets manager or a mounted file with restricted permissions, and give each API its own client so you can rotate or revoke one without touching the others. Check the repository history, not only the current tree.

Zitadel APIs introduction

Caching tokens beyond lifetime

A cached introspection result is only trustworthy until the token expires or is revoked. If your cache entry outlives the token's exp value, the API keeps accepting a token Zitadel has already rejected. Set the cache time to the smaller of a short fixed ceiling and the remaining token lifetime, and key entries by a hash of the token rather than the raw token. Confirm with your team how quickly a revoked token must stop working, because that number sets the ceiling.

Accepting the wrong audience

A valid token issued for a different API in the same Zitadel instance is still a valid signature. If your API does not check the aud claim, a token meant for a reporting service or a partner API can be replayed against your endpoints. Require that the audience contains your API's identifier, and check it in both introspection and local JWT validation. For illustrative purposes, an API named orders-api should reject a token whose audience lists only billing-api, even when the signature verifies.

Skipping JWT signature and algorithm checks

When an API validates JWTs locally, it must verify the signature against the signing keys published by Zitadel, check the issuer, and pin the accepted algorithms to the set your team chose. Decoding a token and reading its claims without verifying the signature is a common shortcut that makes forged tokens acceptable. Fetch keys from the JWKS endpoint of the configured issuer, reject the none algorithm, and confirm which algorithms your validation library accepts by default.

Failing open when Zitadel is unreachable

If introspection times out and the API treats the result as valid, an outage at the identity provider becomes an authentication bypass. Make the default on error a denial, return a clear status such as 503 for the caller to retry, and alert on the rate of introspection failures. Where you use a cache, decide in advance whether a stale entry may be used during an outage, and limit that window in writing. Test this path by blocking the Zitadel endpoint from the API network.

Leaking token contents into logs

Access tokens, introspection request bodies and bearer headers written to logs or traces let anyone with log access replay a live credential. Configure the API's logging and tracing to drop the Authorization header and token parameters, log the subject, audience and token identifier instead, and restrict who can read the log store. Review your OpenTelemetry or reverse proxy access log settings, since they often capture headers by default.

Questions teams ask before validating Zitadel tokens in their APIs

What drives the cost and effort of validating Zitadel tokens in an API?

The effort depends mostly on how many APIs must validate tokens, how many token types and clients are involved, and how much of the setup is already standardized. Each API needs a validation method chosen and implemented, whether that is introspection with basic auth or private key JWT for opaque tokens, or local JWT validation against web keys. Teams should ask for the work to be split into the Zitadel application and client configuration, the API middleware changes, the caching and failure behavior, and the test suite. Ongoing costs come from maintaining that middleware across languages and frameworks, and from reviewing it whenever a new API or token type is added. Ask any partner to price each API and each token type separately in the written scope.

How long does it take to get Zitadel token validation working across our APIs?

Duration depends on the number of APIs, whether they share one validation library, and how many teams own them. A single API with one token type is usually a smaller task than a fleet of services in several languages, each needing its own audience and role checks. Time is also spent on decisions that block the build, such as which access token type each application uses and where the introspection credentials are stored. No duration is fixed here; ask for a timeline in the written scope that lists the APIs, the token types and the environments, including staging and production, that must be tested before release.

What does our team need to provide for this work?

Three groups need to be involved. Identity administrators must confirm the Zitadel project, application and access token type for each API client, and must provide or create the introspection credentials. API owners must name the audience value each API expects, the roles that gate each endpoint, and the failure behavior they want when Zitadel is unreachable. Security reviewers should approve how credentials are stored, how long introspection results are cached, and which tokens are accepted. Agreeing these answers before the build starts prevents most rework.

Can our own engineers validate Zitadel tokens without a partner?

Yes, many teams can do this in-house if they already run identity-aware APIs and have engineers who understand OAuth 2.0 and OpenID Connect. The skills that matter most are token format and signature checking, audience and issuer validation, role claim handling, and safe caching. The risk is usually in the edge cases: accepting tokens intended for another API, caching a revoked token too long, or failing open when the introspection endpoint times out. A partner review or a security test of the finished validation layer can close those gaps. Decide based on whether your team has done this before and whether it will maintain the code over time.

Should our APIs use introspection or local JWT validation?

Introspection suits APIs that need revocation to take effect quickly, because each request asks Zitadel whether the opaque token is still active, at the cost of a network call per request unless results are cached. Local JWT validation suits latency-sensitive APIs, because the API checks the signature against the web keys and reads the claims without calling Zitadel. The trade-off is that a JWT stays valid until it expires, so short lifetimes matter more. Many teams use local validation for most traffic and introspection for sensitive operations. Measure the latency of your own endpoints and set your revocation requirement before choosing.

How does key rotation affect token validation in our APIs?

Key rotation affects only APIs that validate JWTs locally, because they depend on the public keys published by Zitadel to check signatures. When Zitadel rotates its web keys, the API must fetch the updated key set and handle tokens signed with the new key, which normally requires that the JWKS cache refreshes on an unknown key identifier. An API that caches keys too long can reject valid tokens after rotation, while one that refreshes too aggressively can add load. Introspection avoids this dependency because Zitadel evaluates the token directly. Test a rotation in staging before the production change, and confirm your library's key refresh behavior with the vendor documentation.

Running token validation after go-live

Once the API validates Zitadel tokens in production, the validation path needs the same monitoring as any other dependency. Track the rate of rejected tokens by reason (expired, wrong audience, missing role, unknown key, introspection error), because a sudden rise in one category usually points to a specific cause such as a client sending the wrong audience or a rotated key the API has not picked up. Measure introspection latency at the API and separately at the cache, and set alerts on the tail, not the average. Record the introspection client ID and its authentication method in the logs so a failing credential can be traced without guessing.

Credential and key rotation should be rehearsed before it is needed. For introspection, plan to add a second API client secret or key, roll the API configuration to it, confirm successful introspection calls, and only then retire the old credential. For local JWT validation, Zitadel web keys can be rotated, but relying parties must refresh their JWKS to pick up the new key, so confirm how often your validator refreshes keys and what it does when it meets an unknown kid. Write these steps into a runbook and test them in a non-production instance first.

Every Zitadel upgrade should trigger a validation test, not just a platform smoke test. Current self-hosted Zitadel is typically run on Kubernetes with the official Helm chart, or another documented method, and the PostgreSQL database must be on a supported version (14 through 18, per the Zitadel documentation). Before upgrading, confirm the target release in the zitadel/zitadel releases on GitHub page, then run a fixed set of positive and negative test tokens against staging: valid, expired, wrong audience, missing role, and revoked. Document the cache lifetime, the JWKS refresh interval and the introspection failure behavior (fail closed or serve from cache) in the service's operations notes so on-call engineers know what a failure looks like.

How DeployOpen scopes token validation work

DeployOpen plans and implements API token validation inside your own infrastructure, so the resource servers, the Zitadel instance and the network paths between them stay under your control. Before any work starts, the scope, deliverables and timeline are agreed in writing. For this topic, that scope usually starts with an inventory of which APIs receive which token types, which Zitadel projects and applications issue those tokens, and which team owns each resource server. Those answers decide whether the work centers on introspection with basic auth or private key JWT, on local JWT validation against web keys, or on a mix of both.

The written scope should name each decision it covers: the token type per application, the introspection client and its authentication method, the JWKS caching behavior for local validation, and the audience and role checks each API enforces. It should also state what is out of scope, such as changes to the identity provider's login flows, application front ends or upstream gateway policy. Ask for the exact list of APIs and clients, the Zitadel environment each one talks to, and the test cases that will prove a token from one organization cannot reach another organization's API. A quote should follow from that list, not from a generic API count.

Deliverables typically include the validation configuration for each API, the service account or client setup used for introspection, a test suite covering valid, expired, wrong-audience and wrong-role tokens, runbooks for key rotation and cache flushes, and a handover session for the engineers who will maintain the code. Confirm with DeployOpen during scoping which of these artifacts you will own outright and which need your platform team's review before sign-off. Anything not written into the agreed scope should be treated as a change request, with its own written estimate before the work proceeds.

How DeployOpen works on this

DeployOpen scopes, builds, tests and hands over API token validation for Zitadel inside your own infrastructure. The work starts from your API inventory and token types, so each backend gets a validation path that matches its audience, roles and latency needs. Every step is documented so your own engineers can operate the result.

How we scope

  • Inventory each backend API, its clients, and whether it receives opaque or JWT access tokens from Zitadel
  • Agree in writing which validation path applies per API: introspection with basic auth or private key JWT, or local JWT checks against web keys
  • Define required audience values, project roles, and the behavior expected when Zitadel or the introspection endpoint is unreachable
  • Fixed-scope engagements set deliverables and timelines in writing before work starts, and ongoing support is available as a retainer

How we build

  • Configure introspection clients with the chosen authentication method and store their secrets in your approved secrets store
  • Implement token validation middleware in your API stack, including issuer, audience, expiry and role checks
  • Set cache lifetimes for introspection results and JWKS retrieval, and test how revoked tokens are handled during the cache window
  • Test invalid, expired, wrong-audience and under-privileged tokens against each API, and document the results

How we hand over

  • Deliver the validation configuration, middleware code, and cache settings as versioned artifacts in your repositories
  • Provide runbooks for key rotation, client secret rotation, and investigating validation failures in production
  • Walk your engineers through the audience and role model so future APIs follow the same pattern
  • Document open decisions, such as token lifetime and revocation expectations, for your security team to confirm

How we support

  • Retest validation behavior after Zitadel upgrades or changes to signing keys and token types
  • Review new APIs against the agreed validation pattern before they go into production
  • Offer ongoing support, upgrades and continuous testing through a retainer agreed in writing
  • Confirm with your Zitadel version and release notes whether any token or key behavior changes affect your validation code

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.