> ## 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.

# Add Phone Number to a User Route



## OpenAPI

````yaml /api-reference/openapi.json post /v1/voice-agents/phone-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/phone-number:
    post:
      summary: Add a phone number for a user.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddPhoneNumberRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddPhoneNumberResponse'
        '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:
    AddPhoneNumberRequest:
      oneOf:
        - type: object
          required:
            - type
            - phoneNumber
            - label
            - twilioAccountSid
            - twilioAuthToken
          properties:
            type:
              type: string
              description: The type of phone number to add, TWILIO in this case.
              enum:
                - TWILIO
            phoneNumber:
              type: string
              minLength: 1
              description: The phone number to add to the Twilio numbers of a user.
            label:
              type: string
              description: A label to identify the phone number.
              minLength: 1
            twilioAccountSid:
              type: string
              description: The Twilio Account SID associated with the Twilio number.
              minLength: 1
            twilioAuthToken:
              type: string
              description: The Twilio Auth Token for authenticating API requests.
              minLength: 1
        - type: object
          required:
            - type
            - phoneNumber
            - label
            - sipInboundConfigs
            - sipOutboundConfigs
          properties:
            type:
              type: string
              description: The type of phone number to add, SIP in this case.
              enum:
                - SIP
            phoneNumber:
              type: string
              minLength: 1
              description: The phone number to add to the SIP numbers of a user.
            label:
              type: string
              description: A label to identify the phone number.
              minLength: 1
            sipInboundConfigs:
              type: object
              required:
                - originationUri
              properties:
                originationUri:
                  type: string
                  minLength: 1
                  enum:
                    - sip:sip.eu.tryhamsa.com:5060;transport=tcp
                  example: sip:sip.eu.tryhamsa.com:5060;transport=tcp
            sipOutboundConfigs:
              type: object
              required:
                - address
                - transportType
              properties:
                address:
                  type: string
                  minLength: 1
                transportType:
                  type: string
                  minLength: 1
                  enum:
                    - UDP
                    - TCP
                  example: TCP
                customHeaders:
                  type: object
                  additionalProperties:
                    type: string
                sipTrunkUsername:
                  type: string
                  minLength: 1
                sipTrunkPassword:
                  type: string
                  minLength: 1
    AddPhoneNumberResponse:
      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>'

````