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

# Buy phone number

> Buy a phone number from a telephony provider.



## OpenAPI

````yaml api-reference/telephony/openapi.json POST /v1/telephony/phone-numbers/buy
openapi: 3.0.3
info:
  title: Persistence Telephony API
  version: '1.0'
  description: Manage the phone numbers your agents call from and answer on.
servers:
  - url: https://api.persistence.dev
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Telephony
    description: Phone number management.
paths:
  /v1/telephony/phone-numbers/buy:
    post:
      tags:
        - Telephony
      summary: Buy a phone number
      description: >-
        Buy a phone number from a telephony provider. The number is added to
        your workspace and can then be bound to an agent.
      operationId: buyPhoneNumber
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuyPhoneNumberRequest'
        description: Buy number request
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneNumber'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    BuyPhoneNumberRequest:
      type: object
      required:
        - phoneNumber
        - provider
      properties:
        phoneNumber:
          type: string
        provider:
          type: string
    PhoneNumber:
      type: object
      properties:
        allowedInboundCountries:
          type: array
          items:
            type: string
        allowedOutboundCountries:
          type: array
          items:
            type: string
        country:
          type: string
        createdAt:
          type: string
        friendlyName:
          type: string
        id:
          type: string
        inboundAgentName:
          type: string
        inboundAgentPublicId:
          type: string
        inboundWebhookUrl:
          type: string
        isCustomerManaged:
          type: boolean
        isInboundReady:
          type: boolean
        isOutboundReady:
          type: boolean
        label:
          type: string
        outboundAgentName:
          type: string
        outboundAgentPublicId:
          type: string
        phoneNumber:
          type: string
        provider:
          type: string
        providerCurrency:
          type: string
        providerMonthlyCost:
          type: number
        sipConfig:
          $ref: '#/components/schemas/SipConfig'
        spaceId:
          type: string
        status:
          type: string
        updatedAt:
          type: string
    Error:
      type: object
      properties:
        code:
          type: string
        error:
          type: string
    SipConfig:
      type: object
      properties:
        ipAllowlist:
          type: array
          items:
            type: string
        password:
          type: string
        terminationUrl:
          type: string
        transport:
          type: string
        username:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key issued for your workspace.

````