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

# Link SIP Trunk

> Link a BYOC number with SIP username and password or IP-based authentication.

Changes state - verify before retry
Links a bring-your-own phone number with username and password or IP-based SIP authentication and registers it for DialNexa routing. Use this path for SIP or BYOC numbers that were not purchased through DialNexa.

## When to use this

* **Keeping an existing number**: your business number already lives with another carrier and you want DialNexa agents to answer or dial from it.
* **Regulatory or cost constraints**: your carrier relationship must stay in place, so purchasing through [Buy Phone Number](https://dialnexa.com/docs/api-reference/v1/phone-numbers/buy.md) is not an option.
* **Migrating call infrastructure**: route existing SIP trunks through DialNexa without renumbering.

Calls on SIP trunk routes skip the Telephony destination checks that apply to provider numbers, since routing is governed by your trunk. A `400 Bad Request` means the trunk credentials or number failed validation; see [API errors](https://dialnexa.com/docs/api-reference/api-fundamentals.md#handle-dialnexa-api-errors) for the standard error format.

## Authentication Modes

| `authMode` | Required fields | Forbidden fields | Provider setup |
| - | - | - | - |
| `userpass` | `sipTrunkUserName`, `sipTrunkPassword` | None | Use the credentials issued by the provider. This is the default when `authMode` is omitted. |
| `ip` | None | `sipTrunkUserName`, `sipTrunkPassword` | Ask DialNexa support for the signaling IP used in your region, then have the provider allowlist it. |

`authMode` is `userpass` (the default) or `ip`. With `userpass`, both `sipTrunkUserName` and `sipTrunkPassword` are required; with `ip`, neither may be sent. Either mistake returns `400`. A number that is already registered in the workspace returns `409 Conflict`, and a registration that DialNexa's SIP routing rejects returns `502 Bad Gateway`, and nothing is saved. Send `phoneNumber` in E.164 form with the leading plus (for example `+14155552671`); a number that is not valid for its country returns `400`. Use a termination host and optional port without a `sip:` prefix. A `201 Created` response carries the new number's `id`, `country_iso` (the calling code, such as `1`), `phone_number` (the national digits as a JSON number, such as `4155552671`), `termination_uri`, `sip_trunk_enabled`, `nickname`, `auth_mode` and `sip_username` (`null` for `ip`); the password is never returned. After the request succeeds, place a controlled inbound and outbound test, then confirm routing, audio, recording, and Call History evidence. Do not retry after an uncertain timeout until [List Phone Numbers](https://dialnexa.com/docs/api-reference/v1/phone-numbers/list.md) confirms whether the number was created.

## Related endpoints

* [SIP Trunking](https://dialnexa.com/docs/calls/sip-trunking.md): configure BYOC routing in the dashboard.
* [Buy Phone Number](https://dialnexa.com/docs/api-reference/v1/phone-numbers/buy.md): purchase a provider number instead.
* [Delete Phone Number](https://dialnexa.com/docs/api-reference/v1/phone-numbers/delete.md): remove the SIP trunk number and routing credentials.


## OpenAPI

````yaml POST /v1/organization-phone-numbers/sip-trunks
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/sip-trunks:
    post:
      tags:
        - Phone Numbers
      summary: Link SIP Trunk
      description: >-
        Registers a bring-your-own number with SIP trunk credentials for
        workspace routing.
      operationId: linkSipTrunk
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LinkSipTrunkRequest'
            examples:
              request:
                summary: Link a SIP trunk
                value:
                  phoneNumber: '+14155552671'
                  terminationUri: 31974861099010243.zt.plivo.com:5060
                  authMode: userpass
                  sipTrunkUserName: sip-user
                  sipTrunkPassword: YOUR_SIP_PASSWORD
                  nickname: US BYOC Line
      responses:
        '201':
          description: SIP trunk linked successfully.
          content:
            application/json:
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    error: false
                    statusCode: 201
                    message: Success
                    data:
                      id: phn_mfk3p8z2c4v6bn
                      country_iso: '1'
                      phone_number: 4155552671
                      termination_uri: 31974861099010243.zt.plivo.com:5060
                      sip_trunk_enabled: true
                      nickname: US BYOC Line
                      auth_mode: userpass
                      sip_username: sip-user
                    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:
                      - id
                      - country_iso
                      - phone_number
                      - termination_uri
                      - sip_trunk_enabled
                      - nickname
                      - auth_mode
                      - sip_username
                    properties:
                      id:
                        type: string
                        example: phn_mfk3p8z2c4v6bn
                        description: Signed phone number ID.
                      country_iso:
                        type: string
                        example: '1'
                        description: Country calling code without the plus sign.
                      phone_number:
                        type: integer
                        format: int64
                        example: 4155552671
                        description: >-
                          National number without the calling code, as a JSON
                          number.
                      termination_uri:
                        type: string
                        example: 31974861099010243.zt.plivo.com:5060
                      sip_trunk_enabled:
                        type: boolean
                        enum:
                          - true
                      nickname:
                        type: string
                        nullable: true
                      auth_mode:
                        type: string
                        enum:
                          - userpass
                          - ip
                      sip_username:
                        type: string
                        nullable: true
                        description: null for authMode ip.
                  timestamp:
                    type: string
                    format: date-time
        '400':
          description: >-
            Invalid number, termination host, authentication mode, or credential
            combination.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 400 Bad Request
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: >-
                      sipTrunkUserName and sipTrunkPassword are required when
                      authMode is userpass
                    errors:
                      - >-
                        sipTrunkUserName and sipTrunkPassword are required when
                        authMode is userpass
        '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: []
        '409':
          description: Phone number already registered
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 409 Conflict
                  value:
                    statusCode: 409
                    error: true
                    success: false
                    data: []
                    message: >-
                      This phone number is already registered for your
                      organization
                    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: Internal server error
                    errors: []
        '502':
          description: >-
            SIP trunk registration failed. Nothing is saved; retry or contact
            support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer: []
components:
  schemas:
    LinkSipTrunkRequest:
      type: object
      properties:
        phoneNumber:
          type: string
          maxLength: 32
          example: '+14155552671'
          description: >-
            Phone number in E.164 form with the leading plus, for example
            +14155552671. It must be a valid number for its country.
        terminationUri:
          type: string
          maxLength: 2048
          example: 31974861099010243.zt.plivo.com:5060
          description: 'SIP termination host[:port]; must not use a sip: URI prefix'
        authMode:
          enum:
            - userpass
            - ip
          type: string
          default: userpass
          description: >-
            How the provider authorizes this trunk. 'userpass' requires
            sipTrunkUserName and sipTrunkPassword; 'ip' requires both to be
            omitted and expects the provider to have whitelisted our signaling
            IP.
        sipTrunkUserName:
          type: string
          maxLength: 512
          description: >-
            SIP authentication username. Required for authMode=userpass,
            forbidden for ip.
        sipTrunkPassword:
          type: string
          maxLength: 512
          description: >-
            SIP authentication password stored encrypted. Required for
            authMode=userpass and forbidden for authMode=ip.
        nickname:
          type: string
          maxLength: 255
          description: Display nickname for this trunk
      required:
        - phoneNumber
        - terminationUri
    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.