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

# Link Bot to Phone Number

> Link a bot (agent) to a phone number for inbound/outbound calls.



## OpenAPI

````yaml post /v1/phone-numbers/link-agent
openapi: 3.1.0
info:
  title: OpenMic v1 External API
  description: >-
    API specification for OpenMic v1 External API, providing endpoints for bot
    management, call handling, and phone number operations.
  version: 1.0.0
servers:
  - url: https://api.openmic.ai
    description: Production Environment
security:
  - api_key: []
tags:
  - name: Calls
    description: Endpoints related to phone call creation and management.
  - name: Bots
    description: Endpoints related to bot management and configuration.
  - name: Phone Numbers
    description: Endpoints related to phone number management and bot linking.
  - name: Knowledge Bases
  - name: FAQs
  - name: Campaigns
  - name: Tools
  - name: Contact Lists
  - name: Contacts
  - name: Voices
    description: >-
      Endpoints for browsing available text-to-speech voices. Voices are
      read-only and can be filtered by gender, provider, language, and accent.
  - name: SMS
    description: Endpoints for sending SMS messages.
paths:
  /v1/phone-numbers/link-agent:
    post:
      tags:
        - Phone Numbers
      summary: Link Bot to Phone Number
      description: Link a bot (agent) to a phone number for inbound/outbound calls.
      requestBody:
        description: Bot linking details
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LinkBotToPhoneNumberRequest'
            example:
              phone_number_id: ybhb8wzi487w02m2bc7dh0ev
              agent_id: bvrg8wzi487w02m2bc7dh0ev
              direction: both
      responses:
        '200':
          description: Bot linked to phone number successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkBotToPhoneNumberResponse'
              example:
                phone_number_id: ybhb8wzi487w02m2bc7dh0ev
                phone_number: '+15551112222'
                inbound_agent_id: bvrg8wzi487w02m2bc7dh0ev
                outbound_agent_id: bvrg8wzi487w02m2bc7dh0ev
                message: Bot linked successfully for inbound and outbound calls.
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Invalid direction specified. Must be one of 'inbound',
                  'outbound', 'both'.
        '401':
          description: Unauthorized - missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Unauthorized
                message: Invalid or expired API key
        '404':
          description: Phone number or bot not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: The specified phone number or bot was not found.
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: An unexpected error occurred. Please try again later.
components:
  schemas:
    LinkBotToPhoneNumberRequest:
      type: object
      properties:
        phone_number_id:
          type: string
          description: Unique identifier of the phone number
        agent_id:
          type: string
          description: Bot ID to link
        direction:
          type: string
          enum:
            - inbound
            - outbound
            - both
          description: Direction for the bot assignment
      required:
        - phone_number_id
        - agent_id
        - direction
    LinkBotToPhoneNumberResponse:
      type: object
      properties:
        phone_number_id:
          type: string
          description: Unique identifier of the phone number
        phone_number:
          type: string
          description: Phone number in E.164 format
        inbound_agent_id:
          type: string
          description: Bot ID for inbound calls
        outbound_agent_id:
          type: string
          description: Bot ID for outbound calls
        message:
          type: string
          description: Success message
      required:
        - phone_number_id
        - phone_number
        - message
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
        message:
          type: string
          description: Additional error message (for certain error types)
      required:
        - error
  securitySchemes:
    api_key:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API key authentication. Include your API key in the Authorization header
        as: `Authorization: Bearer <your-api-key>`

````