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

# Purchase a phone number

> Starts a Mobilerun Phone purchase for the authenticated owner. Accepted requests always return the same asynchronous envelope; poll GET /numbers/phones/{id} for its business state. `purpose` and `country` are mutually exclusive.



## OpenAPI

````yaml /api-reference/mobilerun-numbers.yaml post /numbers/phones
openapi: 3.1.0
info:
  title: Mobilerun Numbers
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /numbers/phones:
    post:
      tags:
        - Numbers
      summary: Purchase a phone number
      description: >-
        Starts a Mobilerun Phone purchase for the authenticated owner. Accepted
        requests always return the same asynchronous envelope; poll GET
        /numbers/phones/{id} for its business state. `purpose` and `country` are
        mutually exclusive.
      operationId: purchaseNumber
      parameters:
        - description: Optional request idempotency key.
          in: header
          name: Idempotency-Key
          required: false
          schema:
            description: Optional request idempotency key.
            maxLength: 128
            minLength: 1
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicPhonePurchaseInput'
      responses:
        '202':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/PurchaseAcceptedResponse'
                required:
                  - data
                type: object
          description: Number purchase accepted — poll GET /numbers/phones/{id}
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicPhonePurchaseError'
          description: Purchase in progress
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicPhonePurchaseError'
          description: Unsupported purpose or country
        '500':
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/PublicPhonePurchaseError'
                  - $ref: '#/components/schemas/NumberErrorResponse'
          description: Purchase unavailable
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Mobilerun from '@mobilerun/sdk';

            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });

            const number = await client.numbers.create();

            console.log(number.data);
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            number = client.numbers.create()
            print(number.data)
components:
  schemas:
    PublicPhonePurchaseInput:
      additionalProperties: false
      properties:
        billingPreference:
          description: >-
            Prefer a free package seat ('included', default) or force the paid
            checkout ('rent')
          enum:
            - included
            - rent
          type: string
        country:
          description: >-
            Optional ISO 3166-1 alpha-2 country code from GET
            /numbers/countries. Cannot be combined with `purpose`.
          example: de
          maxLength: 2
          minLength: 2
          pattern: ^[a-z]{2}$
          type: string
        label:
          description: >-
            User-defined display label — NFC-normalized, up to 100 GRAPHEMES
            (not UTF-16 code units; an emoji/flag may span several).
            Display-only, never used for routing. Also seeds the billing entity
            name at purchase.
          example: Support line
          type:
            - string
            - 'null'
        purpose:
          description: Optional Mobilerun Phone purpose slug from GET /numbers/purposes.
          example: telegram
          maxLength: 96
          minLength: 1
          type: string
      type: object
    PurchaseAcceptedResponse:
      properties:
        checkoutUrl:
          type:
            - string
            - 'null'
        numberId:
          format: uuid
          type: string
        state:
          enum:
            - awaiting_payment
            - provisioning
          type: string
      required:
        - numberId
        - state
        - checkoutUrl
      type: object
    PublicPhonePurchaseError:
      properties:
        message:
          type: string
        reason:
          enum:
            - purchase_in_progress
            - unsupported_purpose
            - unsupported_country
            - unavailable
          type: string
      required:
        - reason
        - message
      type: object
    NumberErrorResponse:
      properties:
        message:
          type: string
        reason:
          enum:
            - product_disabled
            - not_cancellable
          type: string
        success:
          enum:
            - false
          type: boolean
      required:
        - success
        - reason
        - message
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````