> ## 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 inbound routing policy

> Creates a webhook-backed policy for pre-answer inbound call routing. PHONE_NUMBER policies target one active inbound-enabled Vobiz or Plivo DID, AGENT policies target an active agent, and PARTNER policies apply as the partner default.



## OpenAPI

````yaml /openapi.json post /inbound-route-policies
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:
  /inbound-route-policies:
    post:
      tags:
        - Inbound Routing Policies
      summary: Create inbound routing policy
      description: >-
        Creates a webhook-backed policy for pre-answer inbound call routing.
        PHONE_NUMBER policies target one active inbound-enabled Vobiz or Plivo
        DID, AGENT policies target an active agent, and PARTNER policies apply
        as the partner default.
      operationId: createInboundRoutePolicy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InboundRoutePolicyCreateRequest'
            example:
              scope: PHONE_NUMBER
              phone_number_id: f1a2c3d4-1111-2222-3333-444455556666
              name: Inbound owner routing
              enabled: true
              webhook_url: https://partner.example.com/webhooks/vocobase/inbound-route
              timeout_ms: 2000
              failure_action: ANSWER_WITH_AI
              allowed_actions:
                - ANSWER_WITH_AI
                - SELECT_AGENT
                - TRANSFER
                - REJECT
      responses:
        '201':
          description: Policy created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    const: true
                  data:
                    type: object
                    properties:
                      policy:
                        $ref: '#/components/schemas/InboundRoutePolicy'
              example:
                success: true
                data:
                  policy:
                    id: clxj3rx7z000008l51s9vh3hf
                    partner_config_id: 8f7c95c6-6f2e-4f8f-bd1a-a6c9d9f4e2e3
                    scope: PHONE_NUMBER
                    phone_number_id: f1a2c3d4-1111-2222-3333-444455556666
                    phone_number:
                      id: f1a2c3d4-1111-2222-3333-444455556666
                      number: '+918065480085'
                    agent_id: null
                    agent: null
                    name: Inbound owner routing
                    enabled: true
                    webhook_url: >-
                      https://partner.example.com/webhooks/vocobase/inbound-route
                    has_webhook_secret: false
                    timeout_ms: 2000
                    failure_action: ANSWER_WITH_AI
                    allowed_actions:
                      - ANSWER_WITH_AI
                      - SELECT_AGENT
                      - TRANSFER
                      - REJECT
                    created_at: '2026-07-01T11:00:00.000Z'
                    updated_at: '2026-07-01T11:00:00.000Z'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: A policy already exists for this scope target.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                success: false
                error:
                  code: POLICY_ALREADY_EXISTS
                  message: A policy already exists for this scope target
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    InboundRoutePolicyCreateRequest:
      type: object
      description: >-
        Create a webhook-backed inbound routing policy. PHONE_NUMBER requires
        phone_number_id, AGENT requires agent_id, and PARTNER rejects both
        target IDs.
      required:
        - scope
        - name
        - webhook_url
      properties:
        scope:
          $ref: '#/components/schemas/InboundRoutePolicyScope'
        phone_number_id:
          type: string
          format: uuid
          description: >-
            Required when scope is PHONE_NUMBER. Must reference an active
            inbound-enabled Vobiz or Plivo DID owned by the partner.
        agent_id:
          type: string
          format: uuid
          description: >-
            Required when scope is AGENT. Must reference an active agent owned
            by the partner.
        name:
          type: string
          minLength: 1
          maxLength: 200
          description: Policy label used in partner admin tooling.
        enabled:
          type: boolean
          default: true
          description: When false, the policy is stored but not evaluated.
        webhook_url:
          type: string
          format: uri
          description: HTTPS endpoint that receives the `inbound.route` event.
        webhook_secret:
          type:
            - string
            - 'null'
          description: Optional webhook signing secret. Write-only; never returned.
          writeOnly: true
        timeout_ms:
          type: integer
          minimum: 250
          maximum: 5000
          default: 2000
          description: Policy decision webhook timeout in milliseconds.
        failure_action:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/InboundRoutePolicyFailureAction'
          default: ANSWER_WITH_AI
        allowed_actions:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/InboundRouteAction'
          description: >-
            Optional allowlist for webhook response actions. If omitted, all
            four actions are allowed.
    InboundRoutePolicy:
      type: object
      description: Normalized inbound routing policy object.
      properties:
        id:
          type: string
          description: Opaque policy ID.
        scope:
          $ref: '#/components/schemas/InboundRoutePolicyScope'
        phone_number_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Policy target when scope is PHONE_NUMBER. Null for AGENT and PARTNER
            policies.
        partner_config_id:
          type: string
          format: uuid
        agent_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Policy target when scope is AGENT. Null for PHONE_NUMBER and PARTNER
            policies.
        name:
          type: string
          maxLength: 200
        enabled:
          type: boolean
        webhook_url:
          type: string
          format: uri
        has_webhook_secret:
          type: boolean
          description: Whether a webhook secret exists (secret itself is never returned).
        timeout_ms:
          type: integer
          minimum: 250
          maximum: 5000
        failure_action:
          $ref: '#/components/schemas/InboundRoutePolicyFailureAction'
        allowed_actions:
          oneOf:
            - type: 'null'
            - type: array
              items:
                $ref: '#/components/schemas/InboundRouteAction'
        phone_number:
          oneOf:
            - type: 'null'
            - type: object
              properties:
                id:
                  type: string
                  format: uuid
                number:
                  type: string
        agent:
          oneOf:
            - type: 'null'
            - type: object
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    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
    InboundRoutePolicyScope:
      type: string
      description: >-
        Policy scope. Runtime resolution priority is PHONE_NUMBER, then AGENT,
        then PARTNER.
      enum:
        - PHONE_NUMBER
        - AGENT
        - PARTNER
    InboundRoutePolicyFailureAction:
      type: string
      description: >-
        Fallback action used when the policy webhook times out, fails, or
        returns an invalid response.
      enum:
        - ANSWER_WITH_AI
        - REJECT
    InboundRouteAction:
      type: string
      description: Action values supported by inbound route policy responses.
      enum:
        - ANSWER_WITH_AI
        - SELECT_AGENT
        - TRANSFER
        - REJECT
  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
    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.

````