Docs

Configuration as code

How your project's auth configuration lives in repo files, is deployed as a release, and becomes revisions.

Configuration as code means your project's auth configuration lives in files in your repository. Repo files describe configuration; server APIs own runtime resources. Your project's user schemas, login flows, branding, sign-in connections, and the switch for its OAuth authorization server are files you review like code. zitadel deploy publishes them to the project as a release, an immutable snapshot of those files. The deploy guide walks through a change, and Releases and deployments explains releases, deployments and rollback.

What the CLI writes

  • zitadel.json
  • .zitadel/**
  • framework-specific app files
  • .env.example, the environment template to commit
  • .env.local, with the project's real values, including the project secret
  • .env.development.local, the values the CLI reads: the server, the project and its credentials

What stays out of source control

Commit zitadel.json and .zitadel/**, except:

  • .env.local and .zitadel/secret, which hold the project secret;
  • .zitadel/local/**, the local runtime's data.

Setup adds .zitadel/secret and .env* (all but .env.example) to .gitignore, and start adds .zitadel/local/.

Variables

Some values do not belong in your repository: secrets, and values that differ between production and previews. Store them on the project as variables, and reference them from configuration as ${{ NAME }}. Today an identity provider connection's oidc.client_id and oidc.client_secret take one. Set a value with zitadel variable set NAME <value>. For a secret, run zitadel variable set NAME --secret: it prompts for the value and stores it encrypted, so it is never read back.

A variable can hold a separate value for previews (--preview), so a preview never runs with a production secret. Each deployment keeps the values it was created with: a changed variable reaches users on the next zitadel deploy, or the next zitadel preview for a preview value, and a rollback brings back the old values.

Environments

Your app can run against more than one environment, such as development on the local runtime and production on a hosted server. Give each environment its own project, on a local or remote server. Separate projects never share users, sessions or any other data. What they share is your configuration: you deploy the same .zitadel/ files to each of them.

The CLI keeps each environment's server and project in .env.<name>.local. zitadel env add <name> binds an environment, creating a project for it if needed, and zitadel env list shows the ones this directory has. A command picks the environment from --env, then ZITADEL_ENV, then the hosting platform (VERCEL_ENV, or Netlify's CONTEXT), and uses development otherwise. zitadel env shows which server and project resolved.

A preview is not an environment. It runs on a URL of an existing project and shares that project's data (Origins and previews).

What deploy checks

zitadel deploy --dry-run validates local configuration and shows what would change without mutating files or platform state. zitadel deploy builds a release from it and makes the release live. How publishing works covers the rest of the process. These are the checks that fail a deploy before it uploads anything:

  • Flows are validated at deploy time against the same rules the platform enforces: transition wiring, step reachability, schema field references, and cross-purpose invariants. For example, a purpose switch must go to a purpose the flow serves. A violation fails deploy before anything is uploaded, with the same error text the server would return. Non-blocking product guidance shows up as warnings that name the file.

  • Sign-in connections are checked across files at deploy time. A connection file, .zitadel/idps/<slug>.json, configures one external identity provider (social sign-in). deploy reads your user schemas, login flows and connection files together. It stops, before it changes anything, when they disagree. One E_VALIDATION, "Configuration validation failed", names every problem with the file, the step and the name at fault; with --json, details.issues lists each as {rule, path, steps?, message}. deploy stops on any of these:

    • a step offers a provider its schema does not list (or SSO is off);
    • a schema lists a provider with no connection file;
    • a step offers providers without routing every outcome (a user_already_exists route that carries an action does not count);
    • a claim mapping fills nothing the schema defines;
    • a verified_claims key has no claim_mapping row;
    • a mapping or verified_claims key names a property no schema has (a top-level property name, not a dotted path);
    • two connection files share a slug or a project variable, which is checked across all of them.
  • A connection's oidc block names no endpoint, or every one it needs. With none, the endpoints come from the issuer's discovery document. Otherwise it names authorization_endpoint, jwks_uri, token_endpoint, and userinfo_endpoint unless id_token_mapping is true. The server refuses a block in between (idp.endpoints_partial), so deploy refuses it first with E_VALIDATION, naming the file and the missing endpoints, and a deploy never stops part-way.

  • Connection files are also checked against the platform, and that check is never skipped. When a client_id or client_secret names a project variable, it must exist (E_CREDENTIAL_MISSING when it does not). The id must be a plain variable and the secret a secret one, and one variable may not serve both (E_VALIDATION). The slug, protocol, oidc.issuer, and subject_claim (an absent one reads as sub) of a connection that was deployed cannot be edited (E_VALIDATION). If the platform cannot be read, the deploy stops instead of skipping them.

  • Application files are checked before anything is uploaded. An application file, .zitadel/applications/<slug>.json, declares one of your applications and its OAuth clients; .zitadel/meta/application.json describes its shape, so an editor catches a misspelled key but not a missing client_id or secret. deploy sends every file with the release and shows an added, changed or removed file in its diff. It stops with E_VALIDATION when:

    • a file breaks the schema;
    • a client has no client_id;
    • a confidential client does not name its secret as a ${{ NAME }} project variable;
    • two files share a slug, or two clients share a client_id;
    • a client's secret variable is one another client or a connection names.

    It also stops when a client's secret variable is not on the project (E_CREDENTIAL_MISSING) or is not a secret (E_VALIDATION).

Revisions

  • Schemas and flows are revisioned: an edit publishes a new immutable revision instead of mutating the old one. Existing users keep validating against the schema revision they were created with. A login that names a flow runs the revision of it the deployed release pins.
  • Flows name their schema by its objectType in user_schema and run against the revision the deployed release pins, so a schema edit needs no change to user_schema and reaches sign-in with the next deploy. If the edit removes or renames a property a step collects, update that step's fields: deploy only checks the flows it publishes. Flows and schemas explains the relationship.
  • Flow files carry "$schema": "../meta/flow-definition.json", a pointer at the flow dialect spec setup copies into .zitadel/meta/, so editors validate and autocomplete flow edits offline. It is local-only: the platform ignores it, and a deploy never treats it as a change.

Was this helpful?