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

# Assign Phone Number to a Voice Agent Route



## OpenAPI

````yaml /api-reference/openapi.json post /v1/voice-agents/assign-number
openapi: 3.0.1
info:
  title: Hamsa API
  description: Trying out our transcription and media-to-text APIs
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v1/voice-agents/assign-number:
    post:
      summary: Assign a phone number to a Voice Agent.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AssignPhoneNumberRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssignPhoneNumberResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '500':
          description: Server Side Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AssignPhoneNumberRequest:
      type: object
      properties:
        voiceAgentId:
          type: string
          description: UUID of the voice agent to assign phone number to.
          example: d949f13f-40d2-4e48-ac86-b66633070603
        phoneNumber:
          type: string
          description: >-
            Phone number to assign to voice agent, should start with + and the
            country code.
          example: '+9700000000'
      required:
        - voiceAgentId
        - twilioPhoneNumber
    AssignPhoneNumberResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Success
        data:
          $ref: '#/components/schemas/PhoneNumberRecord'
          type: object
    ErrorSchema:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
    PhoneNumberRecord:
      type: object
      properties:
        id:
          type: string
          example: d949f13f-40d2-4e48-ac86-b66633070603
        number:
          type: string
          example: '+9700000000'
        label:
          type: string
          example: My Twilio Number
        type:
          type: string
          enum:
            - TWILIO
            - SIP
          example: TWILIO
        userId:
          type: string
          example: d949f13f-40d2-4e48-ac86-b66633070603
        sipInboundConfigs:
          type: object
          properties:
            originationUri:
              type: string
              enum:
                - sip:sip.eu.tryhamsa.com:5060;transport=tcp
              example: sip:sip.eu.tryhamsa.com:5060;transport=tcp
        sipOutboundConfigs:
          type: object
          properties:
            address:
              type: string
              example: sip.example.com
              minLength: 1
            transportType:
              type: string
              enum:
                - TCP
                - UDP
              example: TCP
            customHeaders:
              type: object
              additionalProperties: true
        voiceAgentId:
          type: string
          nullable: true
          example: d949f13f-40d2-4e48-ac86-b66633070603
        voiceAgent:
          type: object
          properties:
            id:
              type: string
              example: d949f13f-40d2-4e48-ac86-b66633070603
            name:
              type: string
              example: My Voice Agent
        createdAt:
          type: string
          example: '2023-01-01T12:00:00Z'
        updatedAt:
          type: string
          example: '2023-02-01T12:00:00Z'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````