Publish a schema
Publishes a user schema, the JSON Schema that says which attributes a user has and which attribute identifies the user.
The request is either a user schema (kind: user-schema) or a schema URL
(kind: schema-url) that the server resolves. The response is the stored
schema, as getSchema (GET /schemas/{schema_id}) returns it; its id is
what createUser (POST /users) takes as schema.
The optional $id is the JSON Schema document URI that identifies the
schema in later requests. It is a stable identity for GitOps, not a
free-form resource key. When $id is omitted, the server generates a
sch_* URL. When provided, $id must be unique within the project and
should ideally be a valid URI pointing at where the schema can be accessed.
A $id that already exists in the project is refused; pick another or
omit it.
oauth2 schema.writeAuthorizationBearer <token>Scope: schema.write
project_id*stringThe project ID: the id that createProject (POST /projects) returns. zitadel setup prints
it as "Project id" in its summary and as project_id with --json, and
writes it to .env.local as ZITADEL_PROJECT_ID.
^[a-zA-Z0-9_-]+$team_id?stringThe team ID: the id that createTeam (POST /teams) or queryTeams (POST /teams/query) returns.
^[a-zA-Z0-9_-]+$application/json- body
The meta-schema that a user schema document is validated against. A user schema is the JSON Schema that says which attributes a user has, and which attribute identifies the user.
$schema?stringThe JSON Schema version used for this schema.
objectType*stringThe type of user this schema describes. This is a customer-chosen name.
Every revision of a schema shares its objectType, and flow
definitions name the schema they operate on by it.
length <= 256kind*stringMust be user-schema. It selects this schema type in a create request.
metaSchema*stringThe URI of the user meta-schema version this schema uses.
urilength <= 1024x-auth-methods*The authentication methods users of this schema can use, one entry per method. At least one is required.
1 <= propertiesx-identifier?stringPath of the leaf property whose value identifies a user. Nested leaves
are addressed by their dot-joined attribute path. The property must carry
x-unique "project".
Required when an authentication method that needs identifier-first dispatch (password) is enabled. Passkey is exempt: discoverable credentials identify the user through the assertion itself, so passkey-only and API-managed schemas may designate nothing. Flows using identifier-first passkey are validated at the flow level instead.
1 <= lengthx-display?array<>Ordered leaf property paths whose values, joined with a space, render the user's display name.
1 <= itemsproperties?The user's attributes, as a map. The key is the attribute name and the value is that attribute's schema.
[key: string]?anyThe published schema.
application/json- response
A schema resource: the server-owned envelope around a customer-authored JSON Schema document.
schema is the customer-authored document, served verbatim: its author
defines its keys and contents. The rest of the object (id and metadata)
is the server-owned envelope. Keeping the two apart means the
document may declare any property (including id or metadata) without
colliding with the envelope, and the resource id stays distinguishable
from the document's own $id.
id*stringThe schema's ID: the server-generated sch_* identifier, or the
customer-supplied $id URI when the document declared one at creation.
schema*The customer-authored JSON Schema document, served verbatim.
metadata*import { createZitadelClient } from "@zitadel/api/client";const client = createZitadelClient({ baseUrl: process.env.ZITADEL_URL ?? "http://localhost:8080", token: process.env.ZITADEL_PROJECT_SECRET!, // server-side only});const schema = await client.publishSchema( { title: "ExampleUserSchema", $schema: "https://json-schema.org/draft/2020-12/schema", metaSchema: "https://auth.acme.com/user-schema.json", kind: "user-schema", type: "object", description: "This is an example of a user schema definition.", objectType: "human-user", "x-auth-methods": { password: { enabled: false }, passkey: { enabled: true }, }, required: ["email", "password"], properties: { email: { type: "string", format: "email", description: "The user's email address.", }, password: { type: "string", minLength: 8, description: "The user's password, which must be at least 8 characters long.", }, firstName: { type: "string", description: "The user's first name.", }, lastName: { type: "string", description: "The user's last name.", }, address: { type: "object", description: "The user's address information.", properties: { street: { type: "string", description: "The street address.", }, houseNumber: { type: "string", description: "The house number of the address.", }, city: { type: "string", description: "The city of the address.", }, postalCode: { type: "string", description: "The postal code of the address.", }, country: { type: "string", description: "The country of the address.", }, }, }, }, }, { project_id: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5", team_id: "team_01KZZY8PX8K8ATNVDSMRCZY4N1", },);{ "id": "sch_01H455VB4213EF62K49QF6M73F", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "kind": "user-schema", "type": "object", "description": "This is an example of a user schema definition.", "objectType": "human-user", "x-auth-methods": { "password": { "enabled": false }, "passkey": { "enabled": true } }, "required": [ "email" ], "properties": { "email": { "type": "string", "format": "email", "description": "The user's email address." } } }, "metadata": { "created_at": "2026-07-14T09:11:00Z" }}Was this helpful?