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

# Run Playbook

> Execute a playbook and return the generated report



## OpenAPI

````yaml POST /v2/playbooks/{id}/run
openapi: 3.1.0
info:
  title: TextQL v2 API
  version: '2.0'
  description: >
    REST API for TextQL platform operations. All endpoints require Bearer token
    authentication.
servers:
  - url: https://app.textql.com
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Create and manage AI chat sessions
  - name: Connectors
    description: List available data connectors
  - name: Playbooks
    description: Create, configure, and run automated playbooks
  - name: Sandcastles
    description: Manage Python sandbox environments for code execution
  - name: Changes
    description: Review, approve, and deny Context Library changes
paths:
  /v2/playbooks/{id}/run:
    post:
      tags:
        - Playbooks
      summary: Run Playbook
      description: >
        Execute a playbook and return the generated report. Use `dry_run: true`
        to

        validate without executing. Returns 504 if execution times out.
      operationId: v2.runPlaybook
      parameters:
        - $ref: '#/components/parameters/PlaybookId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                dry_run:
                  type: boolean
                  default: false
                  description: If true, validate without executing
      responses:
        '200':
          description: Playbook execution result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunPlaybookResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '504':
          description: Execution timed out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    PlaybookId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Playbook ID
  schemas:
    RunPlaybookResponse:
      type: object
      properties:
        chat_id:
          type: string
          format: uuid
        report:
          $ref: '#/components/schemas/Report'
        assets:
          type: array
          items:
            $ref: '#/components/schemas/Asset'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
              enum:
                - invalid_request
                - unauthenticated
                - permission_denied
                - not_found
                - conflict
                - rate_limit_exceeded
                - internal
                - timeout
                - cancelled
                - execution_failed
                - no_report
            message:
              type: string
              description: Human-readable error message
    Report:
      type: object
      properties:
        id:
          type: string
          format: uuid
        subject:
          type: string
          description: Report subject line
        summary:
          type: string
          description: Brief summary of the report
        blocks:
          type: array
          description: Structured report content blocks
          items:
            $ref: '#/components/schemas/ReportBlock'
        html_preview:
          type: string
          description: Pre-rendered HTML preview of the report
        chat_id:
          type: string
          format: uuid
          description: Chat session that generated this report
        created_at:
          type: string
          format: date-time
    Asset:
      type: object
      properties:
        name:
          type: string
          description: Asset name
        type:
          type: string
          description: Asset type (e.g. image, table, pdf, html, dataframe, download)
        url:
          type: string
          description: Asset URL
    ReportBlock:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - hero
            - text
            - image
            - list
            - image_text
            - card
            - divider
            - spacer
          description: Block type
        heading:
          type: string
          description: Block heading (text, list, image_text)
        content:
          type: string
          description: Block body content (text, image_text)
        image_url:
          type: string
          description: Image URL (hero, image, image_text)
        image_alt:
          type: string
          description: Image alt text (hero, image, image_text)
        variant:
          type: string
          enum:
            - circular
            - rounded
            - pill
            - none
          description: Image shape variant (image, image_text)
        items:
          type: array
          items:
            type: string
          description: List items (list)
        blocks:
          type: array
          items:
            $ref: '#/components/schemas/ReportBlock'
          description: Nested blocks (card)
        height:
          type: integer
          description: Spacer height in pixels (spacer)
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: invalid_request
              message: Invalid request body
    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthenticated
              message: Authentication required
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: permission_denied
              message: Insufficient permissions
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: not_found
              message: Resource not found
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: internal
              message: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key or JWT token

````