> ## 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 physical eSIM

> Purchases a physical eSIM from available inventory for the authenticated owner. Returns 409 when no stock is available, or 402 with a billing checkout URL when billing capacity is exhausted.



## OpenAPI

````yaml /api-reference/mobilerun-numbers.yaml post /numbers/esims
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/esims:
    post:
      tags:
        - Esims
      summary: Purchase a physical eSIM
      description: >-
        Purchases a physical eSIM from available inventory for the authenticated
        owner. Returns 409 when no stock is available, or 402 with a billing
        checkout URL when billing capacity is exhausted.
      operationId: purchaseEsim
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PurchaseEsimInput'
      responses:
        '201':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/PublicEsim'
                required:
                  - data
                type: object
          description: eSIM purchased
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EsimPaymentRequiredResponse'
          description: Payment required — billing capacity exhausted for this owner
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EsimErrorResponse'
          description: Conflict — see `reason` for the stable, machine-readable cause
        '500':
          description: Internal Server Error
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EsimErrorResponse'
          description: >-
            Service Unavailable — esims are disabled for this deployment (see
            `reason`)
      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 esim = await client.esims.create();

            console.log(esim.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
            )
            esim = client.esims.create()
            print(esim.data)
components:
  schemas:
    PurchaseEsimInput:
      properties:
        idempotencyKey:
          description: >-
            Client-supplied key; replaying the same key returns the original
            purchase instead of buying again
          maxLength: 128
          type: string
        name:
          description: >-
            Optional user-defined display label — NFC-normalized, up to 15
            GRAPHEMES. Omit or null for no label.
          example: Mom's phone
          type:
            - string
            - 'null'
      type: object
    PublicEsim:
      properties:
        cancellationScheduled:
          type: boolean
        carrierName:
          type:
            - string
            - 'null'
        checkoutUrl:
          type:
            - string
            - 'null'
        countryCode:
          type:
            - string
            - 'null'
        createdAt:
          format: date-time
          type:
            - string
            - 'null'
        createdBy:
          type:
            - string
            - 'null'
        currentPeriodEnd:
          format: date-time
          type:
            - string
            - 'null'
        deviceId:
          format: uuid
          type:
            - string
            - 'null'
        deviceUuid:
          type:
            - string
            - 'null'
        exempt:
          type: boolean
        iccid:
          type:
            - string
            - 'null'
        id:
          format: uuid
          type: string
        msisdn:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
        networkStatus:
          enum:
            - degraded
            - null
          type:
            - string
            - 'null'
        rentStatus:
          enum:
            - not_applicable
            - exempt
            - inactive
            - awaiting_payment
            - active
            - cancel_pending
            - refund_pending
            - retiring
            - billing_error
          type: string
        source:
          enum:
            - stocked
            - byo
          type: string
        status:
          enum:
            - in_stock
            - owned
            - installing
            - installed
            - install_failed
            - retired
          type: string
        subscriptionId:
          type:
            - integer
            - 'null'
        updatedAt:
          format: date-time
          type:
            - string
            - 'null'
      required:
        - id
        - status
        - source
        - carrierName
        - countryCode
        - iccid
        - subscriptionId
        - deviceId
        - deviceUuid
        - msisdn
        - name
        - createdBy
        - networkStatus
        - createdAt
        - updatedAt
      type: object
    EsimPaymentRequiredResponse:
      properties:
        checkoutUrl:
          type: string
        message:
          type: string
        reason:
          enum:
            - capacity_exhausted
          type: string
      required:
        - reason
        - message
        - checkoutUrl
      type: object
    EsimErrorResponse:
      properties:
        message:
          type: string
        reason:
          enum:
            - out_of_stock
            - owner_esim_cap
            - byo_disabled
            - byo_esim_cap
            - byo_daily_import_limit
            - byo_failed_limit
            - esim_not_owned
            - device_pool_empty
            - device_claim_cap
            - operator_resolution_required
            - idempotency_conflict
            - byo_awaiting_payment_cap
            - operator_review_required
            - byo_not_reassignable
            - product_disabled
          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

````