fn list(type: enum)
List users, optionally only the humans or only the machines, and store each one. Read-only.
| Argument | Type | Required | Description |
|---|
| type | enum | yes | Narrow the listing to one kind of user |
fn get()
Read one user by id or username and store it. Read-only.
fn ensureMachine(username: string, name: string, description?: string, accessTokenType: enum)
Find or create a machine (service) user by username, converging its display name, description and token type. Idempotent, and mints no credential — patCreate, keyCreate or secretGenerate do that.
| Argument | Type | Required | Description |
|---|
| username | string | yes | Login name; an existing machine user of this name is converged |
| name | string | yes | Display name |
| description? | string | no | Free text; omitting it leaves any existing description as it is, since |
| accessTokenType | enum | yes | |
fn ensureHuman(username: string, email: string, givenName: string, familyName: string, displayName?: string, nickName?: string, gender?: enum, preferredLanguage?: string, phone?: string, emailVerified: boolean)
Find or create a human user by username, converging their name and email. Idempotent, and sets no password: the person sets one from a passwordResetLinkCreate link, or from the mail Zitadel sends.
| Argument | Type | Required | Description |
|---|
| username | string | yes | Login name; an existing human user of this name is converged |
| email | string | yes | Email address |
| givenName | string | yes | First name |
| familyName | string | yes | Last name |
| displayName? | string | no | |
| nickName? | string | no | |
| gender? | enum | no | |
| preferredLanguage? | string | no | BCP-47 tag, e.g. nb or en |
| phone? | string | no | Phone number in E.164 form |
| emailVerified | boolean | yes | Mark the address verified instead of having Zitadel send a code |
fn update(username?: string, email?: string, emailVerified?: boolean, givenName?: string, familyName?: string, displayName?: string, phone?: string, name?: string, description?: string, accessTokenType?: enum)
Change a user's login name, a human's profile or email, or a machine's name, description and token type. Only what is given is sent. Never a password.
| Argument | Type | Required | Description |
|---|
| username? | string | no | New login name |
| email? | string | no | Human users: new email address |
| emailVerified? | boolean | no | |
| givenName? | string | no | |
| familyName? | string | no | |
| displayName? | string | no | |
| phone? | string | no | |
| name? | string | no | Machine users: new display name |
| description? | string | no | Machine users: new description |
| accessTokenType? | enum | no | Machine users: token type |
fn setState(state: enum)
Deactivate, reactivate, lock or unlock a user. Every direction is reversible, and asking for the state a user is already in changes nothing.
| Argument | Type | Required | Description |
|---|
| state | enum | yes | active reactivates or unlocks, inactive deactivates, locked locks out |
fn delete(confirm: string)
Delete a user and everything that belongs to them — grants, tokens, keys. Verify-first: confirm must repeat the live username, and dryRun only reports. Prefer setState inactive, which is reversible.
| Argument | Type | Required | Description |
|---|
| confirm | string | yes | The user's exact username, repeated — a mismatch refuses the delete |
fn patCreate()
Add a personal access token to a user. Returns the token once, marked sensitive.
fn patList()
List a user's personal access tokens by id and expiry. Read-only; a token's value is not readable after it was created.
fn patRevoke(tokenId: string)
Revoke a personal access token, verifying first that it belongs to the user. dryRun only reports.
| Argument | Type | Required | Description |
|---|
| tokenId | string | yes | Token id, verified to belong to the user first |
fn keyCreate(publicKey?: string)
Add a private key to a machine user, or register a public key you hold. Returns the generated key JSON once, marked sensitive.
| Argument | Type | Required | Description |
|---|
| publicKey? | string | no | A public key to register instead of having Zitadel generate the pair |
fn keyList()
List a user's keys by id and expiry. Read-only; key material is not readable after it was created.
fn keyDelete(keyId: string)
Delete a user's key, verifying first that it belongs to them. dryRun only reports.
| Argument | Type | Required | Description |
|---|
| keyId | string | yes | Key id, verified to belong to the user first |
fn secretGenerate()
Generate a machine user's client secret, replacing any previous one. Returns it once, marked sensitive.
fn secretRemove()
Remove a machine user's client secret, leaving the user in place. dryRun only reports.
fn metadataSet(key: string, value: string)
Set one metadata entry on a user, creating or overwriting it. Idempotent.
| Argument | Type | Required | Description |
|---|
| key | string | yes | Metadata key |
| value | string | yes | Metadata value, stored as given |
fn metadataList()
List a user's metadata, decoding each value, and store one resource per entry. Read-only.
fn metadataDelete()
Delete metadata entries from a user by key. dryRun only reports.
fn passwordResetLinkCreate(delivery: enum, urlTemplate?: string)
Mint a password reset for a human user: either a code returned once into a sensitive spec, or a link Zitadel mails to them. No password is ever an argument here.
| Argument | Type | Required | Description |
|---|
| delivery | enum | yes | return stores the code once as a secret; email has Zitadel send the link |
| urlTemplate? | string | no | Link template for the mail, e.g. https://example.org/reset?code={{.Code}} |
fn authFactorList()
List what a person can prove who they are with — TOTP, U2F, a code by SMS or email, a passkey — and whether each is ready. Read-only, and the audit behind 'who here actually has MFA'.
fn authFactorRemove(type: enum, id?: string)
Take one authentication factor away from a person — a lost phone, a retired key. Verify-first: the factor has to be there, and u2f and passkey need the id from authFactorList. dryRun only reports. The person can register a new factor afterwards; this does not lock them out by itself, but removing their last factor while MFA is forced will.
| Argument | Type | Required | Description |
|---|
| type | enum | yes | Which kind of factor to take away |
| id? | string | no | The factor's id, needed for u2f and passkey, where a user may have several |
fn idpLinkList()
List the identity providers a person can log in through, and their account at each. Read-only.
fn idpLinkRemove(idpId: string, externalUserId: string)
Unlink a person from an identity provider, verifying the link first. dryRun only reports. If that provider was their only way in, they will need a password or a passkey afterwards.
| Argument | Type | Required | Description |
|---|
| idpId | string | yes | The identity provider |
| externalUserId | string | yes | The user's id at that provider, verified against the link first |
Resources
user(infinite)— A user, human or machine
user-credential(infinite)— A credential minted for a user — token, key or secret — emitted once
credential(infinite)— A user's existing token or key, by id and expiry; never the secret
metadata(infinite)— One metadata entry on a user
auth-factor(infinite)— One way a person can prove who they are
idp-link(infinite)— A user's account at an identity provider
password-reset(infinite)— A password reset a human can act on
state(infinite)— The outcome of a reversible state change
deletion(infinite)— The outcome of a delete, or of a dry run that planned one