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

# Rollback a Prompt

> Instantly demotes the active live version and promotes a target historical version in a single atomic transaction.



## OpenAPI

````yaml /openapi.yaml post /v1/prompts/{id}/rollback
openapi: 3.1.0
info:
  title: px0 API
  description: >
    px[0] is an open-source prompt infrastructure toolkit for managing prompts
    in production. It replaces hardcoded prompt strings with versioned
    templates, in-process caching, and OpenTelemetry observability, so teams can
    iterate on prompts without touching application code. This is the OpenAPI
    specification for all the public APIs of px0.
  version: 1.0.0
servers:
  - url: http://localhost:3000
    description: Local development server
security: []
paths:
  /v1/prompts/{id}/rollback:
    post:
      tags:
        - Prompts
      summary: Rollback a Prompt
      description: >-
        Instantly demotes the active live version and promotes a target
        historical version in a single atomic transaction.
      operationId: rollbackPrompt
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - target_version
                - rollback_reason
              properties:
                target_version:
                  type: integer
                  description: The historical version number to promote to live.
                rollback_reason:
                  type: string
                  description: The reason for rolling back.
      responses:
        '200':
          description: Prompt successfully rolled back
          content:
            application/json:
              schema:
                type: object
                properties:
                  version:
                    $ref: '#/components/schemas/PromptVersion'
                required:
                  - version
        '400':
          description: Invalid UUID format or request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '404':
          description: Prompt or target version not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
      security:
        - BearerAuth: []
components:
  schemas:
    PromptVersion:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique version identifier.
        prompt_id:
          type: string
          format: uuid
          description: Reference to parent Prompt ID.
        version:
          type: integer
          description: Incrementing sequence number of the version.
        template:
          type: string
          description: The template syntax code with Go template parameters.
          example: Hello {{.name}}!
        status:
          type: string
          enum:
            - draft
            - stable
            - live
            - archived
          description: Active lifecycle status of this template version.
        model:
          type: string
          nullable: true
          description: >-
            Optional `provider/model` identifier intended to execute this prompt
            version.
          example: anthropic/claude-opus-4-6
        model_params:
          type: object
          nullable: true
          additionalProperties: true
          description: >-
            Optional provider-specific model parameters. Nested values are
            supported.
          example:
            temperature: 0.7
            max_tokens: 1024
            thinking:
              type: enabled
              budget_tokens: 512
        created_at:
          type: string
          format: date-time
        published_at:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when status was set to live. Null if draft.
        tags:
          type: array
          items:
            type: string
          description: List of tag strings attached to this version.
      required:
        - id
        - prompt_id
        - version
        - template
        - status
        - model
        - model_params
        - created_at
        - published_at
        - tags
    APIError:
      type: object
      properties:
        error:
          type: string
          example: invalid credentials
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Use an access token retrieved from login (Bearer sess_...) or a
        programmatic API key (Bearer ak_...).

````