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

# Soft delete a sage

> Sets `active = false` on the sage record.



## OpenAPI

````yaml /openapi/private/specs/services/pl.yml delete /pl/sage/{sage_id}
openapi: 3.1.0
info:
  title: Prompt Library (PL) Service API
  description: >
    The central configuration store for sages, council sages, contexts, and
    results.

    All entities use versioned soft-delete with history tables for full audit
    trails.


    ## Authentication

    All endpoints require authentication via one of two methods:

    - **API Key**: Pass the key in the `X-Auth` header (service-to-service
    calls)

    - **JWT Token**: Pass a Bearer token in the `Authorization` header
    (user-facing calls)


    The required permission level is noted per endpoint.


    ## Sub-Modules

    - **Sage** -- Base sage templates (interview configurations)

    - **Council Sage** -- Council-specific sage instances with customizations

    - **Context** -- Job description and role analysis data

    - **Results** -- Evaluation template configurations (scoring,
    recommendations)


    ## Data Model

    - **Versioning** -- Every update creates a new version (soft update)

    - **Soft Delete** -- Delete sets `active = false` rather than removing rows

    - **History Tables** -- Each entity has a parallel `_history` table

    - **Relationships** -- Council Sage references Sage, Context, Results, and
    Status


    ## Query Patterns

    - `?details=1` -- Include full object details in list responses

    - `?active=true|false|all` -- Filter by active status

    - `?custom=1` -- Filter for custom sages only

    - List endpoints return `{id: object}` maps; get endpoints return single
    objects
  version: 1.0.0
  contact:
    name: Platform Team
servers:
  - url: '{protocol}://{host}:{port}'
    description: Prompt Library Service
    variables:
      protocol:
        default: https
        enum:
          - http
          - https
      host:
        default: localhost
      port:
        default: '5000'
security: []
tags:
  - name: Sage
    description: Base sage template CRUD
  - name: Council Sage
    description: Council-specific sage instance CRUD and prompts
  - name: Context
    description: Job context CRUD (PL database)
  - name: Results
    description: Results template CRUD
  - name: Service
    description: Health checks and initialization
paths:
  /pl/sage/{sage_id}:
    delete:
      tags:
        - Sage
      summary: Soft delete a sage
      description: Sets `active = false` on the sage record.
      operationId: deleteSage
      parameters:
        - $ref: '#/components/parameters/SageId'
        - $ref: '#/components/parameters/RequiredPermission_admin_sage'
      responses:
        '200':
          description: Sage deactivated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SageResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Sage not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Sage not found
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - jwtAuth: []
components:
  parameters:
    SageId:
      name: sage_id
      in: path
      required: true
      description: UUID of the sage
      schema:
        type: string
        format: uuid
      example: b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e
    RequiredPermission_admin_sage:
      name: X-Permission-Info
      in: header
      required: false
      description: >-
        **Required JWT permission: `admin_sage`** (informational only --
        enforced server-side)
      schema:
        type: string
  schemas:
    SageResponse:
      type: object
      description: Sage record (from SageModel.to_dict())
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        active:
          type: boolean
        version:
          type: integer
        greeting:
          type:
            - string
            - 'null'
        reminders:
          type:
            - string
            - 'null'
        opening:
          type:
            - string
            - 'null'
        closing:
          type:
            - string
            - 'null'
        end_condition:
          type:
            - string
            - 'null'
        directions:
          type:
            - string
            - 'null'
        guidance:
          type:
            - string
            - 'null'
        scope_id:
          type: string
          format: uuid
        meta_data:
          type:
            - object
            - 'null'
        status_id:
          type: string
          format: uuid
        description:
          type:
            - string
            - 'null'
        avatar:
          type:
            - string
            - 'null'
        chat_avatar:
          type:
            - string
            - 'null'
        duration_list:
          type:
            - array
            - 'null'
          items:
            type: integer
        is_demo:
          type: boolean
        is_internal:
          type: boolean
        audio:
          type: boolean
        language_code:
          type:
            - string
            - 'null'
        followup_days:
          type:
            - integer
            - 'null'
        customizable:
          type: boolean
        is_mentor:
          type: boolean
        slug:
          type:
            - string
            - 'null'
        language:
          type: boolean
        tagline:
          type:
            - string
            - 'null'
        default_tone:
          type:
            - string
            - 'null'
        default_role:
          type:
            - string
            - 'null'
        default_short_role:
          type:
            - string
            - 'null'
        role_level:
          type: string
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
  responses:
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            noApiKey:
              summary: Missing API key
              value:
                error: Unauthorized - API key required
            invalidApiKey:
              summary: Invalid API key
              value:
                error: Unauthorized - Invalid API key
            noToken:
              summary: Missing JWT token
              value:
                error: Unauthorized - No valid token
            invalidToken:
              summary: Invalid or expired JWT
              value:
                error: Unauthorized3
            insufficientPermissions:
              summary: Token lacks required permission
              value:
                error: Unauthorized4
            apiKeyInsteadOfJwt:
              summary: API key sent to JWT-only endpoint
              value:
                error: Unauthorized - JWT token required, not API key
    InternalError:
      description: Unexpected server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Internal server error
  securitySchemes:
    jwtAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: User JWT token passed in Authorization header

````