{
 "openapi": "3.1.0",
 "info": {
  "title": "Corrective & Preventive Actions (Manufacturing)",
  "version": "20261030b",
  "description": "The investigation, and — the part that is always skipped — the check that it worked. A CAPA closed without a verification date is closed on hope."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "capa": {
    "type": "object",
    "required": [
     "title"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "Id",
      "readOnly": true
     },
     "org_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org id",
      "readOnly": true
     },
     "org_unit_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org unit id",
      "readOnly": true
     },
     "capa_no": {
      "type": "string",
      "description": "Capa no",
      "readOnly": true
     },
     "title": {
      "type": "string",
      "description": "Title"
     },
     "description": {
      "type": "string",
      "description": "Description"
     },
     "capa_type": {
      "type": "string",
      "description": "Type",
      "enum": [
       "corrective",
       "preventive",
       "both"
      ]
     },
     "source": {
      "type": "string",
      "description": "Source",
      "enum": [
       "nonconformance",
       "complaint",
       "audit",
       "deviation",
       "trend",
       "management_review",
       "regulatory",
       "supplier",
       "internal_improvement"
      ]
     },
     "priority": {
      "type": "string",
      "description": "Priority",
      "enum": [
       "low",
       "medium",
       "high",
       "critical"
      ]
     },
     "risk_score": {
      "type": "integer",
      "description": "Risk score"
     },
     "item_id": {
      "type": "string",
      "format": "uuid",
      "description": "Item"
     },
     "supplier_id": {
      "type": "string",
      "format": "uuid",
      "description": "Supplier"
     },
     "work_center_id": {
      "type": "string",
      "format": "uuid",
      "description": "Work center"
     },
     "process_area": {
      "type": "string",
      "description": "Process area"
     },
     "investigation_method": {
      "type": "string",
      "description": "Investigation method",
      "enum": [
       "five_why",
       "fishbone",
       "8d",
       "fault_tree",
       "is_is_not",
       "fmea",
       "pareto",
       "other"
      ]
     },
     "root_cause": {
      "type": "string",
      "description": "Root cause"
     },
     "root_cause_category": {
      "type": "string",
      "description": "Cause category"
     },
     "investigation_notes": {
      "type": "string",
      "description": "Investigation notes"
     },
     "containment": {
      "type": "string",
      "description": "Containment"
     },
     "corrective_action": {
      "type": "string",
      "description": "Corrective action"
     },
     "preventive_action": {
      "type": "string",
      "description": "Preventive action"
     },
     "change_order_id": {
      "type": "string",
      "format": "uuid",
      "description": "Authorized by change order"
     },
     "effectiveness_criteria": {
      "type": "string",
      "description": "What \"it worked\" would look like"
     },
     "effectiveness_check_due": {
      "type": "string",
      "format": "date",
      "description": "Effectiveness check due"
     },
     "effectiveness_verified_at": {
      "type": "string",
      "format": "date-time",
      "description": "Effectiveness verified at",
      "readOnly": true
     },
     "effectiveness_verdict": {
      "type": "string",
      "description": "Effectiveness verdict",
      "readOnly": true
     },
     "effectiveness_notes": {
      "type": "string",
      "description": "Effectiveness notes",
      "readOnly": true
     },
     "owner_id": {
      "type": "string",
      "format": "uuid",
      "description": "Owner"
     },
     "raised_by": {
      "type": "string",
      "format": "uuid",
      "description": "Raised by",
      "readOnly": true
     },
     "raised_at": {
      "type": "string",
      "format": "date-time",
      "description": "Raised at",
      "readOnly": true
     },
     "due_date": {
      "type": "string",
      "format": "date",
      "description": "Due"
     },
     "closed_by": {
      "type": "string",
      "format": "uuid",
      "description": "Closed by",
      "readOnly": true
     },
     "closed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Closed at",
      "readOnly": true
     },
     "status": {
      "type": "string",
      "description": "Status",
      "readOnly": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "xf_text_1": {
      "type": "string",
      "description": "Xf text 1",
      "readOnly": true
     },
     "xf_text_2": {
      "type": "string",
      "description": "Xf text 2",
      "readOnly": true
     },
     "xf_text_3": {
      "type": "string",
      "description": "Xf text 3",
      "readOnly": true
     },
     "xf_text_4": {
      "type": "string",
      "description": "Xf text 4",
      "readOnly": true
     },
     "xf_text_5": {
      "type": "string",
      "description": "Xf text 5",
      "readOnly": true
     },
     "xf_num_1": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 1",
      "readOnly": true
     },
     "xf_num_2": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 2",
      "readOnly": true
     },
     "xf_num_3": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 3",
      "readOnly": true
     },
     "xf_date_1": {
      "type": "string",
      "format": "date",
      "description": "Xf date 1",
      "readOnly": true
     },
     "xf_date_2": {
      "type": "string",
      "format": "date",
      "description": "Xf date 2",
      "readOnly": true
     },
     "created_by": {
      "type": "string",
      "format": "uuid",
      "description": "Created by",
      "readOnly": true
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Updated at",
      "readOnly": true
     },
     "updated_by": {
      "type": "string",
      "format": "uuid",
      "description": "Updated by",
      "readOnly": true
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/mfg/capa": {
   "get": {
    "summary": "list capa",
    "operationId": "list_capa_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create capa",
    "operationId": "create_capa_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}": {
   "get": {
    "summary": "get capa",
    "operationId": "get_capa_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change capa",
    "operationId": "change_capa_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete capa",
    "operationId": "delete_capa_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{parentId}/actions": {
   "get": {
    "summary": "Actions",
    "operationId": "action_capa_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Actions",
    "operationId": "action_capa_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{parentId}/actions/{lineId}": {
   "put": {
    "summary": "Actions",
    "operationId": "action_capa_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Actions",
    "operationId": "action_capa_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_capa_0_6",
    "description": "Body keys: overrides, preview, withLines",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}/verify": {
   "post": {
    "summary": "Verify",
    "operationId": "action_capa_0_6",
    "description": "Body keys: verdict, notes; verdict one of effective|partially_effective|not_effective|too_early",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}/investigate": {
   "post": {
    "summary": "Investigate",
    "operationId": "action_capa_0_6",
    "description": "Body keys: investigationMethod",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}/plan": {
   "post": {
    "summary": "Plan",
    "operationId": "action_capa_0_6",
    "description": "Body keys: rootCause, correctiveAction, preventiveAction",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}/implement": {
   "post": {
    "summary": "Implement",
    "operationId": "action_capa_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/capa/{id}/cancel": {
   "post": {
    "summary": "Cancel",
    "operationId": "action_capa_0_6",
    "description": "Body keys: reason",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}