> ## 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.

# Create a new council sage

> Creates a new council sage record in both `council_sages` and
`council_sages_history` tables.




## OpenAPI

````yaml /openapi/private/specs/services/pl.yml post /pl/council-sage/
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/council-sage/:
    post:
      tags:
        - Council Sage
      summary: Create a new council sage
      description: |
        Creates a new council sage record in both `council_sages` and
        `council_sages_history` tables.
      operationId: addCouncilSage
      parameters:
        - $ref: '#/components/parameters/RequiredPermission_council_sage'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CouncilSageCreate'
            example:
              name: Senior Engineer Screen
              role: Software Engineer
              role_level: senior
              sage_id: b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e
              council_id: 6151186e-3b17-4fb2-a54d-ff327bf7a71a
              context_id: a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d
              results_id: d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a
              duration: 30
      responses:
        '201':
          description: Council sage created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CouncilSageResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: No JSON data provided
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - jwtAuth: []
components:
  parameters:
    RequiredPermission_council_sage:
      name: X-Permission-Info
      in: header
      required: false
      description: >-
        **Required JWT permission: `council_sage`** (informational only --
        enforced server-side)
      schema:
        type: string
  schemas:
    CouncilSageCreate:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          format: uuid
        name:
          type:
            - string
            - 'null'
        role:
          type:
            - string
            - 'null'
        role_level:
          $ref: '#/components/schemas/RoleLevelEnum'
        instructions:
          type:
            - string
            - 'null'
        results_instructions:
          type:
            - string
            - 'null'
        intro_question:
          type:
            - string
            - 'null'
        duration:
          type:
            - integer
            - 'null'
        tone:
          type:
            - string
            - 'null'
        context_id:
          type:
            - string
            - 'null'
          format: uuid
        sage_id:
          type:
            - string
            - 'null'
          format: uuid
        results_id:
          type:
            - string
            - 'null'
          format: uuid
        council_id:
          type:
            - string
            - 'null'
          format: uuid
        meta_data:
          type:
            - object
            - 'null'
          additionalProperties: true
        active:
          type: boolean
          default: true
    CouncilSageResponse:
      type: object
      description: Council sage record (from CouncilSageModel.to_dict())
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        role:
          type: string
        role_level:
          type: string
        instructions:
          type:
            - string
            - 'null'
        results_instructions:
          type:
            - string
            - 'null'
        context_id:
          type: string
          format: uuid
        intro_question:
          type:
            - string
            - 'null'
        duration:
          type:
            - integer
            - 'null'
        version:
          type: integer
        sage_id:
          type: string
          format: uuid
        council_id:
          type: string
        results_id:
          type: string
          format: uuid
        meta_data:
          type:
            - object
            - 'null'
        active:
          type: boolean
        tone:
          type:
            - string
            - 'null'
        status_id:
          type: string
          format: uuid
        chat_avatar:
          type:
            - string
            - 'null'
        language_code:
          type:
            - string
            - 'null'
        followup_days:
          type:
            - integer
            - 'null'
        audio:
          type: boolean
        is_demo:
          type: boolean
        is_internal:
          type: boolean
        language:
          type: boolean
        test_results:
          type:
            - object
            - 'null'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
    RoleLevelEnum:
      type: string
      enum:
        - entry
        - junior
        - mid
        - senior
        - principal
        - other
      description: |
        Experience level:
        - `entry` -- entry-level / intern
        - `junior` -- 0-2 years
        - `mid` -- 2-5 years
        - `senior` -- 5-10 years
        - `principal` -- 10+ years / staff
        - `other` -- fallback
  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

````