> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Set the caller's Phone Number

> Sets the authenticated user's phone number and country code together; both are required. This is the self-service twin of PATCH /v1/users/{id}, which is administrator-only — and unlike that merge endpoint it writes ONLY these two fields. Clearing the number is DELETE /v1/users/{id}/phone, which is refused while SMS MFA is enabled; an empty phone here is rejected with 400 rather than clearing anything. Authorized on the "own-profile" resource, which every authenticated user holds, and confined to the caller's own account: an {id} other than the token subject is refused with 403 / IDE-0057.



## OpenAPI

````yaml /en/openapi/v3-current/AM-identity.yaml patch /v1/users/{id}/phone
openapi: 3.0.1
info:
  contact: {}
  description: This is a swagger documentation for the Identity API
  termsOfService: http://swagger.io/terms/
  title: Identity API
  version: 1.0.0
servers:
  - url: //localhost:4001/
security: []
paths:
  /v1/users/{id}/phone:
    patch:
      tags:
        - Users
      summary: Set the caller's Phone Number
      description: >-
        Sets the authenticated user's phone number and country code together;
        both are required. This is the self-service twin of PATCH
        /v1/users/{id}, which is administrator-only — and unlike that merge
        endpoint it writes ONLY these two fields. Clearing the number is DELETE
        /v1/users/{id}/phone, which is refused while SMS MFA is enabled; an
        empty phone here is rejected with 400 rather than clearing anything.
        Authorized on the "own-profile" resource, which every authenticated user
        holds, and confined to the caller's own account: an {id} other than the
        token subject is refused with 403 / IDE-0057.
      parameters:
        - description: Caller's own User ID
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserPhoneInput'
        description: User Phone Input
        required: true
      responses:
        '204':
          content: {}
          description: No Content
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg.HTTPError'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg.HTTPError'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg.HTTPError'
          description: The requested ID is not the authenticated user (IDE-0057)
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg.HTTPError'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg.HTTPError'
          description: Internal Server Error
      security:
        - BearerAuth: []
components:
  schemas:
    UserPhoneInput:
      description: UserPhoneInput payload
      example:
        phone: 5511998888777
        countryCode: BR
      properties:
        countryCode:
          description: >-
            User's ISO 3166-1 alpha-2 country code. Required.


            len=2,alpha is the closest shape this repo's validator can express —
            it has

            no iso3166_1_alpha2 rule and no uppercase rule. The authoritative
            check is

            Casdoor's, which rejects a country code that does not resolve
            against the

            phone number.
          example: BR
          type: string
        phone:
          description: User's phone number in E.164 format. Required.
          example: 5511998888777
          type: string
      required:
        - countryCode
        - phone
      type: object
    pkg.HTTPError:
      properties:
        code:
          type: string
        entityType:
          type: string
        err:
          type: object
        message:
          type: string
        title:
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      description: 'Bearer authentication. Send Authorization: Bearer <token>.'
      in: header
      name: Authorization
      type: apiKey

````