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

# Update a SIP Trunk

Omitted fields are left unchanged.

## Default route

`inbound.default_route` sets, replaces or clears the agent that receives calls to numbers with no extension on the trunk. See [Default route](/api-reference/sip-trunking/endpoint/create-a-sip-trunk#default-route) for how it interacts with extensions.

<CodeGroup>
  ```bash Request theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X PATCH https://api.us.poly.ai/v1/accounts/ACCOUNT_ID/telephony/sip-trunks/TRUNK_ID \
    -H "X-API-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "inbound": {
        "default_route": { "agent": { "agent_id": "my-agent", "client_env": "live" } }
      }
    }'
  ```

  ```json Response theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "id": "tr-0123456789abcdefghijklmn",
    "inbound": {
      "hostname": "tr-0123456789abcdefghijklmn.sbc.sip.us.poly.ai",
      "sip_auth": { "enabled": false },
      "sip_token_auth": { "enabled": true },
      "default_route": {
        "agent": { "agent_id": "my-agent", "client_env": "live", "variant_id": "" }
      }
    },
    …
  }
  ```
</CodeGroup>

| To | Send |
| - | - |
| Set | `{"inbound": {"default_route": {"agent": {"agent_id": "my-agent", "client_env": "live"}}}}` |
| Replace | The same, with a different `agent` |
| Clear | `{"inbound": {"default_route": {"disable": true}}}` |

Provide exactly one of `agent` or `disable: true`; anything else returns `400`. Omitting `default_route` leaves it unchanged. Changes can take up to a minute to affect calls.


## OpenAPI

````yaml PATCH /v1/accounts/{account_id}/telephony/sip-trunks/{trunk_id}
openapi: 3.0.3
info:
  title: PolyAI SIP Trunking API
  version: 1.0.0
  description: Management API for PolyAI SIP Trunks and their Extensions.
servers:
  - url: https://api.us.poly.ai
    description: US region
  - url: https://api.eu.poly.ai
    description: EU region
  - url: https://api.uk.poly.ai
    description: UK region
security:
  - polyApiKey: []
tags:
  - name: SIP Trunks
    description: >-
      A SIP Trunk is a virtual connection between your telephony platform and
      PolyAI. It authenticates callers, accepts inbound calls, and holds the
      list of Extensions that map a dialed number to a PolyAI agent.
  - name: SIP Trunk Extensions
    description: >-
      An Extension binds a dialed number on a trunk to a PolyAI agent. When a
      call reaches a trunk, the dialed user part is matched against that trunk's
      extensions to pick the agent.
  - name: Outbound Calls
    description: Place and query outbound calls that route over a SIP Trunk.
paths:
  /v1/accounts/{account_id}/telephony/sip-trunks/{trunk_id}:
    parameters:
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/trunk_id'
    patch:
      tags:
        - SIP Trunks
      summary: Update a SIP Trunk
      operationId: updateSipTrunk
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSipTrunkRequest'
      responses:
        '200':
          description: The updated SIP Trunk.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SipTrunk'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
components:
  parameters:
    account_id:
      name: account_id
      in: path
      required: true
      description: ID of the account that owns the SIP Trunk.
      schema:
        type: string
    trunk_id:
      name: trunk_id
      in: path
      required: true
      description: The SIP Trunk ID.
      schema:
        type: string
  schemas:
    UpdateSipTrunkRequest:
      type: object
      additionalProperties: false
      description: >-
        Send only the fields you want to change; anything omitted is left
        unchanged. The owning account is immutable and cannot be changed.
      properties:
        sip_cidr:
          type: array
          description: The IPv4 CIDR blocks of your SIP servers. Omit to leave unchanged.
          minItems: 1
          maxItems: 10
          items:
            type: string
            maxLength: 43
        rtp_cidr:
          type: array
          description: >-
            The IPv4 CIDR blocks of your RTP / media servers. Omit to leave
            unchanged.
          minItems: 1
          maxItems: 10
          items:
            type: string
            maxLength: 43
        name:
          type: string
          description: >-
            A friendly name to help identify your SIP Trunk. Omit to leave
            unchanged.
          minLength: 1
          maxLength: 255
          pattern: \S
        encrypted:
          type: boolean
          description: >-
            Whether this SIP Trunk will handle encrypted (true; SIP over
            TCP/TLS, media over UDP/SRTP) or unencrypted (false; SIP over UDP,
            media over UDP/RTP) calls.
        inbound:
          $ref: '#/components/schemas/UpdateSipTrunkInbound'
        outbound:
          $ref: '#/components/schemas/UpdateSipTrunkOutbound'
    SipTrunk:
      type: object
      description: A SIP Trunk.
      properties:
        id:
          type: string
          description: PolyAI-generated SIP Trunk ID, e.g. `tr-0123456789abcdefghijklmn`.
        account_id:
          type: string
          description: The PolyAI account that owns the SIP Trunk.
        sip_cidr:
          type: array
          description: The IPv4 CIDR blocks of your SIP servers.
          items:
            type: string
        rtp_cidr:
          type: array
          description: The IPv4 CIDR blocks of your RTP / media servers.
          items:
            type: string
        name:
          type: string
          description: A friendly name to help identify your SIP Trunk.
        encrypted:
          type: boolean
          description: >-
            Whether this SIP Trunk will handle encrypted (true; SIP over
            TCP/TLS, media over UDP/SRTP) or unencrypted (false; SIP over UDP,
            media over UDP/RTP) calls.
        inbound:
          $ref: '#/components/schemas/SipTrunkInbound'
        outbound:
          $ref: '#/components/schemas/SipTrunkOutbound'
        created_at:
          type: string
          format: date-time
          description: RFC 3339 timestamp of when the SIP Trunk was created.
        updated_at:
          type: string
          format: date-time
          description: RFC 3339 timestamp of when the SIP Trunk was last updated.
      required:
        - id
        - account_id
        - sip_cidr
        - rtp_cidr
        - name
        - encrypted
        - inbound
        - created_at
        - updated_at
    UpdateSipTrunkInbound:
      type: object
      additionalProperties: false
      description: >-
        Configuration for inbound calls. sip_auth and sip_token_auth are
        mutually exclusive.
      properties:
        sip_auth:
          $ref: '#/components/schemas/UpdateSipAuthConfig'
        sip_token_auth:
          $ref: '#/components/schemas/UpdateTokenAuthConfig'
        default_route:
          $ref: '#/components/schemas/UpdateDefaultRoute'
    UpdateSipTrunkOutbound:
      type: object
      additionalProperties: false
      description: Configuration for outbound calls leaving PolyAI.
      properties:
        sip_addresses:
          type: array
          description: >-
            The SIP addresses of your SIP servers to send outbound calls to.
            Omit to leave unchanged. Each must be a `sip:` or `sips:` URI,
            optionally with a port and a transport parameter, and must not
            include a user part.
          maxItems: 4
          example:
            - sip:my-sbc.example.com:5060
            - sip:my-sbc.example.com:5061;transport=tls
          items:
            type: string
            maxLength: 255
        default_caller_id:
          type: string
          description: Default caller ID to use on outbound calls. Omit to leave unchanged.
          maxLength: 128
    SipTrunkInbound:
      type: object
      description: Configuration for inbound calls.
      properties:
        hostname:
          type: string
          description: Hostname that uniquely identifies this SIP Trunk.
        sip_auth:
          $ref: '#/components/schemas/SipAuth'
        sip_token_auth:
          $ref: '#/components/schemas/SipTokenAuth'
        default_route:
          $ref: '#/components/schemas/DefaultRoute'
      required:
        - hostname
        - sip_auth
        - sip_token_auth
    SipTrunkOutbound:
      type: object
      description: Configuration for outbound calls leaving PolyAI.
      properties:
        sip_addresses:
          type: array
          description: The SIP addresses of your SIP servers to send outbound calls to.
          example:
            - sip:my-sbc.example.com:5060
            - sip:my-sbc.example.com:5061;transport=tls
          items:
            type: string
        default_caller_id:
          type: string
          description: Default caller ID to use on outbound calls.
    Error:
      type: object
      description: Error response body.
      properties:
        success:
          type: boolean
        error:
          type: string
        message:
          type: string
      required:
        - success
        - error
        - message
    UpdateSipAuthConfig:
      type: object
      additionalProperties: false
      description: >-
        SIP digest credentials. Mutually exclusive with sip_token_auth. SIP
        digest passwords are never returned on reads — keep your own record of
        anything you set.
      properties:
        disable:
          type: boolean
          description: Set to true to clear the SIP digest credentials.
        username:
          type: string
          description: SIP digest auth username.
          maxLength: 255
        password:
          type: string
          description: SIP digest auth password.
          maxLength: 255
    UpdateTokenAuthConfig:
      type: object
      additionalProperties: false
      description: >-
        SIP token credentials. Mutually exclusive with sip_auth. SIP tokens are
        never returned on reads — keep your own record of anything you set.
      properties:
        disable:
          type: boolean
          description: Set to true to clear the SIP token.
        token:
          type: string
          description: SIP token.
          maxLength: 1024
    UpdateDefaultRoute:
      type: object
      additionalProperties: false
      description: >-
        Sets, replaces or clears the default route. Provide exactly one of
        `agent` or `disable`.
      properties:
        disable:
          type: boolean
          description: Set to true to remove the default route.
        agent:
          $ref: '#/components/schemas/AgentRequest'
    SipAuth:
      type: object
      description: SIP digest auth state.
      properties:
        enabled:
          type: boolean
          description: Whether SIP digest auth is enabled for this SIP Trunk.
        username:
          type: string
          description: SIP digest auth username. Present when enabled.
        realm:
          type: string
          description: SIP digest auth realm. Present when enabled.
      required:
        - enabled
    SipTokenAuth:
      type: object
      description: SIP token auth state.
      properties:
        enabled:
          type: boolean
          description: Whether SIP token auth is enabled for this SIP Trunk.
      required:
        - enabled
    DefaultRoute:
      type: object
      description: >-
        The agent that receives inbound calls whose dialed number has no
        extension on the trunk. Omitted when the trunk has no default route, in
        which case such calls are rejected.
      properties:
        agent:
          $ref: '#/components/schemas/Agent'
      required:
        - agent
    AgentRequest:
      type: object
      additionalProperties: false
      description: The PolyAI agent to bind an extension to.
      properties:
        agent_id:
          type: string
          description: PolyAI Agent / Project ID to route to.
          minLength: 1
          maxLength: 255
          pattern: \S
        client_env:
          type: string
          description: One of sandbox, pre-release, live.
          enum:
            - sandbox
            - pre-release
            - live
        variant_id:
          type: string
          description: Agent variant to route to.
          maxLength: 255
      required:
        - agent_id
        - client_env
    Agent:
      type: object
      description: The PolyAI agent an extension routes calls to.
      properties:
        agent_id:
          type: string
          description: PolyAI Agent / Project ID to route to.
        client_env:
          type: string
          description: One of sandbox, pre-release, live.
          enum:
            - sandbox
            - pre-release
            - live
        variant_id:
          type: string
          description: Agent variant to route to.
      required:
        - agent_id
        - client_env
        - variant_id
  responses:
    BadRequest:
      description: Validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid credential.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Caller is not a telephony admin on the account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Conflict with the current state of the resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    polyApiKey:
      type: apiKey
      in: header
      name: X-API-Key

````