> ## 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 customer

> Updates a customer's name, trade name, e-mail, phone, address or custom-field values, and answers the updated customer with `201`.

Send only what changes: a field you leave out keeps its current value, and an address part you leave out stays as it is. A customer's `document` can't be changed, and neither can its status: use the activate and deactivate routes for that.

`customFields`, when sent, replaces the customer's whole map, so send every value you want to keep. Its keys are checked against the organization's active custom fields for customers; unlike a create, a required custom field you leave out is not an error.


## OpenAPI

````yaml /api-reference/registry.openapi.json put /realms/{realmId}/organizations/{organizationId}/customer/{customerId}
openapi: 3.0.3
info:
  title: Registry
  version: 1.0.0
  description: >-
    Portão 3 registry 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). Confidence tiers:
    generated:typed=37 copied:manual=0 unknown=0.
servers:
  - url: https://api.registry.v2.portao3.com.br/
    description: production
  - url: https://api.registry.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Customers
  - name: Companies
  - name: People
  - name: Products
  - name: Suppliers
paths:
  /realms/{realmId}/organizations/{organizationId}/customer/{customerId}:
    put:
      tags:
        - Customers
      summary: Update a customer
      description: >-
        Updates a customer's name, trade name, e-mail, phone, address or
        custom-field values, and answers the updated customer with `201`.
      operationId: putRealmsByRealmIdOrganizationsByOrganizationIdCustomerByCustomerId
      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: organizationId
          in: path
          required: true
          description: |-
            ID of the organization the customer belongs to.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: customerId
          in: path
          required: true
          description: |-
            ID of the customer to update.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 7f3b1c52-9e4a-4d1b-8a67-2c5d9f0e4b13
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: >-
                    New name of the customer: a person's full name or a
                    company's name. Omit it, or send it empty, to keep the
                    current one.
                  example: Ana Souza
                  type: string
                  maxLength: 100
                trandingName:
                  description: >-
                    New trade name of a company customer. Omit it, or send it
                    empty, to keep the current one.
                  example: Souza Studio
                  type: string
                email:
                  description: New e-mail address of the customer.
                  example: ana.souza@example.com
                  type: string
                  format: email
                  pattern: >-
                    ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
                document:
                  description: >-
                    A customer's document can't be changed: the value is checked
                    (it must be a valid CPF or CNPJ, with no dots, dashes or
                    slashes) and then ignored.
                  example: '52998224725'
                  type: string
                  pattern: ^[A-Za-z0-9]+$
                phoneNumber:
                  description: >-
                    New Brazilian phone number in international format: `+55`,
                    the area code and the number (10 or 11 digits).
                  example: '+5511999999999'
                  type: string
                  pattern: ^\+55[0-9]{10,11}$
                address:
                  default: {}
                  description: >-
                    Parts of the postal address to change. Each part you send
                    replaces the stored one; the parts you leave out stay as
                    they are.
                  type: object
                  properties:
                    city:
                      description: City.
                      example: São Paulo
                      type: string
                      maxLength: 50
                    neighborhood:
                      description: >-
                        Neighborhood. Letters, digits, spaces and the characters
                        `. , -` only.
                      example: Centro
                      type: string
                      maxLength: 100
                      pattern: ^[A-Za-zÀ-ú 0-9.,\-]+$
                    number:
                      description: Street number. Letters, digits and dashes only.
                      example: '123'
                      type: string
                      pattern: ^[A-Za-z0-9\-]+$
                    state:
                      type: string
                      enum:
                        - AC
                        - AL
                        - AP
                        - AM
                        - BA
                        - CE
                        - ES
                        - GO
                        - MA
                        - MT
                        - MS
                        - MG
                        - PA
                        - PB
                        - PR
                        - PE
                        - PI
                        - RJ
                        - RN
                        - RS
                        - RO
                        - RR
                        - SC
                        - SP
                        - SE
                        - TO
                        - DF
                      description: Two-letter code of the Brazilian state.
                      example: SP
                    street:
                      description: >-
                        Street name. Letters, digits, spaces and the characters
                        `. , -` only.
                      example: Rua das Flores
                      type: string
                      maxLength: 100
                      pattern: ^[A-Za-zÀ-ú 0-9.,\-]+$
                    postalCode:
                      description: Postal code (CEP), as `00000-000`.
                      example: 01000-000
                      type: string
                      pattern: ^[0-9]{5}-[0-9]{3}$
                    complement:
                      description: Extra address detail, such as an apartment or suite.
                      example: Apto 45
                      type: string
                      maxLength: 50
                customFields:
                  description: >-
                    Values of the organization's custom fields for this
                    customer, keyed by each field's `slug`. When sent it
                    replaces the customer's whole map: a field you leave out is
                    removed, and a value sent as `null`, an empty string or an
                    empty list clears that field. Every key must be the slug of
                    an active custom field defined for customers, and every
                    value must fit that field's type. Omit `customFields` to
                    leave the values untouched.


                    ---


                    Example: `{"cost-center":"CC-1020"}`
                  example:
                    cost-center: CC-1020
                  type: object
                  additionalProperties: {}
      responses:
        '201':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ID of the customer.
                    example: 7f3b1c52-9e4a-4d1b-8a67-2c5d9f0e4b13
                    format: uuid
                  address:
                    type: object
                    properties:
                      street:
                        type: string
                        description: Street name.
                        example: Rua das Flores
                      number:
                        type: string
                        description: Street number (letters, digits and dashes).
                        example: '123'
                      complement:
                        type: string
                        description: Extra address detail, such as an apartment or suite.
                        example: Apto 45
                      neighborhood:
                        type: string
                        description: Neighborhood.
                        example: Centro
                      city:
                        type: string
                        description: City.
                        example: São Paulo
                      state:
                        type: string
                        description: Two-letter code of the Brazilian state.
                        example: SP
                      postalCode:
                        type: string
                        description: Postal code (CEP), as `00000-000`.
                        example: 01000-000
                    description: Postal address of the customer.
                    example:
                      street: Rua das Flores
                      number: '123'
                      complement: Apto 45
                      neighborhood: Centro
                      city: São Paulo
                      state: SP
                      postalCode: 01000-000
                  name:
                    type: string
                    description: >-
                      Name of the customer: a person's full name or a company's
                      name.
                    example: Ana Souza
                  document:
                    type: string
                    description: >-
                      Tax ID of the customer, without formatting: a CPF (11
                      digits) or a CNPJ (14 characters — the first 12 may be
                      uppercase letters, the last 2 are digits).
                    example: '52998224725'
                  documentType:
                    type: string
                    description: >-
                      Kind of `document`: `CPF` for 11 characters, `CNPJ`
                      otherwise.
                    example: CPF
                  trandingName:
                    type: string
                    description: Trade name of a company customer.
                    example: Souza Studio
                  email:
                    type: string
                    description: E-mail address of the customer.
                    example: ana.souza@example.com
                  phoneNumber:
                    type: string
                    description: >-
                      Phone number of the customer, in international format: `+`
                      followed by digits.
                    example: '+5511999999999'
                  hash:
                    type: string
                    description: >-
                      Token that identifies the customer in the link of their
                      portal page.
                    example: c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f
                    format: uuid
                  customFields:
                    description: >-
                      Values of the organization's custom fields for this
                      customer, keyed by the field's `slug`. Absent, or `null`,
                      when the customer has none.


                      ---


                      Example: `{"cost-center":"CC-1020"}`
                    example:
                      cost-center: CC-1020
                    type: object
                    additionalProperties: {}
                    nullable: true
                required:
                  - hash
                  - id
                description: >-
                  The customer an update answers with: the same shape a create
                  answers with.
        '403':
          description: '`FORBIDDEN_CUSTOMER` — You do not belong to the organization.'
          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_CUSTOMER
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - REGISTRY
                    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_CUSTOMER
                origin: REGISTRY
                message: >-
                  You do not have permission to perform this action on this
                  resource (customer)
        '404':
          description: >-
            `CUSTOMER_NOT_FOUND` — No customer with this ID exists in the
            organization.
          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:
                      - CUSTOMER_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - REGISTRY
                    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: CUSTOMER_NOT_FOUND
                origin: REGISTRY
                message: Customer not found
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter or a body field is invalid, such as
            a `customerId` that is not a UUID (listed in `fields` as `id`);
            `fields` lists each one.


            `CUSTOM_FIELD_NOT_FOUND` — A key of `customFields` is not the slug
            of an active custom field defined for customers. The message reads
            `Custom field "<slug>" not found`.


            `CUSTOM_FIELD_INVALID_VALUE` — A value of `customFields` does not
            fit its custom field's type or options. The message reads `Invalid
            value for custom field "<slug>"`.
          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_FOUND
                      - CUSTOM_FIELD_INVALID_VALUE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - REGISTRY
                    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: REGISTRY
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: name
                    message: 'Too big: expected string to have <=100 characters'
                    code: NAME_MAX

````

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