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

# Publish agent version

> Publish a specific version of an agent and associate it with phone numbers. Phone numbers can be inbound, outbound, or both. If version_id is None, unpublishes the current published version.



## OpenAPI

````yaml /api-reference/openapi.json patch /v1/agent/{agent_id}/published_version
openapi: 3.1.0
info:
  title: Diga API
  version: 0.1.0
servers:
  - url: https://api.diga.io
    description: Production
security: []
paths:
  /v1/agent/{agent_id}/published_version:
    patch:
      tags:
        - Agents
      summary: Publish agent version
      description: >-
        Publish a specific version of an agent and associate it with phone
        numbers. Phone numbers can be inbound, outbound, or both. If version_id
        is None, unpublishes the current published version.
      operationId: publish_agent_version_v1_agent__agent_id__published_version_patch
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublishAgentRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublishAgentResponse'
        '400':
          description: Bad request - Invalid parameters
          content:
            application/json:
              example:
                status: error
                error_code: BAD_PARAMETER
                message: Invalid phone number configuration or version
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              example:
                status: error
                error_code: INTERNAL_SERVER_ERROR
                message: Missing required permissions to update agents or phones
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '404':
          description: Agent Not Found
          content:
            application/json:
              example:
                status: error
                error_code: AGENT_NOT_FOUND
                message: Agent 550e8400-e29b-41d4-a716-446655440000 not found
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              example:
                status: error
                error_code: INTERNAL_SERVER_ERROR
                message: 'Error: Internal Server Error'
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
      security:
        - CustomHTTPBearer: []
components:
  schemas:
    PublishAgentRequest:
      properties:
        version_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Version Id
          description: >-
            The version id to be published. If not provided, the current version
            published will be unpublished
        outbound_phone_number_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Outbound Phone Number Id
          description: >-
            The outbound phone number id to be used by the agent for outbound
            calls.
        inbound_phone_number_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Inbound Phone Number Id
          description: >-
            The inbound phone number id to be used by the agent for inbound
            calls.
      type: object
      title: PublishAgentRequest
    PublishAgentResponse:
      properties:
        agent_id:
          type: string
          format: uuid
          title: Agent Id
          description: The unique identifier for the agent
        published_version_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Version Id
          description: >-
            The version id that was published. If not provided, the agent was
            unpublished
        outbound_phone_number_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Outbound Phone Number Id
          description: >-
            The outbound phone number id to be used by the agent for outbound
            calls.
        inbound_phone_number_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Inbound Phone Number Id
          description: >-
            The inbound phone number id to be used by the agent for inbound
            calls.
      type: object
      required:
        - agent_id
      title: PublishAgentResponse
    ErrorResponseSchema:
      properties:
        status:
          type: string
          title: Status
          description: Status of the response, always 'error' for error responses
          default: error
        error_code:
          type: string
          title: Error Code
          description: Machine-readable error code in SCREAMING_SNAKE_CASE format
          examples:
            - PROJECT_NOT_FOUND
            - INVALID_EMAIL
            - UNAUTHORIZED_ROLE
        message:
          type: string
          title: Message
          description: Human-readable error message with details
          examples:
            - Project with id 550e8400-e29b-41d4-a716-446655440000 not found
            - The email invalid@email is not valid
            - Insufficient permissions to perform this action
      type: object
      required:
        - error_code
        - message
      title: ErrorResponseSchema
      description: Standard error response format for all API errors.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    CustomHTTPBearer:
      type: http
      scheme: bearer

````