Docs

Set a user's password

PUT
/users/{user_id}/password

Sets a user's password, hashed with the project's current password hashing policy.

The new password replaces the current one, and setting it emits auth.factor.password.set. A password the project's password policy refuses answers user.password_policy_violation; send one that meets the policy.

Setting the password of a person in the platform project also ends every personal access token of theirs that has not expired, in the same transaction: a CI job or an agent that uses one is refused from its next call, and the person creates a new token for it. One auth.token.revoked event records it, with reason password_set and the count of tokens that ended.

The password policy is the one in the release that serves the caller's Origin, chosen as createFlow (POST /flows) chooses it. A frontend on a preview URL gets that preview's policy, and one on a primary origin the newest primary deployment's. A request with no Origin, or from the console when the project does not list the console's origin, gets the project's newest primary deployment.

If the request is refused:

  • 403 proj.origin_not_allowed: the project admits no such origin. Add it with zitadel origin add.
  • 403 proj.preview_not_live: the origin matches a preview pattern but has no live preview. Run zitadel preview on the branch.
  • 409 rel.not_deployed: nothing is deployed to the origin. Run zitadel deploy.
  • 409 rel.no_default: the request names no origin and the project has no primary deployment. Run zitadel deploy.
  • 409 rel.revoked: the release that serves the origin is revoked.

Who may call it (ADR 094 §4): an admin of the user's project. For a user of the deployment's platform project, the caller must also hold, on every other project, at least each role the user holds there, and be a platform operator when the user is one; a caller who does not answers 403 user.permission_denied with details.details.reason target_holds_more, without saying what the user holds. On the reserved platform project another user is a customer account, so only an operator may call it there (reason operators_only); on a deployment that names no operator, its admins may, under the same check. A user of any other project is that project's to manage, whatever it holds elsewhere, and a user's own account is theirs.

Authorization

oauth2 user.write
headerAuthorizationBearer <token>

Scope: user.write

Path Parameters

user_id*string

The user ID: the id that createUser (POST /users) or queryUsers (POST /users/query) returns.

Match^user_[a-zA-Z0-9_-]+$

Header Parameters

Origin?string

Standard browser Origin header. Selects the deployment whose password policy applies. Browsers send it automatically; no client action is required. Absent when the caller is not a browser.

Formaturi

Request Body

application/json
  1. body

The request body for setting the user's password.

password*string

The new password for the user.

Response Body

The password was set.

Example Request
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  }),);await api.setUserPassword("user_01KWH3B72K7M7F0N9WD3P2E4YM", { password: "string" });
Example Response
Empty

Was this helpful?