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

# Start sage build workflow

> Initiates the full sage build process by calling the Python
service. If a valid build is already in progress, resumes it
instead of starting a new one.

Checks credits before starting (deduction happens at
`complete_build`). Non-admin users cannot rebuild a sage that
has already been completed.

Build timeout is 20 minutes. Timed-out builds are automatically
cleared so the user can restart.

Registered as `wp_ajax_sagescreen_start_full_sage_build` — **login required**.




## OpenAPI

````yaml /openapi/private/specs/wp/sage-internal.yml post /wp-admin/admin-ajax.php?action=sagescreen_start_full_sage_build
openapi: 3.1.0
info:
  title: SageScreen — Sage Module
  description: >
    Council sage management. Sages are AI screening assistants customized

    per council. Each council can have system sages (non-customizable,

    auto-attached) and custom sages (built through a multi-step workflow).


    **CPT:** `ss_council_sage`

    **Custom statuses:** `ss_draft`, `ss_building`, `ss_active`, `ss_inactive`,
    `ss_paused`


    ## Build Workflow


    Custom sages go through a 6-step creation workflow:

    1. **Context** — Define role, level, and job description

    2. **Culture** — Configure tone, scoring, intro question, evaluation
    guidelines

    3. **Build** — Automated build via Python service (8 sub-steps)

    4. **Test** — Optional test screen to verify sage behavior

    5. **Finalize** — Review and confirm build

    6. **Deploy** — Set email config and activate sage


    Build sub-steps (step 3) run sequentially in the Python service:

    `starting` → `creating_sage` → `sage_generation` → `test_shu` →

    `test_ha` → `test_ri` → `transcending_training` → `enlightenment`
  version: 1.0.0
servers:
  - url: https://{domain}/wp-json/sagescreen/v1
    description: WordPress REST API
    variables:
      domain:
        default: api.sagescreen.app
security: []
tags:
  - name: Sage – REST
    description: REST API endpoints for sage operations and Python callbacks
  - name: Sage – CRUD
    description: AJAX endpoints for sage creation, editing, and status management
  - name: Sage – Build Workflow
    description: AJAX endpoints for the multi-step sage build process
paths:
  /wp-admin/admin-ajax.php?action=sagescreen_start_full_sage_build:
    post:
      tags:
        - Sage – Build Workflow
      summary: Start sage build workflow
      description: >
        Initiates the full sage build process by calling the Python

        service. If a valid build is already in progress, resumes it

        instead of starting a new one.


        Checks credits before starting (deduction happens at

        `complete_build`). Non-admin users cannot rebuild a sage that

        has already been completed.


        Build timeout is 20 minutes. Timed-out builds are automatically

        cleared so the user can restart.


        Registered as `wp_ajax_sagescreen_start_full_sage_build` — **login
        required**.
      operationId: ajaxStartFullSageBuild
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - action
                - nonce
                - sage_id
              properties:
                action:
                  type: string
                  const: sagescreen_start_full_sage_build
                nonce:
                  type: string
                  description: WP nonce for `sagescreen_frontend_nonce`
                  examples:
                    - abc123def456
                sage_id:
                  type: integer
                  description: WordPress post ID of the council sage
                  examples:
                    - 1234
      responses:
        '200':
          description: Build start result
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/StartBuildSuccess'
                  - $ref: '#/components/schemas/AjaxErrorResponse'
              examples:
                newBuild:
                  summary: New build started
                  value:
                    success: true
                    run_id: run_abc123def456
                    total_time: 600000
                    steps:
                      - name: starting
                        label: Starting
                        max_time: 30000
                        step_order: 1
                      - name: creating_sage
                        label: Creating Sage
                        max_time: 60000
                        step_order: 2
                      - name: sage_generation
                        label: Sage Generation
                        max_time: 120000
                        step_order: 3
                      - name: test_shu
                        label: Test Shu
                        max_time: 60000
                        step_order: 4
                      - name: test_ha
                        label: Test Ha
                        max_time: 60000
                        step_order: 5
                      - name: test_ri
                        label: Test Ri
                        max_time: 60000
                        step_order: 6
                      - name: transcending_training
                        label: Transcending Training
                        max_time: 120000
                        step_order: 7
                      - name: enlightenment
                        label: Enlightenment
                        max_time: 90000
                        step_order: 8
                rebuildDenied:
                  summary: Non-admin rebuild denied
                  value:
                    success: false
                    message: >-
                      This sage has already been built. Only administrators can
                      rebuild.
                insufficientCredits:
                  summary: Not enough credits
                  value:
                    success: false
                    message: Insufficient credits to build sage
                noSageId:
                  summary: Missing sage ID
                  value:
                    success: false
                    message: sage_id is required
      security:
        - wpAjaxNonce: []
components:
  schemas:
    StartBuildSuccess:
      type: object
      properties:
        success:
          type: boolean
          const: true
          examples:
            - true
        run_id:
          type: string
          description: Workflow run ID for polling
          examples:
            - run_abc123def456
        total_time:
          type: integer
          description: Sum of all step max_time values in milliseconds
          examples:
            - 600000
        steps:
          type: array
          items:
            $ref: '#/components/schemas/BuildStep'
        resumed:
          type: boolean
          description: true if an existing build was resumed instead of starting fresh
          examples:
            - false
        build_started:
          type: string
          description: Unix timestamp of build start (only present when resumed)
          examples:
            - '1739980800'
    AjaxErrorResponse:
      type: object
      description: |
        Standard AJAX error. The `data` field is either a plain string
        (from `wp_send_json_error`) or absent when using `wp_send_json`
        directly with `success: false`.
      properties:
        success:
          type: boolean
          const: false
          examples:
            - false
        message:
          type: string
          description: Error message (when using wp_send_json directly)
          examples:
            - Security check failed
        data:
          oneOf:
            - type: string
              examples:
                - Security check failed
            - type: object
              properties:
                message:
                  type: string
                  examples:
                    - Insufficient permissions
    BuildStep:
      type: object
      description: Build workflow sub-step metadata
      properties:
        name:
          type: string
          description: Step identifier
          examples:
            - sage_generation
        label:
          type: string
          description: Human-readable step label
          examples:
            - Sage Generation
        max_time:
          type: integer
          description: Maximum expected duration in milliseconds
          examples:
            - 120000
        step_order:
          type: integer
          description: Execution order (1-based)
          examples:
            - 3
        state:
          $ref: '#/components/schemas/BuildStepState'
    BuildStepState:
      type: string
      description: State of an individual build sub-step
      enum:
        - pending
        - running
        - completed
        - failed
      examples:
        - running
  securitySchemes:
    wpAjaxNonce:
      type: apiKey
      in: query
      name: nonce
      description: WordPress AJAX nonce (passed as form field, verified per-action)

````