> ## Documentation Index
> Fetch the complete documentation index at: https://developers.portao3.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a user

> Updates a user's profile, and adds them to organizations or changes their level in the organizations they belong to.

Send only the fields to change: an omitted field, or an empty `firstName`, `lastName` or `cpf`, keeps the current value. Listing an organization the user doesn't belong to yet adds them to it with a personal wallet, like `POST /realms/{realmId}/users/{userId}/organizations/{organizationId}/assign`; organizations you don't list are kept. The e-mail address can't be changed. Only a realm administrator can update another user: an API client, which is an organization admin, gets `403`.


## OpenAPI

````yaml /api-reference/identity.openapi.json patch /realms/{realmId}/users/{userId}
openapi: 3.0.3
info:
  title: Identity
  version: 1.0.0
  description: >-
    Portão 3 identity API. Every endpoint requires a bearer token in the
    Authorization header (Authorization: Bearer <token>) unless its page states
    otherwise; see the Authentication guide. That requirement is not repeated
    per endpoint. Generated by tools/openapi from code (routes + security) and
    the hand-written spec (request/response bodies). 4 app groups run without
    the identity authorizer; publicPatterns enumerates every route they expose,
    except POST /auth/sign-in, documented with HTTP Basic for the API-client
    credentials flow. Confidence tiers: generated:typed=45 copied:manual=0
    unknown=0.
servers:
  - url: https://api.identity.v2.portao3.com.br/
    description: production
  - url: https://api.identity.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Authentication
  - name: Current User
  - name: Custom Fields
  - name: API Clients
  - name: Users
  - name: Organizations
  - name: Groups
  - name: Realms
paths:
  /realms/{realmId}/users/{userId}:
    patch:
      tags:
        - Users
      summary: Update a user
      description: >-
        Updates a user's profile, and adds them to organizations or changes
        their level in the organizations they belong to.
      operationId: patchRealmsByRealmIdUsersByUserId
      parameters:
        - name: realmId
          in: path
          required: true
          description: |-
            ID of your realm.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
        - name: userId
          in: path
          required: true
          description: |-
            ID of the user to update.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 8f1c2d3e-4b5a-4c6d-9e7f-a1b2c3d4e5f6
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                firstName:
                  description: First name. An empty value keeps the current one.
                  example: Ana
                  type: string
                lastName:
                  description: Last name. An empty value keeps the current one.
                  example: Souza
                  type: string
                cpf:
                  description: >-
                    CPF, digits only. Must be a valid CPF; an empty value keeps
                    the current one.
                  example: '52998224725'
                  type: string
                birthdate:
                  description: >-
                    Date of birth, as an ISO 8601 date-time at midnight UTC. A
                    plain `YYYY-MM-DD` date is also accepted.
                  example: '1990-05-17T00:00:00.000Z'
                  type: string
                  format: date-time
                phone:
                  description: >-
                    Phone number in E.164 format: `+`, the country code and the
                    number, digits only. Mobile or landline, Brazilian or not.
                  example: '+5511987654321'
                  type: string
                  pattern: ^\+[1-9]\d{7,14}$
                realm:
                  description: The user's realm.
                  type: object
                  properties:
                    level:
                      description: >-
                        The user's access level in the realm. Must equal the
                        current level: changing it is not allowed.
                      example: USER
                      type: string
                      enum:
                        - ADMIN
                        - USER
                organizations:
                  description: >-
                    Organizations to update or add. A listed organization the
                    user already belongs to gets the new `level`; one they don't
                    belong to yet is added, with a personal wallet.
                    Organizations you don't list are kept.
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: |-
                          ID of an organization of your realm.

                          Format: `UUID`
                        example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
                      level:
                        type: string
                        enum:
                          - ADMIN
                          - USER
                        description: >-
                          Access level in the organization: `ADMIN` manages its
                          users and settings, `USER` uses its wallets and cards.
                        example: USER
                    required:
                      - id
                      - level
                customFields:
                  description: >-
                    Values of the realm's user custom fields, keyed by the
                    custom field's `slug`, for example `{"cost-center":
                    "Marketing"}`. Replaces every stored value: send `{}` to
                    clear them, or omit the field to keep them.
                  type: object
                  additionalProperties: {}
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ID of the user.
                    example: 8f1c2d3e-4b5a-4c6d-9e7f-a1b2c3d4e5f6
                    format: uuid
                  email:
                    type: string
                    description: >-
                      E-mail address the user signs in with. It can't be
                      changed.
                    example: ana.souza@acme.com.br
                  firstName:
                    type: string
                    description: First name.
                    example: Ana
                  lastName:
                    type: string
                    description: Last name.
                    example: Souza
                  cpf:
                    type: string
                    description: CPF, digits only.
                    example: '52998224725'
                  birthdate:
                    type: string
                    description: Date of birth, at midnight UTC.
                    example: '1990-05-17T00:00:00.000Z'
                    format: date-time
                  phone:
                    type: string
                    description: >-
                      Phone number in E.164 format. Omitted when the user has
                      none.
                    example: '+5511987654321'
                  status:
                    type: string
                    enum:
                      - IN_ONBOARDING
                      - CREATING
                      - ACTIVE
                      - DEACTIVATED
                      - BLOCKED
                    description: >-
                      Lifecycle status. `IN_ONBOARDING`: invited, still
                      completing onboarding. `ACTIVE`: can sign in.
                      `DEACTIVATED`: access removed by an administrator.
                      `BLOCKED`: access suspended, for example after too many
                      wrong PINs. `CREATING`: being set up.
                    example: ACTIVE
                  statusCode:
                    type: string
                    enum:
                      - BLOCKED_BY_PIN
                      - BLOCKED_BY_MFA
                      - BLOCKED_BY_ADMIN
                      - USER_ACTIVE
                      - USER_DEACTIVATED
                      - ONLY_ONBOARDING
                    description: >-
                      Reason behind `status`: `USER_ACTIVE`, `USER_DEACTIVATED`,
                      `ONLY_ONBOARDING`, or the cause of a block
                      (`BLOCKED_BY_PIN`, `BLOCKED_BY_MFA`, `BLOCKED_BY_ADMIN`).
                    example: USER_ACTIVE
                  realm:
                    type: object
                    properties:
                      id:
                        type: string
                        description: ID of the realm.
                        example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
                        format: uuid
                      level:
                        type: string
                        enum:
                          - ADMIN
                          - USER
                          - APP_CLIENT
                        description: >-
                          Access level in the realm. `ADMIN` can manage every
                          organization and user of the realm; `USER` acts only
                          in the organizations listed in `organizations`.
                          `APP_CLIENT` can appear on users created with that
                          level.
                        example: USER
                      name:
                        type: string
                        description: Display name of the realm. Can be empty.
                        example: ''
                    required:
                      - id
                      - level
                      - name
                    description: The user's realm and their access level in it.
                  hasMfa:
                    type: boolean
                    description: Whether the user has set up multi-factor authentication.
                    example: true
                  hasPin:
                    type: boolean
                    description: Whether the user has created a transaction PIN.
                    example: true
                  hasFacialBiometric:
                    type: boolean
                    description: Whether the user's face was validated during onboarding.
                    example: true
                  pinErrorsCount:
                    type: number
                    description: >-
                      Consecutive wrong PIN attempts. At 3 the user is blocked
                      (`BLOCKED_BY_PIN`).
                    example: 0
                  mfaErrorsCount:
                    type: number
                    description: Consecutive wrong multi-factor codes.
                    example: 0
                  customFields:
                    type: object
                    additionalProperties: {}
                    description: >-
                      Values of the realm's user custom fields, keyed by the
                      custom field's `slug`, for example `{"cost-center":
                      "Marketing"}`. Omitted when the user has none.
                  createdAt:
                    type: string
                    description: When the user was created.
                    example: '2026-03-02T14:21:07.512Z'
                    format: date-time
                  updatedAt:
                    type: string
                    description: When the user last changed.
                    example: '2026-10-13T18:43:50.746Z'
                    format: date-time
                  createdBy:
                    type: string
                    description: >-
                      ID of the user or API client that created this user. Empty
                      when unknown.
                    example: 43230779-2cfb-4525-a40c-77fbf15e68f0
                  updatedBy:
                    type: string
                    description: >-
                      ID of the user or API client that last changed this user.
                      Empty when unknown.
                    example: 43230779-2cfb-4525-a40c-77fbf15e68f0
                  deletedBy:
                    type: string
                    description: >-
                      ID of the user or API client that deactivated this user.
                      Empty unless the user was deactivated.
                    example: ''
                  organizations:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: ID of the organization.
                          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
                          format: uuid
                        level:
                          type: string
                          enum:
                            - ADMIN
                            - USER
                            - APP_CLIENT
                          description: >-
                            Access level in the organization. `ADMIN` manages
                            the organization's users and settings; `USER` uses
                            its wallets and cards. `APP_CLIENT` can appear on
                            memberships created with that level.
                          example: USER
                        legalName:
                          type: string
                          description: Legal name of the organization, when known.
                          example: Acme Comércio de Alimentos Ltda
                        tradingName:
                          type: string
                          description: Trade name of the organization, when known.
                          example: Acme Alimentos
                      required:
                        - id
                      description: >-
                        An organization the user belongs to, with its
                        registration data.
                    description: Organizations of the realm the user belongs to.
                required:
                  - cpf
                  - createdAt
                  - createdBy
                  - deletedBy
                  - email
                  - firstName
                  - hasFacialBiometric
                  - hasMfa
                  - hasPin
                  - id
                  - lastName
                  - mfaErrorsCount
                  - organizations
                  - pinErrorsCount
                  - realm
                  - status
                  - statusCode
                  - updatedAt
                  - updatedBy
                description: A user of the realm.
        '403':
          description: >-
            `FORBIDDEN_USER` — You are not a realm administrator (an API client
            never is), or `realm.level` differs from the user's current level:
            changing it is not allowed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - FORBIDDEN_USER
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - IDENTITY
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: FORBIDDEN_USER
                origin: IDENTITY
                message: You do not have permission to perform this action on this user
        '404':
          description: >-
            `USER_NOT_FOUND` — No user with this ID exists in your realm.


            `ORGANIZATION_NOT_FOUND` — An `organizations[].id` is not an
            organization of your realm.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - USER_NOT_FOUND
                      - ORGANIZATION_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - IDENTITY
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: USER_NOT_FOUND
                origin: IDENTITY
                message: User not found
        '422':
          description: >-
            `BAD_REQUEST` — The path or body failed validation; `fields` lists
            each invalid field.


            `CUSTOM_FIELD_NOT_ALLOWED` — A `customFields` key is not the slug of
            an active user custom field of the user's organizations; `fields`
            names it.


            `CUSTOM_FIELD_INVALID_VALUE` — A `customFields` value doesn't match
            its custom field's type or options; `fields` names it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - BAD_REQUEST
                      - CUSTOM_FIELD_NOT_ALLOWED
                      - CUSTOM_FIELD_INVALID_VALUE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - IDENTITY
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                  fields:
                    type: array
                    description: >-
                      One entry per invalid request field (validation errors
                      only).
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          description: >-
                            Path of the invalid field, e.g. `label` or
                            `values[0].value`.
                          example: label
                        message:
                          type: string
                          description: Why the field was rejected.
                          example: label is required
                        code:
                          type: string
                          description: >-
                            `<FIELD>_<REASON>` — e.g. `LABEL_REQUIRED`,
                            `TYPE_ONE_OF`, `VALUES_VALUE_TYPE_ERROR`.
                          example: LABEL_REQUIRED
                        values:
                          type: array
                          items:
                            type: string
                          description: >-
                            The accepted values, when the field is an
                            enumeration.
                      required:
                        - field
                        - message
                        - code
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: BAD_REQUEST
                origin: IDENTITY
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: userId
                    message: Invalid UUID
                    code: USERID_UUID

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.