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

# Buy Phone Number

> Purchase a number through the selected provider.

Changes state - verify before retry
Purchases a phone number from your telephony provider and provisions it in your DialNexa workspace. Confirm that the saved number is active before assigning it for inbound or outbound calls; a provider purchase can remain pending while verification completes. On a workspace with a billing plan, the price is the plan's rental rate for the provider and country (in INR), not the reference price in [List Phone Number Pricing](https://dialnexa.com/docs/api-reference/v1/phone-numbers/list-pricing.md). On such a workspace, the first rental cycle is charged from your wallet just after the number is set up, and later cycles are charged automatically when they come due. If the first charge does not go through, DialNexa retries it on the next renewal run, and the rental expires if the balance is still too low. The cycle length comes from your billing plan and is 30 days unless the plan says otherwise. A workspace without a billing plan is not charged a rental. Use [Search Available Numbers](https://dialnexa.com/docs/api-reference/v1/phone-numbers/search-plivo.md) first to find a number that fits your needs, then pass the number back exactly as the search returned it. Providers differ on the leading plus sign, so this endpoint accepts the country code and subscriber number with or without it. Anything other than digits and an optional leading plus is rejected before a provider call is made.

The response `data` carries the number as sent, the provider purchase `status` (`active`, or `pending` while the provider verifies the number), a `message`, and `organizationPhoneNumber`, the new workspace record. That record stores the number as `country_iso` (the calling code, such as `1`) plus `phone_number` (the national digits, such as `4155552671`) and shows the stored status at creation (`pending`). Call [Get Phone Number Details](https://dialnexa.com/docs/api-reference/v1/phone-numbers/get.md) for its current status and rental dates.

Use [Search Available Numbers](https://dialnexa.com/docs/api-reference/v1/phone-numbers/search-plivo.md) first and pass the number exactly as the search returned it. The request accepts digits with an optional leading `+`; other characters fail request validation before the provider is called.

## When To Buy A Phone Number

* **New deployments**: provisioning the first number for a region or use case.
* **Dedicated caller IDs**: separate regional, customer, or brand phone numbers.
* **Per-customer or per-brand numbers**: provisioning a dedicated number for a sub-account, partner, or brand.

For India deployments, the recommended path is purchasing through [Plivo](https://dialnexa.com/docs/calls/sip-trunking.md). For Bring-Your-Own-SIP setups, numbers from your own carrier are connected through SIP trunks rather than purchased here, see [Bring Your Own SIP](https://dialnexa.com/docs/calls/sip-trunking.md).

## Pre-flight checklist

Before purchasing, confirm:

* The selected provider’s verification is complete. Plivo and other standard provider paths require workspace KYC; Vobiz requires the workspace’s separate verified Vobiz account.
* For an Indian (`IN`) Plivo number, DialNexa support has mapped a Plivo compliance ID to the workspace; without it the purchase is refused.
* On a workspace with a billing plan, the wallet holds at least the first rental cycle's cost, and that cost does not take the month's spend past the monthly spend cap.
* The destination country is enabled in **Workspace Settings → Telephony** before you place calls from the number.

## Buy Phone Number With Vobiz

Vobiz uses its own business verification. Complete the Vobiz card under **Workspace settings > Telephony > KYC** before requesting a Vobiz purchase. Plivo verification alone does not satisfy that requirement.

Use the Vobiz provider ID and an available Indian number from the dashboard’s Vobiz inventory. The Plivo search endpoint linked above searches Plivo inventory, so do not use its results for a Vobiz purchase. The Vobiz purchase path returns `active` when the provider confirms the purchase; confirm the workspace record and test inbound routing separately before directing callers to it.

The normal rental-plan, balance, and monthly spend-cap checks still apply. A Vobiz KYC refusal can return `400`; a provider or other purchase failure can return `500`. After an uncertain result, check workspace numbers before retrying.

## Verify The Purchase Before Retrying

Read `data.status` and `data.organizationPhoneNumber.id` in the success envelope, then use [List Phone Numbers](https://dialnexa.com/docs/api-reference/v1/phone-numbers/list.md) or [Get Phone Number Details](https://dialnexa.com/docs/api-reference/v1/phone-numbers/get.md) to confirm the saved number and its status. Check the wallet transactions separately for the first rental charge. If the purchase is pending, wait for activation before routing calls.

Purchasing changes provider inventory and, on a workspace with a billing plan, creates a rental subscription. There is no idempotency key on this operation. After a timeout or uncertain failure, inspect your workspace numbers and provider inventory before retrying; contact support if the provider purchase succeeded but registration failed.

## Errors

* `400 Bad Request` is returned when the workspace's KYC is not verified, an `IN` Plivo number is requested and no compliance ID is mapped to the workspace, the wallet balance is below the first rental cycle's cost (the message states the required and available amounts), the first rental would take the month's spend past the monthly spend cap (`This purchase (₹X) would go over your monthly spend cap. ...`), number rental is not configured for your billing plan, the number format is invalid, or the provider ID is not supported.
* If the provider rejects the purchase, for example because the number was taken between the search and the purchase, the API returns `500` with the message `Error purchasing phone number: ` followed by the provider's reason. After a `5xx` or a timeout, list your numbers before retrying.
* `countryISO` must be the country of the number being bought. A mismatch fails with `500` and the message `Error purchasing phone number: Invalid phone number or ISO code`; contact support before retrying.

## Related endpoints

* [Search Available Numbers](https://dialnexa.com/docs/api-reference/v1/phone-numbers/search-plivo.md): find a number to purchase.
* [List Phone Numbers](https://dialnexa.com/docs/api-reference/v1/phone-numbers/list.md): confirm the purchased number appears in your workspace.
* [Get Phone Number Details](https://dialnexa.com/docs/api-reference/v1/phone-numbers/get.md): inspect the purchased number by ID.
* [Delete Phone Number](https://dialnexa.com/docs/api-reference/v1/phone-numbers/delete.md): remove a number you no longer use.
* [Purchase a Phone Number guide](https://dialnexa.com/docs/calls/phone-numbers.md): end-to-end provisioning walkthrough.
* [KYC and outbound readiness](https://dialnexa.com/docs/platform/kyc-and-outbound-readiness.md): verification required before purchasing in regulated regions.


## OpenAPI

````yaml POST /v1/organization-phone-numbers/purchase
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Organization Folders
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
  - name: Agent Evaluations
paths:
  /v1/organization-phone-numbers/purchase:
    post:
      tags:
        - Phone Numbers
      summary: Buy Phone Number
      description: >-
        Purchases the selected provider number (Plivo or Twilio, chosen by
        telephonyProviderId) and adds it to the authenticated workspace. The
        workspace KYC must be verified, and a Plivo number in IN needs a
        compliance ID mapped to the workspace by support. On a workspace with a
        billing plan, the wallet must hold the plan's rental rate for the
        provider and country; the first cycle is charged just after the number
        is set up.
      operationId: purchasePhoneNumber
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PurchasePhoneNumberRequest'
            examples:
              request:
                summary: Purchase a phone number
                value:
                  phoneNumber: '14155552671'
                  telephonyProviderId: mh00mke5j83neo
                  countryISO: US
      responses:
        '201':
          description: >-
            Purchase processed. Inspect the active or pending status and confirm
            the saved number before routing calls.
          content:
            application/json:
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    error: false
                    statusCode: 201
                    message: Success
                    data:
                      phoneNumber: '14155552671'
                      status: active
                      message: Phone number 14155552671 purchase request sent.
                      organizationPhoneNumber:
                        id: phn_mfk3p8z2c4v6bn
                        phone_number: '4155552671'
                        status: pending
                        country_iso: '1'
                        telephony_provider_id: mh00mke5j83neo
                        organization_id: o14XKPP84rt22g
                        inbound_agent_id: null
                        outbound_agent_id: null
                        rental_start_date: null
                        rental_end_date: null
                        rental_status: null
                        sip_trunk_enabled: false
                        nickname: null
                        is_deleted: false
                        deleted_at: null
                        deleted_by: null
                        created_at: '2026-09-17T05:52:18.634Z'
                        updated_at: '2026-09-17T05:52:18.634Z'
                    timestamp: '2026-09-07T06:00:00.000Z'
              schema:
                type: object
                required:
                  - success
                  - error
                  - statusCode
                  - message
                  - data
                  - timestamp
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  error:
                    type: boolean
                    enum:
                      - false
                  statusCode:
                    type: integer
                    example: 201
                  message:
                    type: string
                    example: Success
                  data:
                    type: object
                    required:
                      - phoneNumber
                      - status
                      - message
                    properties:
                      phoneNumber:
                        type: string
                        description: The number as sent in the request.
                      status:
                        type: string
                        enum:
                          - active
                          - pending
                        description: >-
                          Provider purchase status. pending means the provider
                          is still verifying the number.
                      message:
                        type: string
                        example: Phone number 14155552671 purchase request sent.
                      organizationPhoneNumber:
                        allOf:
                          - $ref: '#/components/schemas/PhoneNumberRecord'
                        description: >-
                          The workspace phone number record as created. Its
                          status is the stored default (pending) at creation;
                          read the number again for its current status and
                          rental dates.
                  timestamp:
                    type: string
                    format: date-time
        '400':
          description: >-
            Invalid request body, unsupported telephonyProviderId, organization
            KYC not verified, no compliance ID mapped for an IN Plivo number,
            phone number rental not configured for the billing plan,
            insufficient wallet balance, the first rental would go over the
            monthly spend cap, or the number was bought but could not be set up.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 400 Bad Request
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: >-
                      countryISO must be a 2-letter uppercase ISO code (e.g.,
                      US, IN)
                    errors:
                      - >-
                        countryISO must be a 2-letter uppercase ISO code (e.g.,
                        US, IN)
                spendCap:
                  summary: Monthly spend cap
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: >-
                      This purchase (₹500.00) would go over your monthly spend
                      cap. Raise the cap in Billing → Balance alerts, or try
                      again after the 1st.
                    errors:
                      - >-
                        This purchase (₹500.00) would go over your monthly spend
                        cap. Raise the cap in Billing → Balance alerts, or try
                        again after the 1st.
        '401':
          description: Unauthorized - missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 401 Unauthorized
                  value:
                    statusCode: 401
                    error: true
                    success: false
                    data: []
                    message: Invalid API key
                    errors: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 500 Internal Server Error
                  value:
                    statusCode: 500
                    error: true
                    success: false
                    data: []
                    message: >-
                      Error purchasing phone number: Invalid phone number or ISO
                      code
                    errors: []
      security:
        - bearer: []
components:
  schemas:
    PurchasePhoneNumberRequest:
      type: object
      properties:
        phoneNumber:
          type: string
          pattern: ^\+?[1-9]\d{5,14}$
          example: '+12025551234'
          description: >-
            Phone number to purchase: country code followed by the subscriber
            number, digits only, with or without a leading plus sign. Both
            +12025551234 and 12025551234 are accepted.
        telephonyProviderId:
          type: string
          example: mh00mke5j83neo
          description: ID of telephony provider (14-char string)
        countryISO:
          type: string
          minLength: 2
          maxLength: 2
          pattern: ^[A-Z]{2}$
          example: US
          description: >-
            Uppercase two-letter country code of the number being bought, for
            example US. It must be the number's own country: a mismatch fails
            with 500 after the provider step.
      required:
        - phoneNumber
        - telephonyProviderId
        - countryISO
    PhoneNumberRecord:
      type: object
      description: >-
        A phone number owned by the workspace, as stored. Returned by the list
        and get endpoints.
      properties:
        id:
          type: string
          example: phn_mfk3p8z2c4v6bn
          description: Signed phone number ID.
        phone_number:
          type: string
          example: '9876543210'
          pattern: ^[0-9]+$
          description: >-
            National number without the country calling code or a plus sign, as
            a string of digits. Build the E.164 form as + followed by
            country_iso and phone_number.
        status:
          type: string
          enum:
            - pending
            - active
          description: Provisioning status of the number.
        country_iso:
          type: string
          example: '91'
          description: >-
            Country calling code without the plus sign, for example 91 or 1.
            This is not an ISO country code.
        telephony_provider_id:
          type: string
          description: Telephony provider the number belongs to.
        organization_id:
          type: string
          description: Owning organization.
        inbound_agent_id:
          type: string
          nullable: true
          description: >-
            Agent that answers inbound calls on this number, on its latest
            published version; null when none is linked.
        outbound_agent_id:
          type: string
          nullable: true
          description: Agent that can call from this number; null when none is linked.
        rental_start_date:
          type: string
          format: date
          nullable: true
          example: '2026-09-17'
        rental_end_date:
          type: string
          format: date
          nullable: true
          example: '2026-10-17'
        rental_status:
          type: string
          nullable: true
          enum:
            - active
            - expired
            - available_for_reassignment
        sip_trunk_enabled:
          type: boolean
          description: Whether a SIP trunk is linked to this number.
        nickname:
          type: string
          nullable: true
          description: Label set in the dashboard.
        is_deleted:
          type: boolean
        deleted_at:
          type: string
          format: date-time
          nullable: true
        deleted_by:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - phone_number
        - status
    ErrorResponse:
      type: object
      description: Error body on endpoints without response filtering.
      properties:
        statusCode:
          type: integer
          example: 404
        error:
          type: boolean
          enum:
            - true
        success:
          type: boolean
          enum:
            - false
        data:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable refusal code.
            - type: array
              items: {}
          description: >-
            For a coded refusal, an object with code and the details listed for
            that code. Otherwise an empty array.
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: Validation messages for a 400. Empty for other errors.
        validation_errors:
          type: array
          description: >-
            Present when uploaded rows fail number validation (batch and
            workflow lead uploads): one group per distinct error.
          items:
            type: object
            properties:
              error:
                type: string
              rows:
                type: array
                items:
                  type: integer
                description: Row numbers with this error.
              phone_numbers:
                type: array
                items:
                  type: string
        invalid_row_count:
          type: integer
          description: 'Present with validation_errors: how many rows failed.'
      required:
        - statusCode
        - error
        - success
        - data
        - message
        - errors
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````

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