Get a user by ID
Returns a user by ID, with the attributes its schema defines.
With team_id, the user is returned only while they are an active member
of that team.
AuthorizationBearer <token>Scope: user.read
user_id*stringThe user ID: the id that createUser (POST /users) or queryUsers (POST /users/query) returns.
^user_[a-zA-Z0-9_-]+$team_id?stringServes the user only when they hold an active membership in this team,
and answers 404 otherwise. Use the id that createTeam (POST /teams) returns or
queryTeams (POST /teams/query) lists.
This is team membership, not lifecycle ownership: it asks which team
the user collaborates in, not which team may deprovision them. The
owning team is reported separately as
metadata.lifecycle_owner_team_id, and a user can belong to many teams
while owning their own lifecycle.
Only active memberships match. A user who has been invited but has not accepted is not served.
It reads the user's memberships, so it takes the same permission as the
team_id filter on POST /users/query: team_membership.read for a
project secret, read on the whole project for a console session.
Otherwise the answer is 403 user.permission_denied.
^[a-zA-Z0-9_-]+$The user.
application/json- response
A user is an individual identity in the system. It can represent a person, a service account or any other type of identity.
attributes is the document that satisfies the user schema named by
schema. That schema defines its property names and types and validates it.
The rest of the object (id, schema, metadata) is the server-owned
envelope. Keeping the two apart means a schema may name a property id or
metadata without colliding with the envelope. It also means closed-world
keywords (additionalProperties: false, propertyNames,
unevaluatedProperties) behave as their author expects.
id*user-id^user_[a-zA-Z0-9_-]+$schema*stringThe ID of the schema that defines the content of attributes.
getSchema (GET /schemas/{schema_id}) returns it, and publishSchema (POST /schemas) creates one.
attributes*The user's content, satisfying the schema named by schema. Property
names and types are determined entirely by that schema.
metadata*identifier?stringThe current value of the user schema's designated identifier
(x-identifier), resolved when the user is read. Absent when the schema
designates no identifier or the user carries no value for it.
identifier_property?stringThe schema property identifier came from. With it, a client can read
the property's definition for its meaning (a mailto link, a field label)
instead of guessing from the value. Present exactly when identifier is.
display?stringThe x-display rendering: the designated properties' values joined in
list order, resolved when the user is read. It is for display only.
Absent when the schema designates no display properties or the user
carries no values for them. Clients render display, falling back to
identifier, then id.
teams?array<>The user's team memberships, present only when the request asked for them
with expand: ["teams"]. Absent means it was not requested; [] means
the user has none.
Memberships sit outside metadata: they are a related collection, not
part of the server-owned envelope, and a different concept from
metadata.lifecycle_owner_team_id, which names the one team that owns the
user's lifecycle.
teams_truncated?booleanTrue when the user is on more teams than the embedded list carries. The
embedded list is capped and cannot be paged; read every team with
listUserTeams (GET /users/{user_id}/teams). Present only alongside
teams.
import { configureZitadel, getApi } from "@zitadel/api/config";// In the browser, through the SDK proxy: the session cookie authenticates the call.const client = getApi(configureZitadel({ projectId: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" }));const user = await client.getUser("user_01KWH3B72K7M7F0N9WD3P2E4YM");{ "id": "string", "schema": "string", "attributes": {}, "metadata": { "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "status": "active", "lifecycle_owner_team_id": "string", "lifecycle_owner_team": { "id": "string", "name": "string", "status": "active", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } }, "identifier": "string", "identifier_property": "string", "display": "string", "teams": [ { "id": "string", "name": "string", "membership_status": "pending", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z" } ], "teams_truncated": true}Was this helpful?