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

# Sync VoiceLink state and readiness

> Fetches remote VoiceLink clients, DIDs, available DIDs, bots, and routing, then compares them with Vocobase local PhoneNumber rows. By default, remote DIDs are imported into Vocobase local inventory; pass `import_dids: false` for a read-only readiness check. Sync does not silently delete local data.



## OpenAPI

````yaml /openapi.json post /voicelink/sync
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/sync:
    post:
      tags:
        - VoiceLink Management
      summary: Sync VoiceLink state and readiness
      description: >-
        Fetches remote VoiceLink clients, DIDs, available DIDs, bots, and
        routing, then compares them with Vocobase local PhoneNumber rows. By
        default, remote DIDs are imported into Vocobase local inventory; pass
        `import_dids: false` for a read-only readiness check. Sync does not
        silently delete local data.
      operationId: syncVoiceLinkState
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoiceLinkSyncRequest'
            example:
              connection_id: 9b7f1c44-c87f-4f0c-9124-3c802a9c1a20
              import_dids: true
      responses:
        '200':
          description: VoiceLink sync and readiness result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceLinkSyncResponse'
              example:
                success: true
                data:
                  clients: []
                  dids:
                    - id: 812
                      did_id: 812
                      did_number: '918011223344'
                      phone_number: '+918011223344'
                      client_id: 415
                      status: active
                      is_expired: false
                      raw: {}
                  available_dids: []
                  bots: []
                  routing: []
                  local_phone_numbers: []
                  readiness:
                    - key: '918011223344'
                      phone_number: '+918011223344'
                      state: NO_BOT
                      issues:
                        - NO_BOT
                        - ROUTING_MISSING
                        - NO_VOCOBASE_AGENT
                      remote_did:
                        did_id: 812
                        did_number: '918011223344'
                        phone_number: '+918011223344'
                        client_id: 415
                        is_expired: false
                        raw: {}
                      local_phone_number: null
                      routing: null
                      bot: null
                      actions:
                        - >-
                          Create an active VoiceLink WebSocket bot for the
                          mapped client
                        - Create VoiceLink call routing for this DID
                        - Assign a Vocobase agent to the local PhoneNumber row
                      action_items:
                        - code: NO_BOT
                          label: >-
                            Create an active VoiceLink WebSocket bot for the
                            mapped client
                        - code: ROUTING_MISSING
                          label: Create VoiceLink call routing for this DID
                        - code: NO_VOCOBASE_AGENT
                          label: Assign a Vocobase agent to the local PhoneNumber row
                  drift:
                    - key: '918011223344'
                      phone_number: '+918011223344'
                      state: NO_BOT
                      action: >-
                        Create an active VoiceLink WebSocket bot for the mapped
                        client
                      did_id: 812
                      client_id: 415
                  warnings: []
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    VoiceLinkSyncRequest:
      type: object
      properties:
        connection_id:
          type: string
          format: uuid
          description: Optional unless multiple active VoiceLink connections exist.
        import_dids:
          type: boolean
          default: true
          description: >-
            When true or omitted, remote purchased DIDs are upserted into
            Vocobase local PhoneNumber inventory. Set false for a read-only
            readiness check.
    VoiceLinkSyncResponse:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            clients:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkNormalizedRow'
            dids:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkNormalizedDid'
            available_dids:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkNormalizedDid'
            bots:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkNormalizedRow'
            routing:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkNormalizedRouting'
            local_phone_numbers:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkLocalPhoneNumber'
            readiness:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkReadinessItem'
            drift:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkDriftItem'
            warnings:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkSyncWarning'
              description: >-
                Non-fatal upstream-fetch issues; empty on a fully-successful
                sync. When present, dependent readiness inferences are
                suppressed rather than guessed.
          required:
            - clients
            - dids
            - available_dids
            - bots
            - routing
            - local_phone_numbers
            - readiness
            - drift
            - warnings
      required:
        - success
        - data
    VoiceLinkNormalizedRow:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        status:
          oneOf:
            - type: string
            - type: integer
        client_id:
          type: integer
        websocket_url:
          type: string
          format: uri
          description: >-
            Present for ordinary bot rows. Omitted when the URL contains the
            signed inbound token.
        websocket_configured:
          type: boolean
          description: >-
            True when a signed inbound bot URL is configured but redacted from
            the response.
        raw:
          type: object
          additionalProperties: true
          description: >-
            Original VoiceLink row. Omitted for bot rows containing a signed
            inbound URL.
    VoiceLinkNormalizedDid:
      allOf:
        - $ref: '#/components/schemas/VoiceLinkNormalizedRow'
        - type: object
          properties:
            did_id:
              type: integer
            did_number:
              type: string
            phone_number:
              type:
                - string
                - 'null'
              description: Normalized E.164 DID when Vocobase can infer it.
            is_expired:
              type: boolean
            is_released:
              type: boolean
          required:
            - phone_number
            - is_expired
            - is_released
    VoiceLinkNormalizedRouting:
      allOf:
        - $ref: '#/components/schemas/VoiceLinkNormalizedRow'
        - type: object
          properties:
            did_id:
              type: integer
            did_number:
              type: string
            phone_number:
              type:
                - string
                - 'null'
            for_inbound_call:
              type: integer
              description: 'VoiceLink mode: 1 mobile, 2 SIP, 3 WebSocket bot.'
            for_outbound_call:
              type: integer
              description: 'VoiceLink mode: 2 SIP, 3 WebSocket bot, 4 only-answer.'
            inbound_websocket_bot_id:
              type: integer
            inbound_sip_trunk_id:
              type: integer
            outbound_websocket_bot_id:
              type: integer
            outbound_sip_trunk_id:
              type: integer
          required:
            - phone_number
    VoiceLinkLocalPhoneNumber:
      type: object
      properties:
        id:
          type: string
          format: uuid
        phone_number:
          type: string
        friendly_name:
          type:
            - string
            - 'null'
        status:
          type: string
        is_default:
          type: boolean
        inbound_enabled:
          type: boolean
        agent:
          type:
            - object
            - 'null'
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - phone_number
        - status
        - is_default
        - inbound_enabled
        - agent
    VoiceLinkReadinessItem:
      type: object
      properties:
        key:
          type: string
          description: >-
            Stable digit-only join key (no `+`) linking the remote DID, routing,
            and local PhoneNumber rows for this number.
        phone_number:
          type: string
        state:
          $ref: '#/components/schemas/VoiceLinkReadinessState'
        issues:
          type: array
          items:
            $ref: '#/components/schemas/VoiceLinkReadinessState'
        remote_did:
          oneOf:
            - $ref: '#/components/schemas/VoiceLinkNormalizedDid'
            - type: 'null'
        local_phone_number:
          oneOf:
            - $ref: '#/components/schemas/VoiceLinkLocalPhoneNumber'
            - type: 'null'
        routing:
          oneOf:
            - $ref: '#/components/schemas/VoiceLinkNormalizedRouting'
            - type: 'null'
        bot:
          oneOf:
            - $ref: '#/components/schemas/VoiceLinkNormalizedRow'
            - type: 'null'
        actions:
          type: array
          items:
            type: string
          description: Human-readable remediation strings (one per issue).
        action_items:
          type: array
          items:
            $ref: '#/components/schemas/VoiceLinkActionItem'
          description: >-
            Same remediation steps as `{ code, label }` objects for programmatic
            use.
        inbound:
          type: object
          description: Direction-specific readiness for DID-to-agent inbound calling.
          properties:
            state:
              $ref: '#/components/schemas/VoiceLinkInboundReadinessState'
            ready:
              type: boolean
            issues:
              type: array
              items:
                $ref: '#/components/schemas/VoiceLinkInboundReadinessState'
            actions:
              type: array
              items:
                type: string
            bot:
              oneOf:
                - $ref: '#/components/schemas/VoiceLinkNormalizedRow'
                - type: 'null'
            runtime:
              type: object
              properties:
                enabled:
                  type: boolean
                configured:
                  type: boolean
                issues:
                  type: array
                  items:
                    type: string
                    enum:
                      - RUNTIME_DISABLED
                      - SIGNING_SECRET_MISSING
                      - INBOUND_WSS_URL_MISSING
              required:
                - enabled
                - configured
                - issues
          required:
            - state
            - ready
            - issues
            - actions
            - bot
            - runtime
      required:
        - key
        - phone_number
        - state
        - issues
        - remote_did
        - local_phone_number
        - routing
        - bot
        - actions
        - action_items
        - inbound
    VoiceLinkDriftItem:
      type: object
      properties:
        key:
          type: string
          description: >-
            Same stable digit-only join key as the readiness row this drift
            belongs to.
        phone_number:
          type: string
        state:
          $ref: '#/components/schemas/VoiceLinkReadinessState'
        action:
          type: string
        did_id:
          type: integer
          description: >-
            Stable VoiceLink DID identifier for repairing this drift row, when
            known.
        client_id:
          type: integer
          description: >-
            Stable VoiceLink client identifier for repairing this drift row,
            when known.
        routing_id:
          type: integer
          description: >-
            Stable VoiceLink routing identifier for repairing this drift row,
            when known.
        bot_id:
          type: integer
          description: >-
            Stable VoiceLink bot identifier for repairing this drift row, when
            known.
        local_phone_number_id:
          type: string
          format: uuid
          description: >-
            Stable local Vocobase PhoneNumber identifier for repairing this
            drift row, when known.
        details:
          type: object
          additionalProperties: true
      required:
        - key
        - phone_number
        - state
        - action
    VoiceLinkSyncWarning:
      type: object
      description: >-
        A non-fatal upstream-fetch problem during sync. When a section fetch
        fails (or the purchased-DID list is truncated), the dependent readiness
        inferences are suppressed rather than guessed off incomplete data.
      properties:
        section:
          type: string
          enum:
            - clients
            - dids
            - available_dids
            - bots
            - routing
        code:
          type: string
          enum:
            - FETCH_FAILED
            - TRUNCATED
        message:
          type: string
      required:
        - section
        - code
        - message
    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
    VoiceLinkReadinessState:
      type: string
      enum:
        - READY
        - NOT_IMPORTED
        - NO_CLIENT_MAPPING
        - NO_BOT
        - ROUTING_MISSING
        - ROUTING_CHANGED
        - NO_VOCOBASE_AGENT
        - REMOTE_DID_EXPIRED
        - REMOTE_DID_RELEASED
        - REMOTE_DID_DELETED
    VoiceLinkActionItem:
      type: object
      description: >-
        A machine code plus human label for one remediation step. `code` is the
        readiness issue the step resolves.
      properties:
        code:
          $ref: '#/components/schemas/VoiceLinkReadinessState'
        label:
          type: string
      required:
        - code
        - label
    VoiceLinkInboundReadinessState:
      type: string
      enum:
        - READY
        - NOT_IMPORTED
        - NO_CLIENT_MAPPING
        - NO_BOT
        - ROUTING_MISSING
        - ROUTING_CHANGED
        - NO_VOCOBASE_AGENT
        - REMOTE_DID_EXPIRED
        - REMOTE_DID_RELEASED
        - REMOTE_DID_DELETED
        - INBOUND_RUNTIME_DISABLED
        - INBOUND_ORIGIN_AUTH_NOT_CONFIGURED
        - INBOUND_NOT_ENABLED_LOCALLY
        - INBOUND_BOT_URL_CHANGED
  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.

````