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

# Publish an earlier version of an AI phone agent

> Put an earlier published version of an AI phone agent live again, unchanged. It is recorded as a new version and the draft is reset to it.

Requires the `phone:write` scope.

Every [publish](https://docs.open.cx/api-reference/phone/publish.md) is numbered as a version: the number is in each publish response and in the agent's version history in the dashboard. Send the number of an earlier one in the path to make its settings live again, exactly as they were. Calls that start afterwards use it, and it is recorded as a new version, so the agent's history keeps every step.

The draft is reset to that version, as after any publish: its unpublished changes are discarded and its `revision` moves, so a publish based on the draft as it was before is refused. Read the [draft](https://docs.open.cx/api-reference/phone/get_draft.md) first if it has changes you want to keep. Instructions, knowledge, actions or other items deleted since that version was published are left out, not refused.

Refusals carry a `code` beside the `message`, so your code can branch on the reason:

| Status | `code` | Meaning |
| - | - | - |
| `201` | | The version is live. The response returns the new `version` and the reset draft's `revision`. |
| `400` | `nothing_to_publish` | That version is what calls already use. |
| `400` | `draft_invalid` | A setting in that version is no longer valid (for example an inactive workflow). |
| `409` | `number_held` | A phone number in that version was given to another agent, IVR or interpreter since. The message names it; free the number first. |
| `403` | | That version differs from what is live in settings only the OpenCX team can change. Ask the OpenCX team to publish it. |
| `404` | | The agent or the version does not exist in your organization. |

Calls already in progress finish with the settings they started with. Agents on an older voice runtime have no drafts or versions, so the request returns `400` for them.


## OpenAPI

````yaml post /phone/{phone_agent_id}/versions/{version}/publish
openapi: 3.1.0
info:
  title: OpenCX API
  description: >

    OpenCX is an AI-powered, all-in-one platform for customer support and
    outbound communications.


    Use this API to manage your OpenCX organization's AI agents, actions,
    conversations, contacts, and more.


    To get started, generate a new API key from the dashboard.


    ## Authentication

    All API endpoints require authentication using a Bearer token. You can
    generate an API key from your OpenCX dashboard.


    ## Rate Limiting

    API requests are rate limited to ensure fair usage. The current limits are:

    - 100 requests per minute for standard endpoints

    - 1000 requests per minute for streaming endpoints


    ## Error Handling

    The API uses standard HTTP status codes and returns detailed error messages
    in the response body.
  version: 1.0-beta
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: http://localhost:8080
    description: Development
  - url: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /phone/{phone_agent_id}/versions/{version}/publish:
    post:
      summary: Publish an earlier version of an AI phone agent
      description: >-
        Put an earlier published version of the agent live again, unchanged:
        real calls use it from the next call on, and it is recorded as a new
        version. The draft is reset to that version, as after any publish: its
        unpublished changes are discarded and its `revision` moves. Refused with
        400 when that version is what is live already or a setting in it is no
        longer valid, with 409 when one of its phone numbers was given to
        something else meanwhile (the message names it), and with 404 for an
        unknown version.
      operationId: publishPhoneAgentVersion
      parameters:
        - schema:
            type: string
          in: path
          name: phone_agent_id
          required: true
        - schema:
            type: integer
            minimum: 1
            maximum: 9007199254740991
          in: path
          name: version
          required: true
          description: The version to put live again, as numbered when it was published.
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneAgentPublishResultDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    PhoneAgentPublishResultDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/PhoneAgentPublishResultDto'
      type: object
      properties:
        agent_id:
          type: string
        version:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        revision:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - agent_id
        - version
        - revision
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.