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

# Send a phone verification code

> Starts verifying a phone number, together with your national code. Confirm it with `POST /v1/save-info` within 2 minutes. The phone number must be registered to the national code you send.

- **First verification:** send `phone` and `nationalCode`. A code is
  sent by SMS.

- **Changing your phone:** first send your **current** `phone` without
  `nationalCode` and confirm that code. That opens a 5-minute window in
  which you send the new `phone` with `nationalCode`.

- **Changing only your national code:** send your current `phone` with
  the new `nationalCode`. No code is sent (`requiresOtp: false`) and the
  change is saved immediately.


This endpoint is rate limited. Too many requests return `429`.



## OpenAPI

````yaml /spec/platform-auth.yaml post /v1/send-phone-token
openapi: 3.0.1
info:
  title: Authentication & Account
  version: 1.0.0
  description: >-
    Log in, issue API tokens, change or reset your password, set up two-factor
    authentication, verify your email address and phone number, and manage your
    account profile and billing contact details.
servers:
  - url: https://api.liara.ir
security:
  - bearerAuth: []
tags:
  - name: Login
    description: Exchange your credentials or a one-time code for an API token.
  - name: Registration
    description: Create a new account.
  - name: Password
    description: Change your password while logged in, or reset a forgotten one.
  - name: API Tokens
    description: Issue additional API tokens for your account.
  - name: Account
    description: Read and update your profile and billing contact details.
  - name: Two-Factor Authentication
    description: Set up and manage authenticator-app (TOTP) two-factor authentication.
  - name: Verification
    description: Verify, or change, your account's email address and phone number.
paths:
  /v1/send-phone-token:
    post:
      tags:
        - Verification
      summary: Send a phone verification code
      description: >-
        Starts verifying a phone number, together with your national code.
        Confirm it with `POST /v1/save-info` within 2 minutes. The phone number
        must be registered to the national code you send.


        - **First verification:** send `phone` and `nationalCode`. A code is
          sent by SMS.

        - **Changing your phone:** first send your **current** `phone` without
          `nationalCode` and confirm that code. That opens a 5-minute window in
          which you send the new `phone` with `nationalCode`.

        - **Changing only your national code:** send your current `phone` with
          the new `nationalCode`. No code is sent (`requiresOtp: false`) and the
          change is saved immediately.


        This endpoint is rate limited. Too many requests return `429`.
      operationId: sendPhoneVerificationCode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - phone
              properties:
                phone:
                  $ref: '#/components/schemas/PhoneNumber'
                nationalCode:
                  type: string
                  pattern: ^\d{10,12}$
                  description: 10 to 12 digits.
            example:
              phone: '09120000000'
              nationalCode: '0000000000'
      responses:
        '200':
          description: >-
            `requiresOtp: true` means a code was sent; confirm it with `POST
            /v1/save-info`. `requiresOtp: false` means the national code was
            updated and nothing else is needed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  requiresOtp:
                    type: boolean
              example:
                requiresOtp: true
        '400':
          description: >-
            The body is invalid, `nationalCode` is missing where it's required,
            or the phone number isn't registered to this national code.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                notMatched:
                  summary: Phone number and national code don't match
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Phone number does not belong to this national code.
                nationalCodeMissing:
                  summary: National code missing
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: National code is required.
                    data: null
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            You're changing your phone but haven't confirmed your current phone
            in the last 5 minutes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 403
                error: Forbidden
                message: You must verify your current phone first.
                data: null
        '409':
          description: The phone number is used by another account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 409
                error: Conflict
                message: The phone number is already taken.
                data: null
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          description: >-
            The phone number and national code check is temporarily unavailable.
            Try again later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    PhoneNumber:
      type: string
      pattern: ^09\d{9}$
      description: Iranian mobile number in the form `09XXXXXXXXX`.
      example: '09120000000'
    Error:
      type: object
      description: Standard error body.
      properties:
        statusCode:
          type: integer
        error:
          type: string
          description: HTTP status text.
        message:
          type: string
          description: What went wrong.
        data:
          type: object
          nullable: true
          description: >-
            Extra details. When present, `code` is a stable, machine-readable
            error code.
          properties:
            code:
              type: string
    AuthError:
      type: object
      description: Error body returned when the API token is rejected.
      properties:
        error:
          type: string
  responses:
    Unauthorized:
      description: The API token is missing, invalid or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
          example:
            error: Unauthorized.
    TooManyRequests:
      description: Too many requests. Wait and try again later.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 429
            error: Too Many Requests
            message: Too Many Requests
            data: null
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send your API token as `Authorization: Bearer <api-token>`. Tokens
        expire (30 days by default) and stop working when you change or reset
        your password.

````

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