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

# Create VoiceLink call routing

> Creates a call-routing record for a DID (one record per DID). Provide either `did_id` or `did_number`. `for_inbound_call` and `for_outbound_call` are VoiceLink mode integers; `3` routes to a WebSocket bot. For the common outbound case, prefer `POST /voicelink/call-ready`, which performs the same setup safely. This endpoint never purchases or renews DIDs, runs KYC, allocates wallet or credit, or deletes local Vocobase data. Numeric fields are validated strictly: zero, negative, non-integer, or non-finite values are rejected with a 400 `VALIDATION_ERROR` naming the field.



## OpenAPI

````yaml /openapi.json post /voicelink/call-routing
openapi: 3.1.0
info:
  title: Vocobase Partner API
  version: '2.0'
  description: >-
    API for managing voice AI agents, documents, and calls on the Vocobase
    platform.
servers:
  - url: https://api.vocobase.com/api/v2
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Config
    description: >-
      Read and update partner configuration, webhook settings, and telephony
      credentials.
  - name: Agents
    description: Create, read, update, and delete voice AI agents.
  - name: Voices
    description: >-
      List voice tiers, available voices, and stream preview audio for agent
      configuration.
  - name: Documents
    description: Upload, manage, and delete knowledge base documents.
  - name: Agent Documents
    description: Link and unlink documents to agents for knowledge base integration.
  - name: Calls
    description: Initiate outbound calls and view call history.
  - name: Phone Numbers
    description: >-
      Import DIDs, assign agents for inbound routing, and re-sync carrier
      Application bindings.
  - name: Inbound Routing Policies
    description: >-
      Define pre-answer routing decisions for inbound calls before AI sessions
      are created.
  - name: Telephony Connections
    description: Create, list, rename, and disconnect named V2 telephony connections.
  - name: VoiceLink Management
    description: Manage VoiceLink reseller clients, DID mapping, and readiness sync.
  - name: Projects
    description: Organize agents into projects. Every agent belongs to exactly one project.
  - name: Dictionaries
    description: Speech-recognition dictionary CRUD and agent attachment.
  - name: Sessions
    description: Browser-initiated WebRTC voice sessions for in-app voice agents.
paths:
  /voicelink/call-routing:
    post:
      tags:
        - VoiceLink Management
      summary: Create VoiceLink call routing
      description: >-
        Creates a call-routing record for a DID (one record per DID). Provide
        either `did_id` or `did_number`. `for_inbound_call` and
        `for_outbound_call` are VoiceLink mode integers; `3` routes to a
        WebSocket bot. For the common outbound case, prefer `POST
        /voicelink/call-ready`, which performs the same setup safely. This
        endpoint never purchases or renews DIDs, runs KYC, allocates wallet or
        credit, or deletes local Vocobase data. Numeric fields are validated
        strictly: zero, negative, non-integer, or non-finite values are rejected
        with a 400 `VALIDATION_ERROR` naming the field.
      operationId: createVoiceLinkCallRouting
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoiceLinkCreateRoutingRequest'
            example:
              connection_id: 9b7f1c44-c87f-4f0c-9124-3c802a9c1a20
              did_id: 812
              for_inbound_call: 1
              for_outbound_call: 3
              outbound_websocket_bot_id: 93
              status: 1
      responses:
        '200':
          description: VoiceLink call routing created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceLinkProxyResponse'
        '201':
          description: VoiceLink call routing created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceLinkProxyResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    VoiceLinkCreateRoutingRequest:
      type: object
      description: >-
        Creates a call-routing record for a DID. Provide either `did_id` or
        `did_number`.
      anyOf:
        - required:
            - did_id
            - for_inbound_call
            - for_outbound_call
        - required:
            - did_number
            - for_inbound_call
            - for_outbound_call
      properties:
        connection_id:
          type: string
          format: uuid
          description: >-
            Optional unless multiple active VoiceLink connections exist.
            `connectionId` is accepted for backwards compatibility.
        did_id:
          type: integer
          minimum: 1
          description: VoiceLink DID ID. Provide either `did_id` or `did_number`.
        did_number:
          type: string
          description: DID number. Used when `did_id` is not available.
        for_inbound_call:
          type: integer
          minimum: 0
          description: 'VoiceLink inbound mode: 1 mobile, 2 SIP, 3 WebSocket bot.'
        for_outbound_call:
          type: integer
          minimum: 0
          description: 'VoiceLink outbound mode: 2 SIP, 3 WebSocket bot, 4 only-answer.'
        inbound_websocket_bot_id:
          type: integer
          minimum: 1
          description: VoiceLink bot ID when `for_inbound_call` is 3.
        inbound_sip_trunk_id:
          type: integer
          minimum: 1
          description: VoiceLink SIP trunk ID when `for_inbound_call` is 2.
        outbound_websocket_bot_id:
          type: integer
          minimum: 1
          description: VoiceLink bot ID when `for_outbound_call` is 3.
        outbound_sip_trunk_id:
          type: integer
          minimum: 1
          description: VoiceLink SIP trunk ID when `for_outbound_call` is 2.
        status:
          type: integer
          enum:
            - 0
            - 1
          default: 1
          description: 'Routing status: 1 active (default), 0 inactive.'
    VoiceLinkProxyResponse:
      type: object
      description: >-
        A VoiceLink upstream response wrapped in the V2 success envelope. The
        `data` shape is forwarded from VoiceLink and may vary by endpoint.
      properties:
        success:
          type: boolean
          const: true
        data:
          oneOf:
            - type: object
              additionalProperties: true
            - type: array
              items: {}
            - type: 'null'
          description: VoiceLink upstream response body.
      required:
        - success
        - data
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          const: false
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
          required:
            - code
            - message
      required:
        - success
        - error
  responses:
    ValidationError:
      description: Validation error in request body or parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: VALIDATION_ERROR
              message: agent_name is required and must be max 50 characters
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: UNAUTHORIZED
              message: Invalid or missing API key
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: NOT_FOUND
              message: Resource not found
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: INTERNAL_ERROR
              message: An unexpected error occurred
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key in format: `rg_live_xxxx`. Pass as a Bearer token in the
        Authorization header.

````