Docs

Publish a flow definition

POST
/flow_definitions

Publishes a new revision of a flow definition, creating the flow definition on its first publish. It records a flowdef.created event.

A flow definition is a template that defines the sequence of steps (capabilities) for one user journey, such as registration, login or password reset. The body follows the flow definition schema, which includes the flow's purpose, audience and steps.

Every call allocates a new opaque ID. That id is the revision_id a release pins for kind: flow_definition.

Revisions of one flow share its name. Posting a definition under an existing name publishes a new revision of that flow, which is not a conflict. List with name to see a flow's revisions, newest by creation time first.

Authorization

oauth2 flow_definition.write
headerAuthorizationBearer <token>

Scope: flow_definition.write

Request Body

application/json
  1. body

The request body for creating a flow definition.

project_id*project-id
Match^[a-zA-Z0-9_-]+$
schema_uri?schema-uri

The URI of the server-published flow definition schema this definition was authored against. The server validates the definition against it. If you omit it, the server uses the latest schema version.

Formaturi
flow_definition*

A flow definition is the configuration of one flow: the sequence of screens the login component (<zitadel-login>) walks a user through to sign in, register, recover access or similar. Each screen is a step. A step collects fields (inputs taken from properties of the user schema), offers actions (what the user can do, such as submit the form or follow a link) and may require gates (security checks, such as a captcha, that must pass before the server accepts the submission). Transitions say which step follows each action.

The definition is server-side configuration and is never sent to the frontend. The server evaluates it and returns the current step, with its fields, actions and gates, to the client.

Administrators create flow definitions, either as .zitadel/flows/ files that zitadel deploy publishes or through the API, and they are stored in the project/team configuration hierarchy. The server selects the matching definition from the purpose and audience when a flow starts with createFlow (POST /flows).

Response Body

The created flow definition.

application/json
  1. response
id*string

The ID of the flow definition.

project_id*string

The ID of the project this flow definition belongs to.

flow_definition*

A flow definition is the configuration of one flow: the sequence of screens the login component (<zitadel-login>) walks a user through to sign in, register, recover access or similar. Each screen is a step. A step collects fields (inputs taken from properties of the user schema), offers actions (what the user can do, such as submit the form or follow a link) and may require gates (security checks, such as a captcha, that must pass before the server accepts the submission). Transitions say which step follows each action.

The definition is server-side configuration and is never sent to the frontend. The server evaluates it and returns the current step, with its fields, actions and gates, to the client.

Administrators create flow definitions, either as .zitadel/flows/ files that zitadel deploy publishes or through the API, and they are stored in the project/team configuration hierarchy. The server selects the matching definition from the purpose and audience when a flow starts with createFlow (POST /flows).

user_schema?|

The user schema this flow operates on: the same object getSchema (GET /schemas/{schema_id}) returns. Present only when the request asked for it with expand=user_schema; null when it was requested but the referenced schema no longer resolves or the caller may not read it.

created_at*string

When the flow definition was created.

Formatdate-time
updated_at*string

When the flow definition was last updated.

Formatdate-time
import { createZitadelApi, ZitadelClient } from "@zitadel/api/client";const api = createZitadelApi(  new ZitadelClient({    baseUrl: process.env.ZITADEL_URL ?? "http://localhost:8080",    token: process.env.ZITADEL_PROJECT_SECRET!, // server-side only  }),);const flowDefinition = await api.publishFlowDefinition({  project_id: "${PROJECT_ID}",  schema_uri: "https://zitadel.com/schemas/v1/flow-definition.json",  flow_definition: {    name: "default-login",    user_schema: "human-user",    purposes: { login: "identifier", register: "register" },    steps: [      {        name: "identifier",        fields: ["email"],        actions: [          {            name: "submit",            kind: "submit",            primary: true,            text_key: "identifier.action.continue",          },          {            name: "passkey",            kind: "passkey",            primary: false,            text_key: "identifier.action.passkey",          },        ],        transitions: {          submit: { target: "password" },          passkey: { target: "done" },          user_not_found: { target: "register" },        },      },      {        name: "password",        fields: ["x-auth-methods#password"],        actions: [          {            name: "submit",            kind: "submit",            primary: true,            text_key: "password.action.signin",          },          {            name: "passkey",            kind: "passkey",            primary: false,            text_key: "password.action.passkey",          },        ],        transitions: {          submit: { target: "done" },          passkey: { target: "done" },        },      },      {        name: "register",        fields: ["email", "givenName", "familyName", "dateOfBirth"],        actions: [          {            name: "submit",            kind: "submit",            primary: true,            text_key: "register.action.password",          },          {            name: "passkey_register",            kind: "passkey_register",            primary: false,            text_key: "register.action.passkey",          },        ],        transitions: {          submit: { target: "register-password" },          passkey_register: { target: "done" },          user_already_exists: { target: "password" },        },      },      {        name: "register-password",        fields: ["x-auth-methods#password"],        actions: [          {            name: "submit",            kind: "submit",            primary: true,            text_key: "register-password.action.submit",          },        ],        on_success: "create_user",        transitions: {          submit: { target: "done" },          user_already_exists: { target: "password" },        },      },      { name: "done", complete: "show" },    ],  },});
Example Response
{  "id": "string",  "project_id": "string",  "flow_definition": {    "$schema": "string",    "name": "standard-login",    "user_schema": "string",    "purposes": {      "property1": "string",      "property2": "string"    },    "audience": {      "team_ids": [        "string"      ],      "app_ids": [        "string"      ]    },    "steps": [      {        "name": "string",        "fields": [],        "actions": [],        "gates": {},        "sso_providers": [],        "on_success": "create_user",        "complete": "redirect",        "transitions": {          "property1": {            "target": "string",            "action": "switch",            "purpose": "login"          },          "property2": {            "target": "string",            "action": "switch",            "purpose": "login"          }        }      }    ]  },  "user_schema": {    "id": "string",    "schema": {      "$schema": "https://json-schema.org/draft/2020-12/schema",      "objectType": "string",      "kind": "user-schema",      "metaSchema": "http://example.com",      "x-auth-methods": {        "password": {          "enabled": true        },        "passkey": {          "enabled": true        },        "magic_link": {          "enabled": true        },        "sso": {          "providers": [            "google"          ],          "enabled": true        },        "otp": {          "enabled": true        }      },      "x-identifier": "string",      "x-display": [        "string"      ],      "properties": {        "property1": {          "x-unique": "unspecified",          "x-claim": "string",          "x-audit": false,          "properties": {            "property1": {},            "property2": {}          }        },        "property2": {          "x-unique": "unspecified",          "x-claim": "string",          "x-audit": false,          "properties": {            "property1": {},            "property2": {}          }        }      }    },    "metadata": {      "created_at": "2019-08-24T14:15:22Z",      "in_use": true    }  },  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}

Was this helpful?