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

# Create a corrective action plan

> Requires the `caps.write` permission + CSRF. Idempotent adoption: if a non-terminal (not `verified`/`rejected`) CAP already exists for the same target with the same problem statement (or title, if no statement was given), that existing CAP is returned verbatim instead of creating a duplicate -- no audit row is written in that case. Otherwise inserts a new CAP in `proposed` status with a path-tier-specific default proof window (`automated` = 14 days, `governed` = 30, `expert` = 60) and writes an `audit_log` row (tenant schema) (`cap_created`). Returns 201.



## OpenAPI

````yaml /api-reference/openapi.json post /remediation/caps
openapi: 3.1.0
info:
  title: CL MVP Product API
  description: >-
    The Causeloop MVP Product API is a deliberately small, explicitly
    allowlisted HTTP surface: `services/api/product_app.py` enumerates every one
    of the 44 published (method, path) operations drawn from seven routers, and
    only those operations are mounted onto this app -- everything else defined
    in the underlying routers (and the entire legacy research surface in
    `services/api/main.py`) is not exposed here. Staff (employee) and
    tenant-user sessions are separate cookie-based principals with no shared
    session table; mutating requests are protected by a double-submit CSRF
    cookie/header pair. See `/api-reference/authentication` for session and CSRF
    details, and `/api-reference/errors-and-conventions` for shared error shapes
    and status-code conventions.
  version: 1.0.0
servers: []
security: []
tags:
  - name: Auth
    description: >-
      Staff (employee) and tenant-user session lifecycle: login/logout,
      current-identity reads, invitation acceptance, and the public pre-login
      workspace directory.
  - name: Staff Onboarding
    description: >-
      The Onboarding Portal surface used to create, provision, ingest data for,
      train, activate, and go-live a tenant. Every operation requires an
      authenticated employee session; mutations additionally require the
      `onboarding_admin` control role (`support_readonly` employees can read but
      not write).
  - name: Insights
    description: >-
      Tenant-facing reads of materialized insight collections (themes, severity,
      issues, fishbone, and related model outputs) produced by the training and
      materialization pipeline.
  - name: Members
    description: Read-only tenant member directory.
  - name: Sources
    description: Tenant-facing source-connector registration and file-upload ingest.
  - name: Remediation
    description: >-
      Tenant-scoped corrective action plans (CAPs), human-in-the-loop issue
      reviews, the tenant audit trail, and the branded Excel export.
  - name: Health & Observability
    description: >-
      Unauthenticated liveness/readiness probes and the employee-only Prometheus
      metrics scrape endpoint.
paths:
  /remediation/caps:
    post:
      tags:
        - Remediation
      summary: Create a corrective action plan
      description: >-
        Requires the `caps.write` permission + CSRF. Idempotent adoption: if a
        non-terminal (not `verified`/`rejected`) CAP already exists for the same
        target with the same problem statement (or title, if no statement was
        given), that existing CAP is returned verbatim instead of creating a
        duplicate -- no audit row is written in that case. Otherwise inserts a
        new CAP in `proposed` status with a path-tier-specific default proof
        window (`automated` = 14 days, `governed` = 30, `expert` = 60) and
        writes an `audit_log` row (tenant schema) (`cap_created`). Returns 201.
      operationId: create_cap_remediation_caps_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCapRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CapRecord'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateCapRequest:
      properties:
        target_type:
          type: string
          title: Target Type
        target_id:
          type: string
          title: Target Id
        title:
          type: string
          title: Title
        problem_statement:
          type: string
          title: Problem Statement
          default: ''
        root_cause:
          type: string
          title: Root Cause
          default: ''
        containment_action:
          type: string
          title: Containment Action
          default: ''
        corrective_action:
          type: string
          title: Corrective Action
          default: ''
        preventive_action:
          type: string
          title: Preventive Action
          default: ''
        success_metric:
          type: string
          title: Success Metric
          default: ''
        verification_evidence:
          type: string
          title: Verification Evidence
          default: ''
        owner:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner
        due_date:
          anyOf:
            - type: string
            - type: 'null'
          title: Due Date
        path_tier:
          type: string
          enum:
            - automated
            - governed
            - expert
          title: Path Tier
          default: governed
      type: object
      required:
        - target_type
        - target_id
        - title
      title: CreateCapRequest
    CapRecord:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        target_type:
          type: string
          title: Target Type
        target_id:
          type: string
          title: Target Id
        title:
          type: string
          title: Title
        status:
          type: string
          enum:
            - proposed
            - approved
            - in_progress
            - blocked
            - completed
            - verified
            - rejected
          title: Status
        version:
          type: integer
          title: Version
        due_date:
          anyOf:
            - type: string
            - type: 'null'
          title: Due Date
        created_at:
          type: string
          title: Created At
        updated_at:
          type: string
          title: Updated At
        owner:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner
        problem_statement:
          type: string
          title: Problem Statement
          default: ''
        root_cause:
          type: string
          title: Root Cause
          default: ''
        containment_action:
          type: string
          title: Containment Action
          default: ''
        corrective_action:
          type: string
          title: Corrective Action
          default: ''
        preventive_action:
          type: string
          title: Preventive Action
          default: ''
        success_metric:
          type: string
          title: Success Metric
          default: ''
        verification_evidence:
          type: string
          title: Verification Evidence
          default: ''
        path_tier:
          type: string
          enum:
            - automated
            - governed
            - expert
          title: Path Tier
          default: governed
        proof_window_days:
          type: integer
          title: Proof Window Days
          default: 30
        steps:
          additionalProperties: true
          type: object
          title: Steps
        proof_started_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Proof Started At
        proof_verified_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Proof Verified At
      type: object
      required:
        - id
        - target_type
        - target_id
        - title
        - status
        - version
        - due_date
        - created_at
        - updated_at
      title: CapRecord
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````