{
  "openapi": "3.1.0",
  "info": {
    "title": "Polara Labs API",
    "version": "1.1.0",
    "description": "Public API for the Polara Labs SOC 2 compliance platform. All endpoints live under /.netlify/functions/. Authentication uses JWT bearer tokens issued by /auth-login. Responses follow a standard envelope: { success: true, data: {...} } on success or { success: false, error: { code, message } } on failure. THE ORDER OF THE FUNNEL, because callers written against an older pay-first flow will be wrong: auth-signup creates the account and a draft assessment, final-submit-assessment submits the completed intake, and the readiness results (score, tier, every gap category with exact counts, two or three findings written out, and the exact size of the locked remainder) come back with NO payment involved at any point. Payment is asked for only after those results exist, which is when a payment_url_* on check-payment-status becomes the thing to present. Endpoints that spend money or produce the paid deliverable (AI help, policy generation, report generation, and evidence uploads beyond the free workspace allowance) answer 402 PAYMENT_REQUIRED to an unpaid caller. An unpaid SOC 2 account whose assessment found gaps has a free workspace: it can work and close its gaps and upload a limited number of evidence files without paying; treat a 402 as a terminal answer and never as a retryable one. There is no free downloadable report at any tier. Polara Labs is not a CPA firm. SOC 2 examinations are performed by independent licensed U.S. CPA firms, the independent partner auditors.",
    "contact": {
      "email": "help@polaralabs.com",
      "url": "https://www.polaralabs.com"
    }
  },
  "servers": [
    {
      "url": "https://www.polaralabs.com/.netlify/functions",
      "description": "Production"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable code, e.g. AUTH_REQUIRED, VALIDATION_ERROR, NOT_FOUND, RATE_LIMITED, INTERNAL_ERROR"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "PaymentStatus": {
        "type": "object",
        "properties": {
          "paid": {
            "type": "boolean"
          },
          "payment_status": {
            "type": "string",
            "enum": [
              "unpaid",
              "paid",
              "waived"
            ]
          },
          "paid_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "assessment_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The assessment this status describes. Null only when the account has no assessment yet."
          },
          "assessment_type": {
            "type": "string",
            "enum": [
              "type1",
              "type2"
            ],
            "nullable": true
          },
          "framework": {
            "type": "string",
            "example": "soc2",
            "description": "The assessment's framework id, for example soc2 or iso27001."
          },
          "payment_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Back compat alias for payment_url_type2_monthly."
          },
          "payment_url_onboarding": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "example": "https://buy.stripe.com/5kQ6oI2MO6AW77Y7ol0000i",
            "description": "Stripe Payment Link for Star, $2,000 one time, with client_reference_id pre set. Platform onboarding only: no SOC 2 Type 1 report is included at this price. A caller presents this OR payment_url_type1 and never both as steps. Do not present either link before the readiness results exist: the intake assessment and the gap analysis it produces are free, and the entry payment buys AI help, policy generation and the report rather than the score."
          },
          "payment_url_type1": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for Star with a SOC 2 Type 1 report, $4,000 one time in total, with client_reference_id pre set. Same platform as payment_url_onboarding, bought together with the SOC 2 Type 1 examination and report by an independent licensed U.S. CPA firm, with no separate auditor invoice."
          },
          "payment_url_type1_upgrade": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link that adds the SOC 2 Type 1 examination and report to a paid SOC 2 account that bought the platform without it, with client_reference_id appended by the server. Null for every other account."
          },
          "payment_url_type2": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for the SOC 2 Type 2 term sold before the current plans. Returned only to an account whose entry payment predates the current plans, at the price that account accepted at its own checkout. Term mechanics, stated in full at /terms and accepted on record at checkout: the term runs all 12 months, the whole term is owed, and an in-term cancellation keeps billing and access running to the end of the committed 12 months."
          },
          "payment_url_type2_monthly": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Explicit alias for payment_url_type2, the monthly schedule of the term sold before the current plans. Returned only to an account whose entry payment predates the current plans, at the price that account accepted at its own checkout."
          },
          "payment_url_type2_annual": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for the term sold before the current plans, paid up front. Returned only to an account whose entry payment predates the current plans, at the price that account accepted at its own checkout."
          },
          "preferred_entry_plan": {
            "type": "string",
            "nullable": true,
            "description": "The entry the company chose earlier (onboarding or type1), if any, so a caller can preselect it."
          },
          "default_entry_plan": {
            "type": "string",
            "nullable": true,
            "description": "The same value as preferred_entry_plan, kept for older callers."
          },
          "company_name": {
            "type": "string",
            "nullable": true
          },
          "entry_plan": {
            "type": "string",
            "nullable": true,
            "description": "The entry bought, as recorded at checkout, for example onboarding or type1. Null when none is recorded."
          },
          "included_audit_consumed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the SOC 2 Type 2 audit included in the term was started. Null while it is unspent."
          },
          "payment_url_iso": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "A framework's own checkout link, with client_reference_id appended by the server. Null on a SOC 2 assessment, on a paid one, and for ISO 27001 under the current plans, where it is bought inside Constellation (payment_url_constellation)."
          },
          "assessments": {
            "type": "array",
            "description": "Every active assessment on the account, SOC 2 first, for switching between frameworks.",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "framework": {
                  "type": "string"
                },
                "payment_status": {
                  "type": "string",
                  "nullable": true
                },
                "status": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "payment_url_orbit": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for Orbit, $7,800 a year, with client_reference_id appended by the server. One SOC 2 Type 2 audit by an independent licensed U.S. CPA firm is included in every contract year. Null when checkout for this plan is not open or the caller is not eligible."
          },
          "payment_url_constellation": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for Constellation, $10,800 a year, with client_reference_id appended by the server. Everything in Orbit plus ISO/IEC 27001 and ISO/IEC 42001 readiness. Null when checkout for this plan is not open or the caller is not eligible."
          },
          "payment_url_orbit_after_star": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for the first year of Orbit at $5,800, offered within 12 months of paying for Star, with client_reference_id appended by the server. It renews at $7,800 a year. Null when checkout for this plan is not open or the caller is not eligible."
          },
          "payment_url_orbit_monthly": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Stripe Payment Link for Orbit at $700 a month on a 12-month term, offered only to Star customers, with client_reference_id appended by the server. Null when checkout for this plan is not open or the caller is not eligible."
          },
          "orbit_offer_expires_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the first-year Orbit offer for a Star customer closes: 12 months after the Star payment. Null when the caller has no open offer."
          },
          "plan": {
            "type": "object",
            "nullable": true,
            "description": "The account's plan record under the current plans. Null when the account has none. plan is star, orbit, constellation, mission or legacy; contract_year is the current contract year of the term, or null before the term starts.",
            "properties": {
              "plan": {
                "type": "string",
                "enum": [
                  "star",
                  "orbit",
                  "constellation",
                  "mission",
                  "legacy"
                ]
              },
              "status": {
                "type": "string"
              },
              "frameworks": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "contract_year": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "start": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "end": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              },
              "type2_offer": {
                "type": "string",
                "enum": [
                  "grid",
                  "legacy"
                ],
                "description": "The SOC 2 Type 2 offer this account sees: grid (Orbit), or legacy for an account already on a Type 2 subscription or held on the terms of its own checkout."
              }
            }
          },
          "grid_year": {
            "type": "object",
            "nullable": true,
            "description": "This contract year's included SOC 2 Type 2 audit on an active Orbit or Constellation plan: year_start, window_end (the end of that year's observation window) and consumed_at (when that year's included audit started, or null while it is unspent). Null for every other account.",
            "properties": {
              "year_start": {
                "type": "string",
                "format": "date-time"
              },
              "window_end": {
                "type": "string",
                "format": "date-time"
              },
              "consumed_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/evidence-attach": {
      "post": {
        "summary": "Attach a file the customer already uploaded to more of their gaps, so one file proves several tasks. Refused for impersonated sessions",
        "description": "Closure is decided by the one completion rule: an upload-only gap the rule now calls complete closes; a fix-it gap or an already complete one keeps its state with the file attached. Generated policies, a SOC 2 report and signed records cannot be attached as proof. ISO 27001 accounts must be paid; a free SOC 2 workspace attach uses no upload quota.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "evidence_id",
                  "gap_ids"
                ],
                "properties": {
                  "evidence_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "gap_ids": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 25,
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ evidence_id, results: [{ gap_id, question_code, outcome: closed | attached_open | already_attached | failed, status }], closed_count }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND (no such file, or not one of the caller's)"
          },
          "409": {
            "description": "EVIDENCE_SUPERSEDED, or GAPS_CHANGED when a gap is no longer live on the same assessment (nothing written)"
          },
          "422": {
            "description": "EVIDENCE_NOT_ATTACHABLE (a generated policy, a SOC 2 report or a signed record)"
          }
        }
      }
    },
    "/iso-soc2-import": {
      "get": {
        "summary": "An ISO 27001 customer's SOC 2 report import: one import by id, or the latest for the caller's ISO assessment (null when none), with each suggestion and what accepting it would do",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "import_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The import (status, report type, period end, auditor firm, suggestions) or null"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "NOT_FOR_FRAMEWORK (the caller's assessment is not ISO 27001)"
          }
        }
      },
      "post": {
        "summary": "Bring your SOC 2 report to an ISO 27001 program: get an upload URL, upload in parts, start the read, set the period end, confirm a report that names another company is your own, or accept or decline suggestions. Refused for impersonated sessions",
        "description": "Accepting a suggestion closes a task only when the report is a Type 2 whose period ended within 12 months, the coverage is full, no exception is noted, the task is a show-it task and its row is upload-only. Anything else attaches the report for reference, which never counts as proof. The read runs in the background and answers 202.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "file_name",
                      "size_bytes"
                    ],
                    "properties": {
                      "action": {
                        "const": "upload_url"
                      },
                      "file_name": {
                        "type": "string"
                      },
                      "size_bytes": {
                        "type": "integer",
                        "maximum": 31457280
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "import_id",
                      "part_number",
                      "data_base64"
                    ],
                    "properties": {
                      "action": {
                        "const": "upload_part"
                      },
                      "import_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "part_number": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "data_base64": {
                        "type": "string",
                        "description": "At most 4 MB a part"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "import_id",
                      "own_report_confirmed"
                    ],
                    "properties": {
                      "action": {
                        "const": "start"
                      },
                      "import_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "own_report_confirmed": {
                        "const": true
                      },
                      "parts": {
                        "type": "integer"
                      },
                      "file_name": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "import_id",
                      "period_end"
                    ],
                    "properties": {
                      "action": {
                        "const": "set_period"
                      },
                      "import_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "period_end": {
                        "type": "string",
                        "format": "date"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "import_id"
                    ],
                    "description": "The report names another company, and the customer confirms it is their own company's report under another name. Until then accepting a suggestion attaches the report for reference only.",
                    "properties": {
                      "action": {
                        "const": "confirm_own_report"
                      },
                      "import_id": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "suggestion_ids",
                      "decision"
                    ],
                    "properties": {
                      "action": {
                        "const": "decide"
                      },
                      "suggestion_ids": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 50,
                        "items": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "decision": {
                        "type": "string",
                        "enum": [
                          "accept",
                          "decline"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "upload_url: { import_id, upload_url, expires_in }; upload_part: { received }; set_period and confirm_own_report: the updated import; decide: the decisions with their effect"
          },
          "202": {
            "description": "start: the read is queued"
          },
          "400": {
            "description": "VALIDATION_ERROR, NOT_A_PDF"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "NOT_FOR_FRAMEWORK, IMPORT_RUNNING, IMPORT_FINISHED, IMPORT_CHANGED, IMPORT_NOT_READY, IMPORT_NOT_RETRYABLE, IMPORT_NOT_AWAITING_UPLOAD, PERIOD_ALREADY_SET, PERIOD_REQUIRED, UPLOAD_MISSING"
          },
          "413": {
            "description": "TOO_LARGE (over 30 MB, or a part over 4 MB)"
          },
          "429": {
            "description": "RATE_LIMITED (uploads, parts and starts are counted per day or hour)"
          },
          "503": {
            "description": "IMPORT_NOT_STARTED (the read could not be queued; retry in a minute)"
          }
        }
      }
    },
    "/iso-risk-starter": {
      "get": {
        "summary": "The risks suggested for an ISO 27001 risk register: first a draft risk for every item the records list and no owned risk covers yet (a critical or high supplier, a supplier task IE8 names, an asset group, a clause 4.1 issue or 4.2 requirement; each carries `covers` and the asset_id or context_entry_ids that covers it), then twelve typical risks worded from the company's own scope answers. Beside them, supplier assets the answers name and the inventory lacks (`suggested_assets`, each dismissable through iso-isms-program dismiss_supplier_suggestion), the dismissed names, and `coverage` { total, covered, uncovered }. The customer adds a risk through /risk-register",
        "description": "Read only (loads the package inputs and builds the model, writes nothing), so an impersonated session may read it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Defaults to the caller's ISO 27001 assessment"
          }
        ],
        "responses": {
          "200": {
            "description": "{ assessment_id, suggested_assets, suggestions, coverage: { total, covered, uncovered }, dismissed_suppliers }"
          },
          "400": {
            "description": "VALIDATION_ERROR (malformed assessment_id)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH (the assessment is SOC 2)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/iso-soc2-report-status": {
      "post": {
        "summary": "The ISO 27001 customer says whether they hold a current SOC 2 report: false hides the SOC 2 upload prompt for good, true undoes it. Stored with who said it and when. Refused for impersonated sessions",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Defaults to the caller's ISO 27001 assessment"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "holds_soc2"
                ],
                "properties": {
                  "holds_soc2": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ holds_soc2, status: { holds, recorded_at, recorded_by_user_id } }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/iso-workspace": {
      "get": {
        "summary": "The ISO 27001 workspace in one read: phase and furthest phase reached, readiness from proof, next actions, the 93 Annex A controls, the management system records, the policies, stage readiness (each unmet condition with its detail, and the order breaks for records_in_order), the company accounts that may sign (roster, sponsor_account) and the SOC 2 import status",
        "description": "Read only: it never seeds or writes, so an impersonated session may read it. With view=tasks it returns every live task (prompts, answers, fix steps, files) of the ISO assessment, even for a company that also has a SOC 2 assessment. The nine clause tasks a management system record proves are not tasks: they are left out of view=tasks and listed on the workspace as record_backed_tasks (each with the records that prove it, whether those records now close it, and the answers and files stored on it before, read-only). A task whose upload a kept record stands in for carries upload_satisfied_by (the asset inventory task's inventory export, satisfied by the asset register once it holds an asset with an owner) and asks for no file. A control card never asks who owns the control: the owner is the Statement of Applicability row's. One policy's text is read from /iso-policy-reader.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "tasks"
              ]
            }
          },
          {
            "name": "assessment_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Defaults to the caller's ISO 27001 assessment"
          }
        ],
        "responses": {
          "200": {
            "description": "IsoWorkspace (frontend/types/isoWorkspace.ts), including package: whether a package is built and still current, or { assessment_id, tasks } for view=tasks"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown view or malformed assessment_id)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only; error.context.results_url points to the free results)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH (the assessment is SOC 2)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/iso-policy-reader": {
      "get": {
        "summary": "One ISMS policy as the customer reads it before approving: the stored text with its document control block, its state, version, what it was built from, what changed, and the content hash an approval binds to",
        "description": "The guided flow and the Policies screen both read this, so an approval sent with content_hash approves exactly the words shown (approve-policy refuses POLICY_CHANGED otherwise). state is not_drafted, drafting, failed, drafted, approved or stale. A policy that says what the records show is no longer so (a commitment to put in place a control its proof shows in place or a planned change that is done, a parameter left to a document the package does not hold, a frequency the company did not record) carries not_current, one sentence per statement, with refresh_available true and confirm_available false. Read only; company members may read; impersonated sessions may read.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "area",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "An ISO policy area id, for example access_control"
          }
        ],
        "responses": {
          "200": {
            "description": "{ area, title, state, version, markdown, content_hash, generated_at, approved_by_name, approved_at, changed_after_approval, failure_reason, annex_refs, clause_refs, built_from, changes, approver }"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown area)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only; error.context.results_url points to the free results)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH (the assessment is SOC 2)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/account-signer": {
      "get": {
        "summary": "Read the authenticated account's signing identity",
        "description": "Returns data.signer with name, title, complete and missing fields. Reads only the authenticated account, including auditor accounts without a customer assessment. No assessment content is returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Account signer identity in the standard success envelope"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "429": {
            "description": "RATE_LIMITED"
          }
        }
      },
      "post": {
        "summary": "Fill your own name and title, name the policy approver, name yourself the signatory, or send a step to the person named for it",
        "description": "Accepts name and title; ignores any caller-supplied account ID. Existing values cannot be overwritten. Use before retrying a letter signature refused with SIGNER_IDENTITY_REQUIRED. Signing itself never changes the account identity. With action delegate_policy_approval and { assessmentId, delegateUserId }, the company owner names the owner or an active member with a full name and job title as the policy approver; policies regenerated afterwards name that person, and regeneration clears the old approval. Answers data.policy_approver. Phase 78: action declare_signatory with { assessmentId, textVersion: 'authority-v1' } names the caller (the owner or an active member, with a full name and title) the company's signatory, recording when, who and whom they replaced; management's assertion and the description approval then need their signature. Answers data { signatory, already }. delegate_policy_approval also accepts delegateUserId equal to the caller's own id from an active member with textVersion authority-v1 (self_declared). action request_authority_action with { assessmentId, step } emails the named signatory, or the owner, a link to the step; one email per step every 12 hours (data { sent: false, already_sent_at } inside the window). Action set_signatory with { assessmentId, name, title }: the company owner names the company's signatory (contacts.signatory), any person; a full name and a title without the name in it, else 400 VALIDATION_ERROR (\"Put your title only, for example Chief Technology Officer.\"); 403 FORBIDDEN for anyone but the owner (a member names only themselves, with declare_signatory); 402 PAYMENT_REQUIRED unpaid; 409 FROZEN once the engagement is under way. Answers data.signatory { name, title }. GET and the own-identity save answer signer.invalid: the stored problems a signature will not print.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Your own name, or with set_signatory the signatory's full name"
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Your own job title, or with set_signatory the signatory's job title, without their name in it"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "delegate_policy_approval",
                      "declare_signatory",
                      "request_authority_action",
                      "set_signatory"
                    ],
                    "description": "Omit to save your own name and title"
                  },
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "delegate_policy_approval, declare_signatory, request_authority_action and set_signatory"
                  },
                  "delegateUserId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "delegate_policy_approval only"
                  },
                  "textVersion": {
                    "type": "string",
                    "enum": [
                      "authority-v1"
                    ],
                    "description": "declare_signatory, and delegate_policy_approval naming yourself"
                  },
                  "step": {
                    "type": "string",
                    "enum": [
                      "sign_assertion",
                      "sign_rep_letter",
                      "sign_engagement_letter",
                      "approve_description",
                      "respond_exception",
                      "disclose_exception",
                      "set_as_of",
                      "approve_policy",
                      "change_scope",
                      "trust_page",
                      "trust_document",
                      "cancel_subscription"
                    ],
                    "description": "request_authority_action only"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved data.signer in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN (delegate_policy_approval: not the company owner, or a member naming someone else; declare_signatory: not the owner or an active member; request_authority_action: no access to the assessment)"
          },
          "404": {
            "description": "NOT_FOUND (delegate_policy_approval: the assessment, or a person who is not an active member)"
          },
          "409": {
            "description": "SIGNER_IDENTITY_ON_FILE, SIGNER_IDENTITY_INVALID (delegate_policy_approval: the delegate has no valid full name and title); declare_signatory: SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID (error.context.signer); request_authority_action: NO_RECIPIENT, SELF_REQUEST"
          },
          "429": {
            "description": "RATE_LIMITED (declare_signatory and request_authority_action: 10 an hour each)"
          },
          "502": {
            "description": "EMAIL_FAILED (request_authority_action)"
          }
        }
      }
    },
    "/auth-login": {
      "post": {
        "summary": "Authenticate user and receive JWT",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns access token and user payload"
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    },
    "/auth-passkey-login": {
      "post": {
        "summary": "Sign in with a passkey: ask for options, then verify the browser's assertion",
        "description": "Public. step options answers WebAuthn request options (discoverable, user verification required) and sets a five minute challenge cookie. step verify checks the assertion against the stored passkey and answers the same session as auth-login: { message, user, token } and the polara_refresh cookie. Failed verifies count against a per-IP limit.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "step"
                    ],
                    "properties": {
                      "step": {
                        "type": "string",
                        "enum": [
                          "options"
                        ]
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "step",
                      "response"
                    ],
                    "properties": {
                      "step": {
                        "type": "string",
                        "enum": [
                          "verify"
                        ]
                      },
                      "response": {
                        "type": "object",
                        "description": "The browser's WebAuthn response JSON, as @simplewebauthn/browser returns it"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "options: { options }. verify: { message, user, token }, exactly as auth-login answers"
          },
          "400": {
            "description": "VALIDATION_ERROR (malformed body, unknown step, expired challenge) or PASSKEY_UNAVAILABLE (this origin does not offer passkeys)"
          },
          "401": {
            "description": "AUTH_REQUIRED: the passkey is not registered with Polara, or it could not be verified"
          },
          "429": {
            "description": "RATE_LIMITED: too many failed sign-in attempts from this address"
          },
          "503": {
            "description": "SESSION_UNAVAILABLE: the session could not be stored; no cookie is set"
          }
        }
      }
    },
    "/auth-passkey-register": {
      "post": {
        "summary": "Add a passkey to the signed-in account: ask for options, then verify the browser's credential",
        "description": "step options answers WebAuthn creation options (discoverable, user verification required, existing passkeys excluded) and sets a five minute challenge cookie. step verify stores the passkey and emails the account a security notice. An account holds at most 10 passkeys. An impersonated session is refused.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "step"
                    ],
                    "properties": {
                      "step": {
                        "type": "string",
                        "enum": [
                          "options"
                        ]
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "step",
                      "response"
                    ],
                    "properties": {
                      "step": {
                        "type": "string",
                        "enum": [
                          "verify"
                        ]
                      },
                      "response": {
                        "type": "object",
                        "description": "The browser's WebAuthn response JSON, as @simplewebauthn/browser returns it"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "options: { options }. verify: { passkey }",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "options": {
                          "type": "object"
                        },
                        "passkey": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "label": {
                              "type": "string",
                              "description": "Device label, such as Passkey on Mac"
                            },
                            "device_type": {
                              "type": "string",
                              "nullable": true,
                              "description": "singleDevice or multiDevice"
                            },
                            "backed_up": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "last_used_at": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR (malformed body, unknown step, expired challenge, credential not verified) or PASSKEY_UNAVAILABLE"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY: an impersonated session cannot add a passkey"
          },
          "409": {
            "description": "PASSKEY_LIMIT_REACHED (10 passkeys) or PASSKEY_EXISTS (already registered)"
          }
        }
      }
    },
    "/auth-passkeys": {
      "get": {
        "summary": "List the signed-in account's passkeys",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "{ passkeys }. Key material is never returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "passkeys": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "label": {
                                "type": "string",
                                "description": "Device label, such as Passkey on Mac"
                              },
                              "device_type": {
                                "type": "string",
                                "nullable": true,
                                "description": "singleDevice or multiDevice"
                              },
                              "backed_up": {
                                "type": "boolean"
                              },
                              "created_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "last_used_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH_REQUIRED"
          }
        }
      },
      "delete": {
        "summary": "Remove one of the signed-in account's passkeys",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ removed: true }"
          },
          "400": {
            "description": "VALIDATION_ERROR: id is missing or not a uuid"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY: an impersonated session cannot remove a passkey"
          },
          "404": {
            "description": "NOT_FOUND: no passkey with this id on the account"
          }
        }
      }
    },
    "/check-payment-status": {
      "get": {
        "summary": "Get current payment status and tier-specific Stripe checkout URLs for the authenticated user",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Polara-Framework",
            "in": "header",
            "required": false,
            "description": "Which of the account's assessments to read when it holds both SOC 2 and ISO 27001. Absent means the newest one. A ?framework= query parameter with the same values wins over the header. Any other value is refused with 400 VALIDATION_ERROR.",
            "schema": {
              "type": "string",
              "enum": [
                "soc2",
                "iso27001",
                "iso42001"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payment status with the two entry URLs and both Type 2 payment schedules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PaymentStatus"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/upgrade-to-type2": {
      "post": {
        "summary": "Start the paid Type 2 subscription on a paid SOC 2 assessment (onboarding or Type 1 entry; no Type 1 report required)",
        "description": "Returns the Stripe Checkout URL for the Type 2 subscription. Pricing tier is selected via the `cycle` field on the request body (default `monthly`). The audits row is created later by the Stripe webhook on checkout.session.completed.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId",
                  "observationStartDate",
                  "durationMonths"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "observationStartDate": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; must not be more than 30 days in the past"
                  },
                  "durationMonths": {
                    "type": "integer",
                    "enum": [
                      6,
                      9,
                      12
                    ]
                  },
                  "cycle": {
                    "type": "string",
                    "enum": [
                      "monthly",
                      "annual"
                    ],
                    "default": "monthly",
                    "description": "Payment schedule. For an account on Star: annual = Orbit, billed yearly at $7,800 a year, or $5,800 for the first year within 12 months of paying for Star; monthly = Orbit at $700 a month on a 12-month term. Each contract year of Orbit includes one SOC 2 Type 2 audit. An account whose entry payment predates the current plans is offered Orbit the same way, its entry payment counting as the Star payment; an account already on a Type 2 subscription keeps its own schedule."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns Stripe checkout URL for the selected cycle",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "checkout_url": {
                          "type": "string",
                          "format": "uri",
                          "description": "Stripe Checkout URL with client_reference_id pre-set to the assessment id"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "FORBIDDEN (not the owner or an active member of the company). Since phase 78 a member gets the same checkout as the owner, built on the owner's assessment id (client_reference_id), and an audit row checkout_started_by_member is written."
          },
          "409": {
            "description": "Already Type 2 (error.code = ALREADY_TYPE2)"
          }
        }
      }
    },
    "/cancel-subscription": {
      "post": {
        "summary": "Cancel an active Type 2 subscription (access continues through the committed term)",
        "description": "Type 2 monthly runs on a 12-month term. Within the committed year the subscription is scheduled to cancel at the term end (Stripe cancel_at); past year one it cancels at the current period end. Access to Type 2 features continues through the returned access_through date; when the cancel takes effect the customer.subscription.deleted webhook sets subscription_status to 'paused'. Idempotent: calling twice returns the same canceled_at timestamp. The authoritative state write happens via the Stripe webhooks; this endpoint writes optimistically for immediate UX feedback.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional. If provided, must match the caller's own assessment; otherwise the caller's assessment is resolved by user_id."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription marked to cancel at period end",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "canceled_at_period_end": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "canceled_at": {
                          "type": "string",
                          "format": "date-time",
                          "description": "ISO timestamp when cancel was first recorded"
                        },
                        "access_through": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "ISO timestamp when paid access ends (subscription_current_period_end)"
                        },
                        "already_canceled": {
                          "type": "boolean",
                          "description": "Present and true when the subscription was already canceled before this call (idempotent no-op)"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No active subscription to cancel (error.code = NO_SUBSCRIPTION) or invalid request body (VALIDATION_ERROR)"
          },
          "401": {
            "description": "Missing or invalid bearer token (error.code = AUTH_REQUIRED)"
          },
          "403": {
            "description": "OWNER_ONLY: only the owner, who holds the card, can do this. error.context { can_declare: false, step, kind: 'billing', named: { name } } (phase 78); the page offers to send it to the owner."
          },
          "404": {
            "description": "No assessment found for current user (error.code = NOT_FOUND) or subscription missing at Stripe (SUBSCRIPTION_NOT_FOUND)"
          },
          "502": {
            "description": "Stripe API error (error.code = STRIPE_ERROR)"
          }
        }
      }
    },
    "/create-billing-portal-session": {
      "post": {
        "summary": "Create a Stripe Billing Portal session for payment-method update",
        "description": "Returns a short-lived Stripe Billing Portal URL scoped via flow_data to the payment_method_update flow only. The caller is redirected to Stripe to update their card; subscription cancel is intentionally routed through /cancel-subscription instead. An account with no Stripe customer receives NO_CUSTOMER. Open to the owner and, since phase 78, to an active member of the company; a member's open writes the audit row billing_portal_opened_by_member.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Portal session created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "format": "uri",
                          "description": "Stripe-hosted Billing Portal URL (single-use, short-lived)"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Caller has no Stripe customer on file (error.code = NO_CUSTOMER)"
          },
          "401": {
            "description": "Missing or invalid bearer token (error.code = AUTH_REQUIRED)"
          },
          "404": {
            "description": "Assessment not found for current user (error.code = NOT_FOUND)"
          },
          "405": {
            "description": "Method not allowed, POST only (error.code = METHOD_NOT_ALLOWED)"
          },
          "502": {
            "description": "Stripe API error (error.code = STRIPE_ERROR)"
          }
        }
      }
    },
    "/checkout-started": {
      "post": {
        "summary": "Record that a member opened a checkout",
        "description": "Phase 78. The dashboard calls it, fire and forget, when someone opens a checkout link. For an active member of the company it writes the audit row checkout_started_by_member { assessment_id, checkout } and answers recorded: true; for the owner it records nothing and answers recorded: false. The purchase itself is credited to the company's assessment through the checkout's client_reference_id.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId",
                  "checkout"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "checkout": {
                    "type": "string",
                    "enum": [
                      "type1_upgrade",
                      "orbit",
                      "constellation",
                      "type2"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { recorded } }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND (no such assessment, or not the owner or an active member)"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/request-on-demand-audit": {
      "post": {
        "summary": "Starts the SOC 2 Type 2 audit included in the current contract year, or records a request for a later one",
        "description": "This endpoint never returns a checkout url and never states a figure. Orbit and Constellation include one SOC 2 Type 2 audit in every contract year: while the current contract year's audit is unused, this starts it, because that audit is included and there is nothing to buy. A later audit in a contract year that has already used its included audit is arranged on request: the request is recorded and the engagement is quoted before it begins. Accounts that bought before the current plans keep the terms they bought. Gates, in order: an active Type 2 subscription is required; the 3 month observation period must be complete; no Type 2 audit may already be in progress.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "UUID of the caller's own assessment"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Either the included audit was started, or the request was recorded for our team to price",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "outcome": {
                          "type": "string",
                          "enum": [
                            "audit_started",
                            "quote_requested"
                          ],
                          "description": "audit_started when the audit carried inside the term was begun. quote_requested when the request was recorded for our team to price with independent audit firms."
                        },
                        "audit_id": {
                          "type": "string",
                          "format": "uuid",
                          "nullable": true,
                          "description": "Present on audit_started. The audits row created for the audit carried inside the term."
                        },
                        "requested_at": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "Present on quote_requested. When the request was recorded."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error (VALIDATION_ERROR) or observation period not yet complete (OBSERVATION_INCOMPLETE)"
          },
          "401": {
            "description": "Missing or invalid bearer token (error.code = AUTH_REQUIRED)"
          },
          "403": {
            "description": "Caller lacks an active Type 2 subscription (error.code = SUBSCRIPTION_REQUIRED)"
          },
          "404": {
            "description": "Assessment not found or not owned by caller (error.code = NOT_FOUND)"
          },
          "409": {
            "description": "A Type 2 audit is already in progress (error.code = AUDIT_IN_PROGRESS)"
          }
        }
      }
    },
    "/final-get-dashboard": {
      "get": {
        "summary": "Get full dashboard state for the authenticated user (gaps, evidence, policies, workflow step, payment URLs)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Polara-Framework",
            "in": "header",
            "required": false,
            "description": "Which of the account's assessments to read when it holds both SOC 2 and ISO 27001. Absent means the newest one. A ?framework= query parameter with the same values wins over the header. Any other value is refused with 400 VALIDATION_ERROR.",
            "schema": {
              "type": "string",
              "enum": [
                "soc2",
                "iso27001",
                "iso42001"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dashboard payload"
          }
        }
      }
    },
    "/start-framework": {
      "post": {
        "summary": "Add a second compliance framework to the authenticated owner's account",
        "description": "One account can hold a SOC 2 assessment and an ISO 27001 assessment side by side. Creates the owner's draft assessment for the framework, or returns the one that already exists. No payment field is written; the new assessment starts at the free readiness questionnaire. Account owners only: a company member, an admin, an auditor and an impersonated session are refused. Select the framework on later requests with the X-Polara-Framework header.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "framework"
                ],
                "properties": {
                  "framework": {
                    "type": "string",
                    "enum": [
                      "soc2",
                      "iso27001",
                      "iso42001",
                      "gdpr",
                      "hipaa",
                      "nist_csf",
                      "pci_dss"
                    ],
                    "description": "The framework to start. gdpr, hipaa, nist_csf and pci_dss are readiness frameworks and need a submitted SOC 2 assessment first (409 SOC2_REQUIRED otherwise)."
                  },
                  "isoEntryState": {
                    "type": "string",
                    "description": "Optional ISO 27001 entry triage answer; ignored for SOC 2"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The owner already holds this framework: data = { assessment_id, framework, created: false }"
          },
          "201": {
            "description": "Created: data = { assessment_id, framework, created: true }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, or FORBIDDEN for a company member, an admin or an auditor"
          },
          "429": {
            "description": "RATE_LIMITED. Max 10 per owner per hour"
          }
        }
      }
    },
    "/stripe-webhook": {
      "post": {
        "summary": "Stripe webhook target. receives checkout.session.completed events. NOT meant to be called by clients; documented for completeness.",
        "responses": {
          "200": {
            "description": "Event processed"
          },
          "400": {
            "description": "Missing or invalid stripe-signature header"
          }
        }
      }
    },
    "/verify-report": {
      "get": {
        "summary": "Verify an issued SOC 2 report by the SHA-256 of its PDF or by the report reference printed on it (public, rate limited)",
        "description": "No account needed. Pass sha=<64 hex characters> (the SHA-256 of the report PDF) or ref=<report reference UUID printed on the document>. An unknown value answers 200 with verified:false. 60 lookups per 15 minutes per client.",
        "parameters": [
          {
            "name": "sha",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          {
            "name": "ref",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ verified:true, report_type, report_sha256, reference, issued_at, renderer_version, superseded, audit:{ audit_type, period_or_as_of }, opinion:{ firm_name, opinion_type }, company:{ legal_name } } or { verified:false }"
          },
          "400": {
            "description": "Malformed sha or ref (VALIDATION_ERROR)"
          },
          "429": {
            "description": "Rate limited (RATE_LIMITED)"
          }
        }
      }
    },
    "/dashboard-resume": {
      "get": {
        "summary": "The authenticated customer's last place in the dashboard, or with view=welcome the once-per-session welcome-back line (template for unpaid callers; a checked short model sentence may be used for paid callers)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "welcome"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ location }, or { message, place, encouragement, source }"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "429": {
            "description": "RATE_LIMITED"
          }
        }
      },
      "post": {
        "summary": "Record the authenticated customer's last place in the dashboard (view, optional gap or policy area), or with { heard_about } the optional answer to the results screen question 'How did you hear about Polara?'. One kind per request. Refused for impersonated sessions",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "location"
                    ],
                    "properties": {
                      "location": {
                        "type": "object",
                        "required": [
                          "view"
                        ],
                        "properties": {
                          "view": {
                            "type": "string",
                            "enum": [
                              "questionnaire",
                              "remediation",
                              "policies",
                              "report",
                              "observation",
                              "type1"
                            ]
                          },
                          "gap": {
                            "type": "string"
                          },
                          "area": {
                            "type": "string"
                          },
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "heard_about"
                    ],
                    "properties": {
                      "heard_about": {
                        "type": "string",
                        "enum": [
                          "google",
                          "ai_assistant",
                          "reddit",
                          "linkedin",
                          "colleague",
                          "other"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ saved: true, location }, or { saved, already, heard_about }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "429": {
            "description": "RATE_LIMITED"
          }
        }
      }
    },
    "/iso-isms-program": {
      "get": {
        "summary": "The ISO 27001 management system records in one read: scope and context, objectives, competence, monitoring, changes, communications, roles, opportunities, improvements, assets, awareness, the document ledger and the internal audit programme. While no programme is saved, audit_programme_starter is the programme to start from: its auditor line is a role sentence and its one planned audit has no date, so the programme can be approved before an auditor is assigned. risk_method.source_gaps names, for each risk method input (scoringScale, reviewFrequency, acceptanceCriteria, acceptanceApprover), the card it is read from as { gap_id, key, stored }, or null when no card holds it; the risk method sheet edits an input by PUT /final-submit-gap-fields on that gap and key, with expected_fields set to the stored value.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "IsoProgramResponse (frontend/types/isoRecords.ts); audit_programme_starter is null once a programme exists"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH (the assessment is SOC 2)"
          },
          "404": {
            "description": "NOT_FOUND"
          }
        }
      },
      "post": {
        "summary": "One action on the management system records (IsoProgramAction in frontend/types/isoRecords.ts). request_internal_audit_quote opens the clause 9.2 engagement at once: a pending audit with no auditor, reading quote_requested, the team notified once; a second request answers the same state and writes nothing. save_audit_programme and approve_audit_programme link the open internal audit of the programme's year to it. save_program returns an approved scope to draft only for a real change to a scope or context field; the operations fields (operational_planning, change_control_summary, outsourced_processes) never do. Operations are approved on their own: approve_document with doc_id iso-operational-planning-and-control, the sixth ledger document, refused with 400 while the planning or the change control text is blank. Every approve_document is kept in the document's approval history (document_approvals carry history, first_approved_at and version). upsert_opportunity and delete_opportunity return an approved scope and context to draft when they add, change or remove an opportunity (reverted_to_draft). confirm_policy_current { area } and confirm_policies_current { areas } record that the person who may approve each policy confirmed it still accurate after its answers or records changed (one audit row per policy, never an approval); a policy the session may not approve is refused by name in refused, a policy that says what the records show is no longer so is refused with POLICY_NOT_CURRENT (400) naming each statement in its refusal's statements (it is redrafted, never confirmed), and a request that confirms nothing answers the first refusal's code with every refusal in error.context.refused. Top management's approvals (FX2-G): approve_risk_method and approve_document for iso-roles-and-authorities are made only from the executive sponsor's account (the roles record's sponsor bound to the company roster, else the sponsor the answers name, else the one account of a founder alone); any other account is refused with 403 SPONSOR_APPROVAL_REQUIRED naming the sponsor in error.context.sponsor, and 409 SPONSOR_NOT_LINKED while no sponsor is named; nothing is written. approve_risk_method is refused with 400 RISK_METHOD_INCOMPLETE (error.context.missing names risk_review_frequency) while the method records no reassessment interval (clause 8.2); an approval made before the interval was recorded reads as not approved until it is entered and the method approved again. record_compensating_measures { entries: [{ conflict, measure, checked_by, frequency }] } records who checks a person whose duties conflict (one entry per conflict the records show, GET segregation), written whole; 400 with context.problems otherwise. The internal audit is priced separately and quoted for the company, so no response carries an amount.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "description": "request_internal_audit_quote, save_audit_programme, approve_audit_programme, save_program, approve_program, approve_document, or any register action listed in IsoProgramAction"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "request_internal_audit_quote with an open audit: { internal_audit: { requested: true, commercial_state } }; a record action: the record as saved"
          },
          "201": {
            "description": "request_internal_audit_quote when this request opened the engagement"
          },
          "400": {
            "description": "VALIDATION_ERROR (the approval refusals carry context.problems)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY (every write) or FRAMEWORK_MISMATCH"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "SURVEILLANCE_UNPAID (a later cycle whose surveillance visit is not paid for), POLICY_NOT_APPROVED, POLICY_NOT_COMMUNICATED, POLICY_VERSION_CHANGED"
          }
        }
      }
    },
    "/iso-proof-review": {
      "get": {
        "summary": "The proof facts of an ISO 27001 workspace: the evidence files with their recorded event day and byte identity, every proof claim and reviewer decision, the control traces (all, or one with control_ref), the current approved policy identities, and the file form: for every file the applicable controls it is attached to (controls_by_file), a suggested starting sentence per control (suggested_claims), the control titles, the per-file cap (max_controls, 6) and the single-record wording. Company members and the assigned auditor read it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "control_ref",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One Annex A control (A.5.1 to A.8.34); without it, every control"
          }
        ],
        "responses": {
          "200": {
            "description": "{ evidence, claims, reviews, traces, policy_identities, control_policy_areas, file_form: { max_controls, single_record_sampling_method, controls_by_file, suggested_claims, control_titles }, viewer: { can_claim, can_review } }"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid ISO 27001 accounts only)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH (the assessment is SOC 2)"
          },
          "404": {
            "description": "NOT_FOUND"
          }
        }
      },
      "post": {
        "summary": "One proof record. claim: a company member describes ONE file for ONE control (what it shows, the locator, the event day, the period, the population and the sample); one append-only iso_proof_claims row with its claim_digest. claim_file: the same, one form per file: the file-level facts once (period_start, period_end, locator, population_description, population_size, sample_size, sampling_method, artifact_kind; event_day defaults to the file's recorded day; single_record true sets population 1, sample 1, 'Entire population (one record)'), and controls, a list of up to 6 { control_ref, claim } the file is attached to; every row is built and validated in full before the first is written and the answer carries one row per control, each with its own digest. A claim left exactly as the suggested sentence is accepted only with confirm_suggested true, which is logged before any row is written. review: the assigned internal auditor records adequate or inadequate for one claim, bound to its claim_digest. Every write is refused for an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessment_id",
                  "action"
                ],
                "properties": {
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "claim",
                      "claim_file",
                      "review"
                    ]
                  },
                  "claim": {
                    "type": "object",
                    "description": "For claim: evidence_id, evidence_sha256, control_ref, policy_content_hash (the current approved policy's hash, or null), event_day, period_start, period_end, claim, locator, population_description, population_size, sample_size, sampling_method, artifact_kind (operating_record, policy, other)"
                  },
                  "claim_file": {
                    "type": "object",
                    "description": "For claim_file: evidence_id, evidence_sha256, period_start, period_end, locator, population_description, artifact_kind, controls [{ control_ref, claim }] (1 to 6), and either single_record true or population_size, sample_size, sampling_method; event_day optional; confirm_suggested true when a sentence is kept as suggested"
                  },
                  "claim_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "For review"
                  },
                  "claim_digest": {
                    "type": "string",
                    "description": "For review: the digest of the claim as displayed"
                  },
                  "decision": {
                    "type": "string",
                    "enum": [
                      "adequate",
                      "inadequate"
                    ],
                    "description": "For review"
                  },
                  "rationale": {
                    "type": "string",
                    "description": "For review: 20 to 4000 characters"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "claim or review: { record }; claim_file: { records, evidence_id, control_refs, confirmed_as_suggested }"
          },
          "400": {
            "description": "VALIDATION_ERROR (claim_file refusals carry context.control_ref, or context.max_controls and context.given over the cap); SUGGESTION_NOT_CONFIRMED (context.control_refs: the sentences left as suggested without the confirm); BEFORE_READINESS_ANSWER (the period starts before the day the readiness assessment answered the control's practice absent or informal; context.control_ref, context.period_start, context.readiness_floor_day, context.readiness_answer; nothing is written; BEFORE_POLICY_APPROVAL (an A.5.36 period starts before the day the first security policy was approved, or no policy is approved yet; context.control_ref, context.period_start, context.policy_floor_day; nothing is written)"
          },
          "401": {
            "description": "AUTH_REQUIRED (also when the session authority changed)"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN (not a company member for a claim, not the assigned auditor for a review), FRAMEWORK_MISMATCH"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "POLICY_NOT_APPROVED (the covering policy is not approved; claim_file names context.control_ref), PROOF_CHANGED (the evidence, the policy or the claim changed; a claim_file refused part way carries context.written, context.failed and context.not_written)"
          }
        }
      }
    },
    "/iso-soa": {
      "get": {
        "summary": "The ISO 27001 Statement of Applicability: all 93 Annex A controls with the decision (applicability, justification, owner), who confirmed each row and when, the implementation status derived from proof, and the live risks linked to each control. `?ref=A.8.5` returns one control with its trace.",
        "description": "Seeds the 93 rows from the catalog and the intake answers on the first read. An impersonated session reads the derived status without writing it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One control reference (A.5.1 to A.8.34)"
          }
        ],
        "responses": {
          "200": {
            "description": "{ soa: [...], counts: { total, confirmed, applicable, excluded }, card_warnings } or, with ref, { control, trace, counts }"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown ref)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH (the assessment is SOC 2)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Decide Statement of Applicability rows. Two bodies: { updates: [{ control_ref, applicability?, justification?, owner_name?, owner_user_id?, confirm? }] } (1 to 93 rows; a change to the applicability or the justification clears a prior confirmation unless the same update confirms; an exclusion needs the company's own reason, never the drafted sentence and never one already written for another control), or { action: 'confirm_suggested_inclusions', control_refs, shown_count }, which confirms the suggested inclusions the screen showed in one step: every ref must be applicable, undecided and carry a reason, else nothing is written. A confirmation (either body) is made only from the executive sponsor's account (FX2-G, clause 6.1.3): any other account may draft a row but is refused 403 SPONSOR_APPROVAL_REQUIRED for a confirmation, with nothing written.",
        "description": "One request stamps one confirmed_at; the package counts the distinct stamps as confirmation steps. The bulk action writes its audit log row first (mode bulk_inclusions, the counts shown and confirmed, the actor, every row before and after), then one guarded update that touches neither source, justification nor applicability; a row that changed meanwhile undoes the step and answers 409. Exclusions are never confirmed in bulk. Impersonated sessions are refused before any read.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "updates"
                    ],
                    "properties": {
                      "updates": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 93,
                        "items": {
                          "type": "object",
                          "required": [
                            "control_ref"
                          ],
                          "properties": {
                            "control_ref": {
                              "type": "string"
                            },
                            "applicability": {
                              "type": "string",
                              "enum": [
                                "applicable",
                                "not_applicable"
                              ]
                            },
                            "justification": {
                              "type": "string"
                            },
                            "owner_name": {
                              "type": "string",
                              "nullable": true
                            },
                            "owner_user_id": {
                              "type": "string",
                              "format": "uuid",
                              "nullable": true
                            },
                            "confirm": {
                              "type": "boolean"
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "control_refs",
                      "shown_count"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "confirm_suggested_inclusions"
                        ]
                      },
                      "control_refs": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 93,
                        "items": {
                          "type": "string"
                        },
                        "description": "The suggested inclusions the screen showed, each once"
                      },
                      "shown_count": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 93,
                        "description": "How many suggested rows the screen showed (at least the refs listed)"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ updated: [...rows], counts: { total, confirmed, applicable, excluded }, audit_queued, audit_queue_reason, card_warnings } (the bulk action adds shown_count, confirmed_count and confirmed_at)"
          },
          "400": {
            "description": "VALIDATION_ERROR (shape; an exclusion without the company's own reason; an unknown action)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "SOA_SUGGESTIONS_CHANGED (context.refs: the suggested rows that are excluded, already confirmed, blank or gone since the screen loaded; nothing written), EXCLUSION_REASON_REPEATED (context.repeated_from), EXCLUSION_CONTRADICTS_SUPPLIERS"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/signed-record": {
      "get": {
        "summary": "The customer's signed records: the audit records management drafts, signs and downloads (access review, offboarding, vendor register, incident log, risk register, management assertion, oversight minutes, and the bridge letter after an issued SOC 2 report). GET lists; every other action is a POST with `action`.",
        "description": "The customer's row is the one the request selects (X-Polara-Framework header or ?framework=; SOC 2 when none is named), for the company owner the token proves; an assessment_id a customer sends is never read. An ISO 27001 assessment reaches exactly one record type, the risk register, seeded from its live risks: list returns only risk_register rows, `types` lists that one type and `bridge_letter` is null; create accepts only that type; every row action reads the stored row's type and refuses any other with 403 FRAMEWORK_MISMATCH. Signing records the document as evidence attached to the open SOC 2 gaps the control model names for the record; an ISO register's signature attaches to no ISO gap. Signatures, exports, receipts and the signer's own name are refused under impersonation before anything is read.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "soc2",
                "iso27001",
                "iso42001"
              ]
            },
            "description": "Which of the caller's own assessments to act on; wins over the X-Polara-Framework header"
          },
          {
            "name": "assessment_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Admins and the assigned auditor only; ignored for customers"
          },
          {
            "name": "readiness_framework",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "gdpr",
                "hipaa",
                "nist_csf",
                "pci_dss"
              ]
            },
            "description": "Names the caller's GDPR, HIPAA, NIST CSF 2.0 or PCI DSS readiness row, whose one record type is the readiness attestation. An unknown value is 400 VALIDATION_ERROR."
          }
        ],
        "responses": {
          "200": {
            "description": "{ records: [...], types: [{ record_type, label, cadence, last_signed_record_id, last_signed_at, next_due_on }], bridge_letter: { available, reason, message, report_reference, bridge_period_start, latest_bridge_period_end } | null }"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown framework selector)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "MIGRATION_PENDING"
          }
        }
      },
      "post": {
        "summary": "One of: create { record_type }, update { record_id, body }, upload_source { record_id, csv_base64, file_name } (access review), sign { record_id, name, title?, expected_updated_at }, receive { record_id } (the assigned auditor, management assertion), pdf { record_id, document?: 'signed'|'receipt' }, source { record_id }, signer, set_signer { name, title }.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "create",
                      "update",
                      "upload_source",
                      "sign",
                      "receive",
                      "pdf",
                      "source",
                      "signer",
                      "set_signer"
                    ]
                  },
                  "record_type": {
                    "type": "string",
                    "enum": [
                      "access_review",
                      "offboarding",
                      "vendor_register",
                      "incident_log",
                      "risk_register",
                      "management_assertion",
                      "oversight_review",
                      "bridge_letter"
                    ]
                  },
                  "record_id": {
                    "type": "string"
                  },
                  "body": {
                    "type": "object"
                  },
                  "name": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "expected_updated_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "readiness_framework": {
                    "type": "string",
                    "enum": [
                      "gdpr",
                      "hipaa",
                      "nist_csf",
                      "pci_dss"
                    ],
                    "description": "Names the caller's GDPR, HIPAA, NIST CSF 2.0 or PCI DSS readiness row, whose one record type is the readiness attestation. An unknown value is 400 VALIDATION_ERROR."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action-specific; sign answers { record, evidence_id, pdf_sha256, gaps_updated: [{ gap_id, question_code, status, closed }] }"
          },
          "201": {
            "description": "create: { record }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH (an ISO 27001 assessment reaches the risk register only), FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "RECORD_SIGNED, RECORD_SUPERSEDED, RECORD_CHANGED, NO_ISSUED_REPORT, BRIDGE_WINDOW_CLOSED, BRIDGED_REPORT_CHANGED, SIGNER_IDENTITY_ON_FILE. Signing a management assertion: SIGNATORY_MISMATCH, SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID, DESCRIPTION_NOT_APPROVED, DESCRIPTION_CHANGED; for Type 1 also AS_OF_INVALID (no as-of date set), AS_OF_BEFORE_FLOOR (error.context.floor), AS_OF_IN_FUTURE; for Type 2 also PERIOD_UNSET (the observation period has no dates) and PERIOD_NOT_ENDED (error.context.period; the period ends after today). A signed Type 1 assertion locks the as-of date. A Type 2 assertion's period is the observation period, written by the server whatever the body sends. On SIGNATORY_MISMATCH, error.context { can_declare, step, kind, named } (phase 78): can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "MIGRATION_PENDING"
          }
        }
      }
    },
    "/assessment-as-of": {
      "get": {
        "summary": "Read the Type 1 as-of date: the date, its floor, the intake's proposal, a suggestion and any lock",
        "description": "Returns data { applies, as_of_date, floor, floor_source, proposed, suggested, locked_by }. The floor is the day the work on file was completed; the date cannot sit before it. locked_by names the signed engagement letter or management assertion that fixes the date, or is null. A Type 2 assessment answers applies: false, because its report uses the observation period. Paid accounts only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessmentId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "As-of state in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Set the Type 1 as-of date",
        "description": "Only the company owner or the named signatory, never an impersonated session. The floor and the lock are computed on the server, never taken from the request. Answers the new as-of state, the same shape as GET.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId",
                  "date"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new as-of state in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR, AS_OF_INVALID (not a calendar date), AS_OF_TOO_FAR_AHEAD (more than 30 days from today)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN (not the owner or the named signatory). On FORBIDDEN, error.context { can_declare, step, kind, named } (phase 78): can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "AS_OF_LOCKED (a signed engagement letter or management assertion fixes the date), AS_OF_BEFORE_FLOOR (error.context.floor is the earliest allowed day), AS_OF_NOT_TYPE1 (a Type 2 assessment)"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/assessment-scope": {
      "get": {
        "summary": "Read the Trust Services Categories of the company's SOC 2 assessment",
        "description": "Any member of the company may read it. Returns the scope, what each category adds, whether the questionnaire is submitted, and whether the scope is locked and why. can_change is true only for the company owner, not impersonated, while the scope is not locked. member_can_act (phase 78) is true for anyone else at the company, not impersonated, while the scope is not locked: they may change it as themselves after the notice.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Which of the caller's own assessments to read; wins over the X-Polara-Framework header. An unknown value is 400 VALIDATION_ERROR"
          }
        ],
        "responses": {
          "200": {
            "description": "{ success: true, data: { assessment_id, scope, categories, submitted, locked, lock_reason, can_change, options: [{ key, name, always_included, in_scope, add_when, covers, counts, question_codes, criteria, policy_names, written_into }], member_can_act } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown framework selector)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED (not a SOC 2 assessment)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      },
      "post": {
        "summary": "Change the Trust Services Categories (the company owner, or an active member as themselves)",
        "description": "Security is always kept; name every category to keep, Security included. A widening is allowed until an engagement letter carries a signature or an audit is requested. A narrowing is allowed before the questionnaire is submitted, or while no gap of a removed category is closed, and it deletes the open gaps of the removed category; when some of them hold work, it needs confirm: true, and confirmed, those gaps and the proof filed under them are deleted. After a widening of a submitted assessment, new_question_codes names the questions to answer. Impersonated sessions are refused. An active member passes the owner check by sending actingAsMember: 'authority-v1' (phase 78), which writes the audit row owner_action_self_declared.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Which of the caller's own assessments to read; wins over the X-Polara-Framework header. An unknown value is 400 VALIDATION_ERROR"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scope"
                ],
                "properties": {
                  "scope": {
                    "oneOf": [
                      {
                        "type": "array",
                        "maxItems": 10,
                        "items": {
                          "type": "string",
                          "maxLength": 60
                        }
                      },
                      {
                        "type": "string",
                        "maxLength": 300
                      }
                    ]
                  },
                  "confirm": {
                    "type": "boolean",
                    "description": "Required to delete open gaps that hold work"
                  },
                  "actingAsMember": {
                    "type": "string",
                    "enum": [
                      "authority-v1"
                    ],
                    "description": "Phase 78. An active member who sends it passes the owner check as themselves, and the audit row owner_action_self_declared is written. Ignored for the owner."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { assessment_id, scope, categories, submitted, locked, lock_reason, can_change, options: [{ key, name, always_included, in_scope, add_when, covers, counts, question_codes, criteria, policy_names, written_into }], changed, added, removed, deleted_gap_count, new_question_codes } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (bad JSON, no category named, or a name that is no category: error.context.unknown)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN (not the owner, and not an active member sending actingAsMember), COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID. On FORBIDDEN, error.context { can_declare, step, kind, named, assessment_id } (phase 78): step is change_scope, kind is 'owner', named is { name } of the company owner, can_declare is true for an active member, never while impersonating; the page then offers to continue as yourself (send actingAsMember: 'authority-v1') or to send the step to the owner (account-signer request_authority_action)."
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED, SCOPE_LOCKED, SCOPE_NARROWING_BLOCKED, SCOPE_NARROW_NEEDS_CONFIRM (error.context.categories, one { key, open, with_work } per removed category), SCOPE_CHANGED (the scope moved since it was read; reload). error.context also carries scope, requested, lock_reason and closed_gap_count on a refused plan."
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      }
    },
    "/system-description-approval": {
      "get": {
        "summary": "Read the system description (Section 3) as it renders now, with its hash and approval",
        "description": "Returns data { applies, html, sha256, matters, approval, state }. html is Section 3 as the report would print it today, sha256 its hash, matters what the management assertion is made except for, approval the stored approval, and state whether that approval still covers the current text. applies is true for every assessment: a Type 2 assertion is signed over the approved description too. A Type 2 assessment whose report cannot render yet answers html null with state not_ready. Paid accounts only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessmentId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The description and its approval state in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "The named signatory approves the system description they read",
        "description": "Send the sha256 from GET. The hash is recomputed on the server; if the text changed since it was read, the approval is refused. The approval records the signatory's name from their account, never from the request. A Type 1 management assertion cannot be signed until the current description is approved.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId",
                  "action",
                  "sha256"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "approve"
                    ]
                  },
                  "sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "data.approval { sha256, as_of_date, approved_at, approved_by_user_id, approved_by_name } in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "DESCRIPTION_CHANGED (read it again and approve), SIGNATORY_MISMATCH, SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID (error.context.signer). On SIGNATORY_MISMATCH, error.context { can_declare, step, kind, named } (phase 78): can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/rep-letter": {
      "get": {
        "summary": "Read the management representation letter for the current audit",
        "description": "Returns the live letter of the audit the assessment's assignment names, or null when none has been issued. Customers read their own company's letter; the assigned auditor and admins read any letter on an assignment they hold. Impersonated sessions are refused on every method, reads included. A SOC 2 assessment only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "audit_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Optional; names the audit when the assessment has more than one"
          }
        ],
        "responses": {
          "200": {
            "description": "{ success: true, data: { letter, audit_id } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (assessment_id is missing)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH (not a SOC 2 assessment), FORBIDDEN (no access to the assessment, or no assignment for it)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "AMBIGUOUS_ASSIGNMENT (more than one audit; send audit_id)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "NOT_AVAILABLE (representation letters are not available in this environment), COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      },
      "post": {
        "summary": "One of: get, generate (the service auditor), sign (the company's named signatory), receive (the service auditor), review (the assigned practitioner)",
        "description": "get answers the same as GET. generate builds the letter from the report's own record and answers data { letter }; only an auditor or admin may generate. It emails the named signatory, with the company's members on cc, that the letter must be signed before midnight UTC at the end of its practitioner report date. sign, receive and review need the letter_id and report_context_sha256 of the letter as read, and are refused if it changed since. sign records the signature of the company's named signatory, typed exactly as the name on their account, and answers data { letter } (data { letter, already_signed: true } when it is already signed); a new signature emails the assigned auditor. A signature refused because the letter's day has passed answers REPRESENTATION_REFRESH_REQUIRED with a message written for the signer. receive records the auditor's receipt of the signed letter; a caller-supplied uploaded_pdf_s3_key or sha256 is refused. review records the assigned practitioner's personal review with their account name and a note of 20 to 4000 characters. Impersonated sessions are refused before anything is read.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "assessment_id"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "get"
                      },
                      "assessment_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "audit_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Optional; names the audit when the assessment has more than one"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "assessment_id"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "generate"
                      },
                      "assessment_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "audit_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Optional; names the audit when the assessment has more than one"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "assessment_id",
                      "letter_id",
                      "report_context_sha256",
                      "signature_name"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "sign"
                      },
                      "assessment_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "audit_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Optional; names the audit when the assessment has more than one"
                      },
                      "letter_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "report_context_sha256": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "signature_name": {
                        "type": "string",
                        "description": "Must match the name on the signer's account"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "assessment_id",
                      "letter_id",
                      "report_context_sha256"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "receive"
                      },
                      "assessment_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "audit_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Optional; names the audit when the assessment has more than one"
                      },
                      "letter_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "report_context_sha256": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "assessment_id",
                      "letter_id",
                      "report_context_sha256",
                      "signature_name",
                      "review_note"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "review"
                      },
                      "assessment_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "audit_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Optional; names the audit when the assessment has more than one"
                      },
                      "letter_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "report_context_sha256": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "signature_name": {
                        "type": "string"
                      },
                      "review_note": {
                        "type": "string",
                        "minLength": 20,
                        "maxLength": 4000
                      }
                    }
                  }
                ],
                "discriminator": {
                  "propertyName": "action"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { letter } } (get also carries audit_id; a repeated sign carries already_signed: true)"
          },
          "400": {
            "description": "VALIDATION_ERROR (assessment_id missing, an unknown action, letter_id or report_context_sha256 missing, the typed name does not match the account, or a review note outside 20 to 4000 characters)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH, FORBIDDEN (no access; generate and receive: not an auditor or admin; sign: an auditor or admin without access to the company; review: not the assigned practitioner; no assignment; the write found no current personal authority)"
          },
          "404": {
            "description": "NOT_FOUND (the assessment; sign and receive: no letter has been issued yet)"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "AMBIGUOUS_ASSIGNMENT. generate: COMPANY_NAME_REQUIRED, QUESTIONNAIRE_REQUIRED, OBSERVATION_PERIOD_REQUIRED, SIGNATORY_REQUIRED, FIRM_REQUIRED (error.context.missing), CONFLICT (the current context already has a signed letter). Any write: REPRESENTATION_REFRESH_REQUIRED (the letter read is no longer current), REPRESENTATION_CONTEXT_CHANGED, OPINION_INCOMPLETE, REPRESENTATION_DATE_INVALID, REPRESENTATIONS_MISSING, REPRESENTATION_REVIEW_REQUIRED, REPRESENTATION_ISSUED_IMMUTABLE, REPRESENTATION_SIGNATURE_INVALID. sign: SIGNATORY_MISMATCH, SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID (error.context.signer). review: SIGNER_IDENTITY_REQUIRED. On SIGNATORY_MISMATCH, error.context { can_declare, step, kind, named } (phase 78): kind is 'signatory', named is { name, title } of the named signatory, can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "NOT_AVAILABLE, REPRESENTATION_CONTEXT_UNAVAILABLE (the report inputs could not be verified or the write could not be confirmed), COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      }
    },
    "/engagement-letter-sign": {
      "post": {
        "summary": "Sign your side of an engagement letter",
        "description": "The side is read from the caller's role: the assigned auditor signs the auditor side, someone at the customer company signs the customer side, and an admin signs the auditor side only. The customer signs after the auditor. signature_name must match the name on the signer's account, case and spacing ignored. On a Type 1 assessment the customer side is signed only by the company's named signatory, and that signature locks the as-of date unless a signed management assertion already holds it. A side already signed answers 200 with already_signed: true and changes nothing. Impersonated sessions are refused before anything is read.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "engagement_letter_id",
                  "signature_name"
                ],
                "properties": {
                  "engagement_letter_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "signature_name": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { engagement_letter_id, status, side, already_signed: false } }, or { engagement_letter_id, status, already_signed: true } when that side is already signed"
          },
          "400": {
            "description": "VALIDATION_ERROR (engagement_letter_id or signature_name missing, or the typed name does not match the account)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, ADMIN_CANNOT_SIGN_FOR_CUSTOMER (the auditor side is already signed), FORBIDDEN (not the assigned auditor, or not the customer on the letter), COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID"
          },
          "404": {
            "description": "NOT_FOUND (the letter or its assessment)"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "CONFLICT (the letter is voided, the auditor has not signed yet, or the as-of date lock changed while signing; try again), SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID (error.context.signer). Type 1 customer side: SIGNATORY_MISMATCH, whose error.context also carries signer. On SIGNATORY_MISMATCH, error.context { can_declare, step, kind, named } (phase 78): kind is 'signatory', named is { name, title } of the named signatory, can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      }
    },
    "/management-exception-response": {
      "get": {
        "summary": "Read the exceptions the service auditor recorded on the current engagement, with management's responses",
        "description": "Returns data { assignment_id, audit_id, issued, can_respond, refusal, exceptions }. exceptions lists each completed exception with the auditor's words and the latest response given to it as it now reads; a response given to an earlier version is returned in earlier_responses flagged given_to_previous_version. can_respond is true only for the company's named signatory while the report is not issued. refusal says why not: { code, message, context? } with code READ_ONLY (an auditor, an admin or an impersonated session), SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID or SIGNATORY_MISMATCH. On a SIGNATORY_MISMATCH refusal, refusal.context { can_declare, step, kind, named } (phase 78) is the same as on the POST refusal. A customer with no assignment yet gets { exceptions: [], can_respond: false, refusal: null }. A SOC 2 assessment only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "audit_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Optional; names the audit when the assessment has more than one"
          }
        ],
        "responses": {
          "200": {
            "description": "{ success: true, data: { assignment_id, audit_id, issued, can_respond, refusal, exceptions: [{ conclusion_id, control_ref, exception_text, exception_evaluation, concluded_at, response, earlier_responses }] } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (assessment_id is missing)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "FRAMEWORK_MISMATCH, FORBIDDEN (no access to the assessment; an auditor or admin with no assignment), COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "AMBIGUOUS_ASSIGNMENT (more than one audit; send audit_id)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      },
      "post": {
        "summary": "The company's named signatory records management's response to an exception",
        "description": "The words are response_text, stored as typed; a response that repeats the auditor's words is refused. Who responded and when come from the signed-in account and the database clock, never from the request, so responded_by, responder_name, responder_title, responded_at, created_at and id are refused if sent. concluded_at is the exception's concluded_at as read; a response to an exception the auditor changed since is refused. Responses are append-only, and none can be added once the report is issued. Impersonated sessions, auditors and admins are refused before the body is read.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessment_id",
                  "control_ref",
                  "concluded_at",
                  "response_text"
                ],
                "properties": {
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "audit_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "control_ref": {
                    "type": "string",
                    "minLength": 1
                  },
                  "concluded_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "response_text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { response } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (bad JSON, a missing field, an attribution field sent, or a response over 4000 characters), RESPONSE_COPIES_AUDITOR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH, FORBIDDEN (an auditor or admin, no access to the assessment, or no assignment), COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID"
          },
          "404": {
            "description": "NOT_FOUND, EXCEPTION_NOT_FOUND (no completed exception for that control)"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "REPORT_ISSUED, RESPONSE_REFRESH_REQUIRED (the auditor changed the exception; read it again), RESPONSE_CONFLICT, AMBIGUOUS_ASSIGNMENT, SIGNATORY_MISMATCH, SIGNER_IDENTITY_REQUIRED, SIGNER_IDENTITY_INVALID (error.context.signer). On SIGNATORY_MISMATCH, error.context { can_declare, step, kind, named } (phase 78): kind is 'signatory', named is { name, title } of the named signatory, can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "NOT_AVAILABLE (responses are not available in this environment), COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      }
    },
    "/truth-review-acknowledge": {
      "post": {
        "summary": "Acknowledge the completion review that reopened items on the account",
        "description": "Sets truth_review.acknowledged_at once for a member with access to the assessment, so the dashboard banner stops showing. Idempotent: a second call keeps the first timestamp. Returns the review record, or null when the assessment has none. Never from an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The truth review record (or null) in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/fix-list-item-done": {
      "post": {
        "summary": "Tick one item on the fix list Polara's internal review returned",
        "description": "Stamps done_at and done_by on one item of the current build's fix list, for any active member of the company. Idempotent: a second tick keeps the first time and person and writes nothing. The tick is the customer's own word: it changes no gap and no gate, and the review of the next build decides. Returns the fix list and whether every item is now ticked. Never from an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId",
                  "itemId"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "itemId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ fix_list, completed } in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND (no such assessment, no fix list, or no such item)"
          },
          "409": {
            "description": "PACKAGE_REBUILT (the list belongs to an older build)"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "FIX_LIST_UNAVAILABLE"
          }
        }
      }
    },
    "/partner-requests": {
      "get": {
        "summary": "The caller's company's partner requests, newest first",
        "description": "Every request the company has asked Polara to arrange through the Polara Preferred Pricing Network (PPPN) or from Polara itself, for any member of the company (requests belong to the company owner). Each request carries id, type, status (requested, quoted, accepted, declined or closed), details, quote_cents and quote_note once quoted, requested_by_email, created_at, quoted_at and closed_at. Allowed for an impersonated session, which reads and writes nothing. No payment is required.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "{ requests: PartnerRequest[] }"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "The caller is not a member of the company"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Ask Polara to arrange a penetration test, a certification body, an AIUC-1 auditor, legal review, a Mission quote, an integration or a person on a sales call",
        "description": "Records one request for the company and notifies the team at once. One open request per type per company: when a request of that type is already open (requested, quoted or accepted), it returns that request with created false and records nothing new. Five requests an hour per person. No payment is required, and the response carries no gap detail and nothing AI-generated. Refused for an impersonated session, because a request records who asked.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "pentest",
                      "cert_body",
                      "aiuc_auditor",
                      "legal",
                      "mission_quote",
                      "integration_priority",
                      "sales_call"
                    ]
                  },
                  "details": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 2000,
                    "description": "Optional context for the request"
                  },
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional. The company's own assessment the request is about; defaults to the company's active SOC 2 assessment"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ request, created: false }: a request of this type is already open, and it is returned unchanged"
          },
          "201": {
            "description": "{ request, created: true }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND (the assessment_id is not the company's)"
          },
          "409": {
            "description": "CONFLICT (the open request changed during the call; ask again)"
          },
          "429": {
            "description": "RATE_LIMITED (five requests an hour per person)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/dress-rehearsal": {
      "get": {
        "summary": "The latest Dress Rehearsal for the caller's company: the mock audit that walks every control the CPA firm will test before it looks",
        "description": "Returns { rehearsal, package_built, required, pre_audit_request }. rehearsal is null before the first run; otherwise it carries id, status, walk, sample, findings, as_of, passed_at, created_at and updated_at. required is true when the rehearsal is the step before the auditor for this assessment. The rehearsal is practice, not a verdict: passing it promises nothing about the report. Paid accounts only. Allowed for an impersonated session, which writes nothing.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "soc2",
                "iso27001"
              ]
            },
            "description": "Which of the company's assessments to use; defaults to the active one"
          }
        ],
        "responses": {
          "200": {
            "description": "{ rehearsal, package_built, required, pre_audit_request }"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown framework)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Start a Dress Rehearsal, or confirm one sampled item",
        "description": "action start walks every control, draws the sample and lists the findings as a new rehearsal (a re-run is a new rehearsal; the latest is the state), once the report package is built; ten starts an hour per person. action confirm records one person's answer for one sampled item (accurate or needs_update) with a compare-and-set on expected_updated_at, which must be the rehearsal's current updated_at. Findings live on the rehearsal only and never change the gap plan. Paid accounts only. Refused for an impersonated session, because a confirmation is a named person's statement.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "soc2",
                "iso27001"
              ]
            },
            "description": "Which of the company's assessments to use; defaults to the active one"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "start"
                        ]
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "rehearsal_id",
                      "item_key",
                      "confirmation",
                      "expected_updated_at"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "confirm"
                        ]
                      },
                      "rehearsal_id": {
                        "type": "string"
                      },
                      "item_key": {
                        "type": "string"
                      },
                      "confirmation": {
                        "type": "string",
                        "enum": [
                          "accurate",
                          "needs_update"
                        ]
                      },
                      "expected_updated_at": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ rehearsal } after a confirmation"
          },
          "201": {
            "description": "{ rehearsal } after a start"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND (assessment, rehearsal or sampled item)"
          },
          "409": {
            "description": "CONFLICT (the rehearsal changed since expected_updated_at; reload and try again), PACKAGE_NOT_BUILT, REHEARSAL_PASSED"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/questionnaire-draft": {
      "get": {
        "summary": "Security questionnaire drafts: the list, one draft, or one draft's CSV export",
        "description": "Without id: { drafts, sources }, every draft of the company and the approved policies and system description answers are drafted from. With id: { draft }, the status poll while a draft is being written. With id and format=csv: a text/csv download, once every answered item is confirmed (409 CONFIRMATION_REQUIRED otherwise); the export records that the draft was exported, so it is refused for an impersonated session. Each answer cites the excerpts it was drafted from. Paid accounts only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "csv"
              ]
            },
            "description": "With id, returns the draft as CSV"
          }
        ],
        "responses": {
          "200": {
            "description": "{ drafts, sources }, { draft }, or the CSV file"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY (CSV export only)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "DRAFT_NOT_READY, CONFIRMATION_REQUIRED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Create, retry, confirm or save a security questionnaire draft",
        "description": "action create takes the questions a prospect sent (1 to 200, each up to 1,000 characters) and an optional title, and answers 202 with the draft while the answers are drafted in the background from the company's approved policies and system description only (409 NO_SOURCES while there are none). action retry restarts a draft that did not finish. Create and retry together are limited to three an hour per person. action confirm records that a person stands behind one answer; action save replaces one answer (up to 4,000 characters). Confirm and save are a compare-and-set on expected_updated_at, the draft's current updated_at. There is no confirm-all. Paid accounts only. Refused for an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "questions"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "create"
                        ]
                      },
                      "title": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 200
                      },
                      "questions": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 200,
                        "items": {
                          "type": "string",
                          "maxLength": 1000
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "id"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "retry"
                        ]
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "id",
                      "index",
                      "expected_updated_at"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "confirm"
                        ]
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 199
                      },
                      "expected_updated_at": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "id",
                      "index",
                      "answer",
                      "expected_updated_at"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "enum": [
                          "save"
                        ]
                      },
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 199
                      },
                      "answer": {
                        "type": "string",
                        "maxLength": 4000
                      },
                      "expected_updated_at": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ draft } after confirm or save"
          },
          "202": {
            "description": "{ draft } after create or retry, while the answers are drafted"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "CONFLICT (the draft changed since expected_updated_at), NO_SOURCES, DRAFT_NOT_READY, DRAFT_NOT_FAILED"
          },
          "429": {
            "description": "RATE_LIMITED (three drafts an hour per person)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE (the draft could not be started)"
          }
        }
      }
    },
    "/readiness-assessment": {
      "get": {
        "summary": "A GDPR, HIPAA Security Rule, NIST CSF 2.0 or PCI DSS readiness assessment: the delta questions, the caller's answers and the results",
        "description": "Computed on every read from the caller's readiness row, which is created by start-framework after a submitted SOC 2 assessment. An uncovered caller gets exactly { framework, covered: false, submitted, teaser, questions, answers, delta }: the teaser is the score, tier, categories, at most three example gaps, locked counts and the SOC 2 carry-over. For PCI DSS the teaser also carries applicability: { value, reason, flags, applies, excluded }, the Self-Assessment Questionnaire (SAQ) pick (A, A-EP or D), its reason key, the level1, serviceProvider and otherChannels flags, and how many requirements are in and out of that SAQ; no requirement list. A covered caller (an Orbit or Constellation plan) also gets { evaluation, carry_over, deliverables, records, attestation } in place of the teaser. No model is called. Rate limited to 120 requests an hour per person across GET, PUT and POST.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "gdpr",
                "hipaa",
                "nist_csf",
                "pci_dss"
              ]
            },
            "description": "The readiness framework; chooses between the caller's own rows only. An unknown value is 409 FRAMEWORK_UNSUPPORTED."
          }
        ],
        "responses": {
          "200": {
            "description": "{ framework, covered, submitted, teaser, questions, answers, delta } when uncovered; covered adds evaluation, carry_over, deliverables, records, attestation"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "404": {
            "description": "NOT_FOUND (Start this framework first)"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "put": {
        "summary": "Save delta answers, or one readiness record",
        "description": "The body carries exactly one of answers (any caller), ropa, dpia, art28 (GDPR), risk_analysis (HIPAA), csf_profile or csf_tiers (NIST CSF 2.0) or pci_evidence (PCI DSS); the records need a covered caller and answer 402 otherwise. Records are validated with size caps and stamped with who saved them and when. Answers the GET shape. Refused for an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "gdpr",
                "hipaa",
                "nist_csf",
                "pci_dss"
              ]
            },
            "description": "The readiness framework; chooses between the caller's own rows only. An unknown value is 409 FRAMEWORK_UNSUPPORTED."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Exactly one of the properties",
                "properties": {
                  "answers": {
                    "type": "object",
                    "description": "Delta answers keyed by question code"
                  },
                  "ropa": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    },
                    "description": "Records of processing rows, at most 200, 500 characters a field"
                  },
                  "dpia": {
                    "type": "object",
                    "description": "The data protection impact assessment sections"
                  },
                  "art28": {
                    "type": "object",
                    "properties": {
                      "item": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string"
                      }
                    },
                    "description": "One Article 28 checklist item"
                  },
                  "risk_analysis": {
                    "type": "object",
                    "properties": {
                      "rows": {
                        "type": "object"
                      }
                    },
                    "description": "Likelihood and impact per risk area"
                  },
                  "csf_profile": {
                    "type": "object",
                    "properties": {
                      "rows": {
                        "type": "object",
                        "description": "Keyed by Subcategory ID: { current, target, note? }, each level one of not_in_place, partly_in_place, in_place, not_a_priority; note at most 500 characters"
                      }
                    },
                    "description": "The Current and Target Profile, saved whole, at most 120 rows a save"
                  },
                  "csf_tiers": {
                    "type": "object",
                    "properties": {
                      "governance": {
                        "type": "object",
                        "description": "{ current, target, rationale }: tiers 1 to 4 or null, rationale at most 1000 characters"
                      },
                      "management": {
                        "type": "object",
                        "description": "{ current, target, rationale }: tiers 1 to 4 or null, rationale at most 1000 characters"
                      }
                    },
                    "description": "The tier self-assessment for cybersecurity risk governance and risk management"
                  },
                  "pci_evidence": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "requirement"
                    ],
                    "properties": {
                      "requirement": {
                        "type": "string",
                        "maxLength": 32,
                        "description": "A PCI DSS requirement ID. To link evidence it must be in the caller's SAQ, picked from the row's stored answers (400 otherwise); removal works for any requirement of the module"
                      },
                      "source": {
                        "type": "string",
                        "enum": [
                          "polara",
                          "url"
                        ],
                        "description": "polara links a file from the caller's own SOC 2 evidence (evidence_id); url links an https address (url)"
                      },
                      "evidence_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "With source polara: a soc2_evidence row of the caller's SOC 2 assessment, read on the server; the stored label is the server's file name"
                      },
                      "url": {
                        "type": "string",
                        "maxLength": 2048,
                        "description": "With source url: an https link (any other scheme is 400)"
                      },
                      "note": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "remove": {
                        "type": "boolean",
                        "enum": [
                          true
                        ],
                        "description": "{ requirement, remove: true } takes the link off that requirement"
                      }
                    },
                    "description": "One evidence link for one PCI DSS requirement: { requirement, source, evidence_id | url, note? } or { requirement, remove: true }"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The GET shape for the caller"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (records only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED, SAVE_CONFLICT"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Submit the readiness questions",
        "description": "Send an empty object. Stamps the submit time and the submitter, then answers the GET shape. Refused for an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "gdpr",
                "hipaa",
                "nist_csf",
                "pci_dss"
              ]
            },
            "description": "The readiness framework; chooses between the caller's own rows only. An unknown value is 409 FRAMEWORK_UNSUPPORTED."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The GET shape for the caller"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED, SAVE_CONFLICT"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/readiness-binder-pdf": {
      "get": {
        "summary": "The readiness binder as one PDF",
        "description": "Requirements, records, approved policies and the signed attestation for a GDPR, HIPAA Security Rule, NIST CSF 2.0 or PCI DSS readiness assessment. Covered callers only (402 otherwise, nothing is rendered). The binder states that it is not a certification. Allowed for an impersonated session (a read). Limited to 10 an hour per person.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "gdpr",
                "hipaa",
                "nist_csf",
                "pci_dss"
              ]
            },
            "description": "The readiness framework; chooses between the caller's own rows only. An unknown value is 409 FRAMEWORK_UNSUPPORTED."
          }
        ],
        "responses": {
          "200": {
            "description": "{ filename, downloadUrl?, pdfBase64? }"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "404": {
            "description": "NOT_FOUND (Start this framework first)"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/readiness-policy": {
      "get": {
        "summary": "Readiness policy areas and their state",
        "description": "Without area: { framework, covered, areas }. With area: { framework, covered, area }, the status poll while a draft is written. Policy text is returned to covered callers only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "framework",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "gdpr",
                "hipaa",
                "nist_csf",
                "pci_dss"
              ]
            },
            "description": "The readiness framework; chooses between the caller's own rows only. An unknown value is 409 FRAMEWORK_UNSUPPORTED."
          },
          {
            "name": "area",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One policy area id of the framework"
          }
        ],
        "responses": {
          "200": {
            "description": "{ framework, covered, areas } or { framework, covered, area }"
          },
          "400": {
            "description": "VALIDATION_ERROR (unknown area)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Draft or approve one readiness policy",
        "description": "action draft starts drafting one area in the background and answers 202; draft starts are limited to 10 an hour per person, and an approved area is not drafted again. action approve records who approved the drafted text and when, using the account's full name and job title (409 SIGNER_IDENTITY_REQUIRED if either is missing). Covered callers only (402 otherwise). Refused for an impersonated session.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "framework",
                  "action",
                  "area"
                ],
                "properties": {
                  "framework": {
                    "type": "string",
                    "enum": [
                      "gdpr",
                      "hipaa",
                      "nist_csf",
                      "pci_dss"
                    ]
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "draft",
                      "approve"
                    ]
                  },
                  "area": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "approve: { framework, covered, area }"
          },
          "202": {
            "description": "draft: { framework, covered, area }, drafting"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "FRAMEWORK_UNSUPPORTED, DRAFT_IN_PROGRESS, POLICY_APPROVED, POLICY_NOT_DRAFTED, SIGNER_IDENTITY_REQUIRED, CONFLICT"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "AI_UNAVAILABLE"
          }
        }
      }
    },
    "/get-trust-page": {
      "get": {
        "summary": "A company's published trust page (public, rate limited)",
        "description": "No account needed. Returns the published trust page for a slug: company_name, slug, logo_url (a presigned URL valid for 15 minutes, or null), records_live, hero { lede }, frameworks[] (id soc2, iso27001 or iso42001, label, kind, state issued, progress or building, status_line, about, monitored, reports[] { label, document_key, verify_ref, requestable }, controls_line), controls[] (framework_id, label, heading, count_line, intro, in_place, total, groups[] { name, count_line, rows[] { key, name, ref, criteria, state in_place, in_progress or not_started, status_word } }), subprocessors[] { vendor, service } (empty unless the company publishes them), documents[] { key soc2_type2 or soc2_type1, label }, policies (names) and contact_email. A draft, unpaid or unknown page is a 404. 300 requests an hour per client. Cache-Control: public, max-age=60, must-revalidate.",
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "required": true,
            "description": "The trust page slug: lowercase letters, digits and hyphens, 1 to 48 characters, starting and ending with a letter or digit.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]([a-z0-9-]{0,46}[a-z0-9])?$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ success: true, data: TrustPage } as described above"
          },
          "404": {
            "description": "NOT_FOUND: bad slug, or no published page for it"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/trust-badge": {
      "get": {
        "summary": "The SVG trust badge for a published trust page (public, rate limited)",
        "description": "No account needed. Answers a 220 by 64 SVG image (Content-Type image/svg+xml), not a JSON envelope, for embedding on the company's own site. theme is dark or light; anything else falls back to dark. A draft, unpaid or unknown page is a 404 in the JSON error envelope. 600 requests an hour per client. Cache-Control: public, max-age=60, must-revalidate, so a withdrawn report leaves the badge within a minute.",
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "required": true,
            "description": "The trust page slug: lowercase letters, digits and hyphens, 1 to 48 characters, starting and ending with a letter or digit.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]([a-z0-9-]{0,46}[a-z0-9])?$"
            }
          },
          {
            "name": "theme",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "dark",
                "light"
              ],
              "default": "dark"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The badge",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/trust-document-request": {
      "post": {
        "summary": "Request a company's SOC 2 report from its trust page, then confirm the request by email (public, rate limited)",
        "description": "No account needed. Two actions on one endpoint. action request records a request for one document on a published trust page and emails the requester a confirmation link that is valid for 24 hours; it answers { status: check_email }. action confirm takes the token from that link and marks the request confirmed, after which the company owner is told and decides; it answers { status: confirmed }. The owner's decision is made in the account, and an approved request is emailed a download link (see trust-document-download). Rate limits: request, 5 an hour per client and 3 a day per email address; confirm, 20 an hour per client. Every attempt counts, including ones that find no page. Answers 503 UNAVAILABLE while trust records are switched off.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "slug",
                      "document_key",
                      "name",
                      "email",
                      "company",
                      "confidentiality_ack"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "request"
                      },
                      "slug": {
                        "type": "string",
                        "pattern": "^[a-z0-9]([a-z0-9-]{0,46}[a-z0-9])?$"
                      },
                      "document_key": {
                        "type": "string",
                        "enum": [
                          "soc2_type2",
                          "soc2_type1"
                        ]
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      "email": {
                        "type": "string",
                        "format": "email",
                        "maxLength": 254
                      },
                      "company": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      "reason": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 500
                      },
                      "confidentiality_ack": {
                        "type": "boolean",
                        "const": true,
                        "description": "The requester agrees to keep the document confidential."
                      },
                      "website": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 200,
                        "description": "Leave empty. A filled value is accepted and silently dropped."
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "token"
                    ],
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "confirm"
                      },
                      "token": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 2048
                      }
                    }
                  }
                ],
                "discriminator": {
                  "propertyName": "action"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ status: check_email } for request, { status: confirmed } for confirm"
          },
          "400": {
            "description": "VALIDATION_ERROR: bad JSON, an unknown action or a field that fails its rule"
          },
          "404": {
            "description": "NOT_FOUND: no published page, or no document that can be requested"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "410": {
            "description": "LINK_INVALID: the confirmation link is malformed, expired or already used"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "UNAVAILABLE: trust records are switched off"
          }
        }
      }
    },
    "/trust-document-download": {
      "get": {
        "summary": "The download page for an approved trust document request (public)",
        "description": "Opened from the link in the approval email. Answers an HTML page (Content-Type text/html, Cache-Control no-store, X-Robots-Tag noindex), never JSON, and never spends a download: 200 with a Download the report button that POSTs the token back, 410 when the link no longer works, 429 when rate limited (120 an hour per client). The link is valid for 7 days and for 10 downloads.",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "description": "The signed token from the approval email.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "HTML page with the download form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "410": {
            "description": "HTML page: the link no longer works"
          },
          "429": {
            "description": "HTML page: too many tries"
          },
          "500": {
            "description": "HTML page: the link could not be opened"
          }
        }
      },
      "post": {
        "summary": "Spend one download of an approved trust document (public)",
        "description": "Takes token as a form field (application/x-www-form-urlencoded, as the download page sends it) or as JSON { token }. Every outcome is a 302 with an empty body and Cache-Control no-store: on success to a presigned PDF URL valid for 15 minutes, with the download counted; when the request is no longer eligible to the company's trust page with document=expired; otherwise to the site root. 30 an hour per client.",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "302": {
            "description": "Location is the presigned PDF URL, the trust page with document=expired, or the site root"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED (JSON)"
          }
        }
      }
    },
    "/manage-trust-page": {
      "get": {
        "summary": "Read the company's trust page settings, its preview and its document requests",
        "description": "Any member of the company may read it. preview is the same payload the public trust page serves. can_edit is true for the owner, not impersonated. member_can_act (phase 78) is true for an active member, not impersonated: they may change the page as themselves after the notice. requests lists confirmed document requests only for those two, and only while trust records are switched on. A company with no eligible assessment answers eligible: false with page null and reason.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "{ success: true, data: { page: { slug, status, contact_email, show_policies, published_at, published_subprocessors } | null, suggested_slug, public_url, preview, can_edit, member_can_act, impersonated, eligible, reason, records_live, requests, vendors, badge, search_listing } }"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID"
          },
          "404": {
            "description": "NOT_FOUND (no assessment)"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "UNAVAILABLE (trust pages are not switched on yet), COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      },
      "post": {
        "summary": "Save or publish the trust page (the company owner, or an active member as themselves)",
        "description": "Every field is optional; one left out keeps its saved value. publish true publishes the page and false returns it to a draft. Publishing is refused until the caller's email address is verified; drafts and unpublishing never are. published_subprocessors is read only while trust records are switched on, and a name not in the current vendor register is dropped. Answers the same view as GET. Impersonated sessions are refused before anything is read. An active member passes the owner check by sending actingAsMember: 'authority-v1' (phase 78), which writes the audit row owner_action_self_declared.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "slug": {
                    "type": "string"
                  },
                  "contact_email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "email"
                  },
                  "show_policies": {
                    "type": "boolean"
                  },
                  "publish": {
                    "type": "boolean"
                  },
                  "published_subprocessors": {
                    "type": "array",
                    "maxItems": 200,
                    "items": {
                      "type": "string"
                    }
                  },
                  "actingAsMember": {
                    "type": "string",
                    "enum": [
                      "authority-v1"
                    ],
                    "description": "Phase 78. An active member who sends it passes the owner check as themselves, and the audit row owner_action_self_declared is written. Ignored for the owner."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { page: { slug, status, contact_email, show_policies, published_at, published_subprocessors } | null, suggested_slug, public_url, preview, can_edit, member_can_act, impersonated, eligible, reason, records_live, requests, vendors, badge, search_listing } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (bad JSON, or a field that fails its rule: error.context.field is slug, contact_email or published_subprocessors)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (no assessment that can have a trust page)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, OWNER_ONLY (not the owner, and not an active member sending actingAsMember), EMAIL_NOT_VERIFIED (publishing before the caller's address is verified), COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID. On OWNER_ONLY, error.context { can_declare, step, kind, named, assessment_id } (phase 78): step is trust_page, kind is 'owner', named is { name } of the company owner, can_declare is true for an active member, never while impersonating; the page then offers to continue as yourself (send actingAsMember: 'authority-v1') or to send the step to the owner (account-signer request_authority_action)."
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "SLUG_TAKEN (error.context.field is slug)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "UNAVAILABLE, COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      }
    },
    "/trust-document-decision": {
      "post": {
        "summary": "Approve, deny or revoke a document request on the company's trust page (the company owner, or an active member as themselves)",
        "description": "Only a request on the caller's own trust page. approve and deny need a pending request, revoke an approved one. approve pins the report being approved and emails the requester a download link valid for 7 days; deny emails a short note; revoke sends nothing and stops the emailed link at once. If the email fails, the decision is undone and the answer is 502. Impersonated sessions are refused before anything is read. An active member passes the owner check by sending actingAsMember: 'authority-v1' (phase 78), which writes the audit row owner_action_self_declared. Answers 503 UNAVAILABLE while trust records are switched off, before the session is checked.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "request_id",
                  "decision"
                ],
                "properties": {
                  "request_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "decision": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "deny",
                      "revoke"
                    ]
                  },
                  "actingAsMember": {
                    "type": "string",
                    "enum": [
                      "authority-v1"
                    ],
                    "description": "Phase 78. An active member who sends it passes the owner check as themselves, and the audit row owner_action_self_declared is written. Ignored for the owner."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { request: { id, requester_name, requester_email, requester_company, reason, document_label, status, verified_at, decided_at, download_count } } }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, OWNER_ONLY (not the owner, and not an active member sending actingAsMember), COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING, COMPANY_ACCESS_INVALID. On OWNER_ONLY, error.context { can_declare, step, kind, named, assessment_id } (phase 78): step is trust_document, kind is 'owner', named is { name } of the company owner, can_declare is true for an active member, never while impersonating; the page then offers to continue as yourself (send actingAsMember: 'authority-v1') or to send the step to the owner (account-signer request_authority_action)."
          },
          "404": {
            "description": "NOT_FOUND (no trust page, or no such request on it)"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "ALREADY_DECIDED, NOT_REVOCABLE (only an approved request can be revoked), DOCUMENT_UNAVAILABLE (the report is no longer available to share)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "502": {
            "description": "EMAIL_FAILED (nothing was decided; if the undo also failed, the message says to revoke the approval)"
          },
          "503": {
            "description": "UNAVAILABLE (trust records are switched off), COMPANY_ACCESS_UNAVAILABLE"
          }
        }
      }
    },
    "/connector-availability": {
      "get": {
        "summary": "Which evidence connectors can be connected right now (public)",
        "description": "No account needed and no parameters. Answers { connectors: [ { slug, connectable } ] } for the connectors Polara offers, in registry order: aws, github, gcp, google_workspace, azure and microsoft_entra. connectable is false only for a connector whose own app is not configured in this deploy. Cache-Control: public, max-age=60.",
        "responses": {
          "200": {
            "description": "{ success: true, data: { connectors: { slug: string, connectable: boolean }[] } }"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          }
        }
      }
    },
    "/final-submit-assessment": {
      "post": {
        "summary": "Submit the questionnaire, or save changed answers on a paid account",
        "description": "Every top-level key except assessment_part and expected_fields is an answer. A resubmit never deletes a gap: an item whose question still applies keeps its row, a new question adds one, an item that no longer applies is marked superseded, and a changed answer reopens the item it used to close. On a paid account the edit lock is read before any write, and a resubmit answers data.rederived { reopened, inserted, stale_policy_areas } (stale_policy_areas is null when it could not be read). Impersonated sessions are refused before any write.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "assessment_part": {
                    "type": "integer",
                    "enum": [
                      1,
                      2
                    ],
                    "description": "Which half of the questionnaire this is; absent means the whole questionnaire."
                  },
                  "expected_fields": {
                    "type": "object",
                    "description": "The values the client last read, for the save conflict check."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The submitted assessment in the standard success envelope; data.rederived on a paid resubmit"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN, FRAMEWORK_MISMATCH, COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "ANSWERS_FINAL (the opinion is signed or the audit is completed), ANSWERS_LOCKED_UNDER_REVIEW (an auditor is reviewing the built package), SAVE_CONFLICT, SHARED_ASSESSMENT_FINALIZED, RESUBMIT_WOULD_DISCARD_WORK, ONBOARDING_FROZEN"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/assessment-draft": {
      "get": {
        "summary": "Read the caller's own questionnaire draft",
        "parameters": [
          {
            "name": "provisional",
            "in": "query",
            "required": false,
            "description": "1 to also return provisional_score for a SOC 2 draft",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "description": "Returns the caller's own draft answers. No assessment id is accepted, so a caller reads only their own. Impersonated sessions may read. With provisional=1 on a SOC 2 draft, data.provisional_score is the readiness score (0 to 100) of the answers given so far, or null when none can be scored yet: a number only, with no gap text.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The draft answers in the standard success envelope"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Autosave questionnaire answers",
        "description": "Merges the sent answers into the saved draft. On a paid account the edit lock is read before the write. The autosave never re-checks gaps or policies; the submit does. Impersonated sessions are refused before any write.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "form_data"
                ],
                "properties": {
                  "form_data": {
                    "type": "object",
                    "description": "Partial answers, merged into the draft (at most 256 KB)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "data { saved, form_data, updated_at } in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN, COMPANY_ACCESS_REVOKED, COMPANY_INVITATION_PENDING"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "ANSWERS_FINAL (the opinion is signed or the audit is completed), ANSWERS_LOCKED_UNDER_REVIEW (an auditor is reviewing the built package), SAVE_CONFLICT, SHARED_ASSESSMENT_FINALIZED, ONBOARDING_FROZEN"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/final-submit-gap-fields": {
      "put": {
        "summary": "Save the answers on one gap's card",
        "description": "Saves the card answers for one gap; the completion rule decides its status. On a paid account with a built package the edit lock is read before the write, whatever isEdit says, and the save recalculates progress and records which approved policies it made stale. action records or withdraws a disclosed exception (paid accounts only). Impersonated sessions are refused before any write.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "gapId"
                ],
                "properties": {
                  "gapId": {
                    "type": "string"
                  },
                  "fieldData": {
                    "type": "object",
                    "description": "Card answers keyed by field."
                  },
                  "isEdit": {
                    "type": "boolean"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "disclose_exception",
                      "withdraw_exception"
                    ]
                  },
                  "exceptionText": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The saved gap in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR, EXCEPTION_TEXT_REQUIRED, BEFORE_READINESS_ANSWER, BEFORE_POLICY_APPROVAL (error.context.problems names each date)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (outside the free workspace; an exception disclosure is paid only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "ANSWERS_FINAL (the opinion is signed or the audit is completed), ANSWERS_LOCKED_UNDER_REVIEW (an auditor is reviewing the built package), SAVE_CONFLICT, EXCEPTION_NOT_FOUND, SIGNATORY_MISMATCH. On SIGNATORY_MISMATCH, error.context { can_declare, step, kind, named } (phase 78): can_declare is true for the owner or an active member, never while impersonating; the page then offers to continue as yourself (account-signer declare_signatory) or to send the step to the named person (account-signer request_authority_action)."
          },
          "410": {
            "description": "ADMIN_CLOSE_RETIRED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/approve-policy": {
      "post": {
        "summary": "Approve, revoke, or record the opening of one policy",
        "description": "Send the content hash of the text that was read. action opened records that the approver opened this text; approval needs a recorded open and a reading time. A policy written from answers or files that have since changed is refused with POLICY_FACTS_CHANGED (error.context.area names the policy, never its text); refresh it, then approve the new text. A policy written before the facts hash existed is approved as before. Paid accounts only. Impersonated sessions are refused before any write.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessmentId",
                  "policyArea"
                ],
                "properties": {
                  "assessmentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "policyArea": {
                    "type": "string"
                  },
                  "approved": {
                    "type": "boolean"
                  },
                  "expectedContentHash": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{16}$"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "opened"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The approval state in the standard success envelope"
          },
          "400": {
            "description": "VALIDATION_ERROR, POLICY_NOT_GENERATED"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN, POLICY_APPROVER_MISMATCH. On POLICY_APPROVER_MISMATCH, error.context.named lists the named approvers and adds can_declare, step approve_policy and kind approver (phase 78): an active member can name themselves the approver (account-signer delegate_policy_approval with their own id), and policies that name someone else are written again to name them before they approve."
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "POLICY_FACTS_CHANGED (refresh this policy first), POLICY_CHANGED (read the new version), POLICY_GENERATING, POLICY_CHECKS_FAILED, POLICY_APPROVER_UNNAMED, POLICY_NOT_OPENED, POLICY_READ_TOO_FAST, SAVE_CONFLICT"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    },
    "/oauth-github-connect": {
      "post": {
        "summary": "Finish a GitHub App install for an assessment",
        "description": "The browser posts the installation_id, state and user authorization code that GitHub sent on the redirect. The state names the assessment, and the caller must have access to it. The code is exchanged with GitHub and the installation is bound only when GitHub lists it for that GitHub user; otherwise 403 GITHUB_INSTALLATION_NOT_VERIFIED and nothing is stored. An installation already connected to another assessment is refused with 409 GITHUB_INSTALLATION_IN_USE. An install on a GitHub organization connects. An install on a personal GitHub account connects only when the state carries the customer's statement that the account holds only the company's work (oauth-github-launch-url scope_attestation); the statement is stored on the connection with the person and the date, written to the audit log as oauth.connect.scope_attested, and disclosed in Section 3.2 and the export manifest. Without the statement the install is refused with 422 CONNECTOR_PERSONAL_ACCOUNT and error.context { attestable: true, account_login }: nothing is stored, no sync starts, and the refusal is written to the audit log. setup_action update is accepted only when the state carries the statement (a retried install of an app already on the account). One active GitHub connection per assessment.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "installation_id",
                  "state",
                  "setup_action",
                  "code"
                ],
                "properties": {
                  "installation_id": {
                    "type": [
                      "integer",
                      "string"
                    ],
                    "description": "A positive integer; a numeric string is accepted"
                  },
                  "state": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string",
                    "description": "GitHub App user authorization code from the install redirect"
                  },
                  "setup_action": {
                    "type": "string",
                    "enum": [
                      "install",
                      "update"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { connection_id, account_login, provider: 'github' } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (body, installation_id, or an invalid or expired state)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, or FORBIDDEN (the state belongs to another user or was already used, or the caller cannot reach the assessment), or GITHUB_INSTALLATION_NOT_VERIFIED (no code, or GitHub does not list the installation for the authorizing user)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "ALREADY_CONNECTED, or GITHUB_INSTALLATION_IN_USE (the installation is connected to another assessment)"
          },
          "422": {
            "description": "CONNECTOR_PERSONAL_ACCOUNT (a personal GitHub account and no statement in the state; error.context { attestable: true, account_login })"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "502": {
            "description": "GITHUB_VALIDATION_FAILED"
          },
          "503": {
            "description": "CONFIG_ERROR"
          }
        }
      }
    },
    "/oauth-google-callback": {
      "get": {
        "summary": "Google consent callback for Google Cloud and Google Workspace",
        "description": "Google sends the browser here after consent. It always answers 302 to /dashboard/integrations and never returns the JSON envelope. The Google account should belong to the company's Google Workspace: its Workspace domain the company domain or a subdomain of it. The company domain is read from the account owner's email address, or from the company website when the owner uses a personal mail address; when neither gives one, any Workspace account is accepted. When the state carries the customer's statement (oauth-google-launch-url scope_attestation), a personal Google account connects Google Cloud, and an account on another Workspace domain connects Google Cloud and Google Workspace; each row stores the statement with the person and the date, and oauth.connect.scope_attested is audited. Google Workspace with a personal Google account stays refused: it has no Workspace directory to read. Only one Google Cloud connection can be active on an assessment, with or without a statement. On a refusal nothing is stored and the refusal is written to the audit log.",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "error",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Location is /dashboard/integrations. On success it carries google_connected (gcp, google_workspace, or both, comma separated) and may carry google_warning (workspace_admin_check_errored, workspace_not_admin). On failure it carries google_error and, when a statement could open the refusal, attestable=1 with google_hd and company_domain (domains only). google_error is one of: CONNECTOR_PERSONAL_ACCOUNT (a personal Google account, or one with no Workspace domain), CONNECTOR_DOMAIN_MISMATCH (a Workspace domain other than the company domain), CONNECTOR_ALREADY_BOUND (Google Cloud is already connected on this assessment with a different Google account; disconnect it on its card first), method_not_allowed, consent_denied, google_error, missing_params, invalid_state, state_replay, assessment_not_found, forbidden, code_exchange_failed, id_token_invalid, no_scopes_granted, workspace_insert_failed, workspace_not_admin, workspace_admin_check_failed, internal_error"
          }
        }
      }
    },
    "/generate-policy-draft": {
      "post": {
        "summary": "Start writing a policy, or every policy the Policies step still needs",
        "description": "The policy is written by a background job; this answers at once with status processing. Four request shapes: a generate (company_name, signature, assessment_id, and optionally policy_area, template_code and field_data); refresh: true, a new version written from the latest answers (assessment_id, policy_area); retry: true, one policy again (assessment_id, policy_area); generate_policies: true, every SOC 2 policy the Policies step still needs (assessment_id, optional resume). Paid accounts only. Impersonated sessions are refused before any write. For SOC 2, every shape answers 409 POLICIES_LOCKED until remediation is finished and 409 POLICY_FACTS_CONFLICT while the answers disagree. A resume (resume: true) starts only policies queued earlier and is not checked here; each of those jobs checks the answers again and ends that policy failed with POLICY_FACTS_CONFLICT.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessment_id"
                ],
                "properties": {
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "policy_area": {
                    "type": "string"
                  },
                  "company_name": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string",
                    "description": "Name, Title"
                  },
                  "template_code": {
                    "type": "string"
                  },
                  "field_data": {
                    "type": "object"
                  },
                  "refresh": {
                    "type": "boolean"
                  },
                  "retry": {
                    "type": "boolean"
                  },
                  "generate_policies": {
                    "type": "boolean"
                  },
                  "resume": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { status: processing, assessment_id, policy_area, request_id, started_at } }, with joined: true when a job for the same answers is already running; generate_policies answers { assessment_id, queued, dispatched }"
          },
          "400": {
            "description": "VALIDATION_ERROR, or a field_data content check code"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED (paid accounts only)"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FRAMEWORK_MISMATCH"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "POLICY_FACTS_CONFLICT: the company's own answers disagree for a policy this request would write, so nothing is queued and no AI call is made. error.message says what to settle. error.context carries field (primary_cloud, access_review_cadence, headcount or independent_reviewer), values (each answer with where it came from, for example \"Azure (questionnaire A4)\"; empty for independent_reviewer, which means no second person is named to review the policies) and areas (the policies refused). Also POLICIES_LOCKED (error.context carries the remaining gap count), GENERATION_IN_PROGRESS, NO_POLICY, NO_CHANGES, POLICY_EXISTS, UNDER_AUDITOR_REVIEW"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "502": {
            "description": "INTERNAL_ERROR (the background job could not be started; retry)"
          }
        }
      }
    },
    "/free-sample-policy": {
      "get": {
        "summary": "Read the free sample policy",
        "description": "The one sample Information Security Policy a free workspace can have written. An account that is not paid and has no free workspace answers 402 PAYMENT_REQUIRED.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ success: true, data: { area: information_security, status, markdown, generated_at, attempts_left } }; markdown is set only when the sample is written"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      },
      "post": {
        "summary": "Start the free sample policy",
        "description": "Starts the sample in a background job. A paid account writes its policies in the Policies step and gets 409 USE_POLICIES_STEP. A caller whose email address is not verified gets 403 EMAIL_NOT_VERIFIED before the start is counted and before any AI call. While the answers disagree the start is refused with 409 POLICY_FACTS_CONFLICT before it is counted against the free starts and before any AI call. Impersonated sessions are refused before any write.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessment_id"
                ],
                "properties": {
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { area: information_security, status, markdown, generated_at, attempts_left } }; markdown is set only when the sample is written (the sample is already written or being written)"
          },
          "202": {
            "description": "{ success: true, data: { area: information_security, status: processing, markdown: null, attempts_left } }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PAYMENT_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, EMAIL_NOT_VERIFIED (the caller's email address is not verified yet)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "409": {
            "description": "POLICY_FACTS_CONFLICT: the company's own answers disagree for a policy this request would write, so nothing is queued and no AI call is made. error.message says what to settle. error.context carries field (primary_cloud, access_review_cadence, headcount or independent_reviewer), values (each answer with where it came from, for example \"Azure (questionnaire A4)\"; empty for independent_reviewer, which means no second person is named to review the policies) and areas (the policies refused). Also USE_POLICIES_STEP, SAMPLE_USED"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "INTERNAL_ERROR (the sample could not be started and was not counted; retry)"
          }
        }
      }
    },
    "/oauth-github-launch-url": {
      "post": {
        "summary": "Start a GitHub App install for an assessment",
        "description": "Returns data.launch_url for the GitHub App install connect flow with a signed, single-use state that names the assessment. Paid accounts only (402 PLAN_REQUIRED, checked first). scope_attestation (phase 78) carries the customer's statement that a personal or off-domain account holds only the company's work; the server stamps the time and signs it into the state, and the connect step stores the sentence it words itself.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessment_id"
                ],
                "properties": {
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "scope_attestation": {
                    "type": "object",
                    "required": [
                      "version"
                    ],
                    "properties": {
                      "version": {
                        "type": "string",
                        "enum": [
                          "scope-v1"
                        ]
                      },
                      "reason": {
                        "type": "string",
                        "enum": [
                          "personal_account",
                          "domain_mismatch"
                        ],
                        "description": "What the notice the customer read named. The connect records the statement only when the bound account has this reason."
                      },
                      "account": {
                        "type": "string",
                        "maxLength": 320,
                        "description": "The account the notice named (GitHub login). An install on another account is refused with 422 CONNECTOR_PERSONAL_ACCOUNT."
                      },
                      "hosted_domain": {
                        "type": "string",
                        "maxLength": 253,
                        "description": "The Google Workspace domain the notice named. A consent on another domain is refused again with attestable=1."
                      }
                    },
                    "description": "Send only after the customer ticked: This account holds only the company's work, and I am allowed to connect it for the company."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { launch_url } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (assessment_id, or a scope_attestation of another version); CONNECTOR_NOT_OFFERED (the connector is not listed, refused before any read)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PLAN_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY (refused before any read), FORBIDDEN (not someone at this company; a system admin outside it may launch but not send scope_attestation)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "CONFIG_ERROR"
          }
        }
      }
    },
    "/oauth-google-launch-url": {
      "post": {
        "summary": "Start the Google consent for Google Cloud and Google Workspace",
        "description": "Returns data.launch_url for the Google consent connect flow with a signed, single-use state that names the assessment. Paid accounts only (402 PLAN_REQUIRED, checked first). scope_attestation (phase 78) carries the customer's statement that a personal or off-domain account holds only the company's work; the server stamps the time and signs it into the state, and the connect step stores the sentence it words itself.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "assessment_id"
                ],
                "properties": {
                  "assessment_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "scope_attestation": {
                    "type": "object",
                    "required": [
                      "version"
                    ],
                    "properties": {
                      "version": {
                        "type": "string",
                        "enum": [
                          "scope-v1"
                        ]
                      },
                      "reason": {
                        "type": "string",
                        "enum": [
                          "personal_account",
                          "domain_mismatch"
                        ],
                        "description": "What the notice the customer read named. The connect records the statement only when the bound account has this reason."
                      },
                      "account": {
                        "type": "string",
                        "maxLength": 320,
                        "description": "The account the notice named (GitHub login). An install on another account is refused with 422 CONNECTOR_PERSONAL_ACCOUNT."
                      },
                      "hosted_domain": {
                        "type": "string",
                        "maxLength": 253,
                        "description": "The Google Workspace domain the notice named. A consent on another domain is refused again with attestable=1."
                      }
                    },
                    "description": "Send only after the customer ticked: This account holds only the company's work, and I am allowed to connect it for the company."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { launch_url } }"
          },
          "400": {
            "description": "VALIDATION_ERROR (assessment_id, or a scope_attestation of another version); CONNECTOR_NOT_OFFERED (the connector is not listed, refused before any read)"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "402": {
            "description": "PLAN_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY (refused before any read), FORBIDDEN (not someone at this company; a system admin outside it may launch but not send scope_attestation)"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          },
          "503": {
            "description": "CONFIG_ERROR"
          }
        }
      }
    },
    "/oauth-confirm-scope": {
      "post": {
        "summary": "Confirm an existing personal or off-domain connection",
        "description": "Phase 78. Records the customer's statement that an existing connection on a personal account or another domain holds only the company's work, with no reconnect. Only someone at the company records it (no system admin bypass); impersonated sessions are refused before anything is read. The connection is then in scope, Section 3.2 and the export manifest disclose the statement, and the description needs approval again because its text changed. A connection already covered answers 200 with the stored statement.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "connection_id",
                  "scope_attestation"
                ],
                "properties": {
                  "connection_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "scope_attestation": {
                    "type": "object",
                    "required": [
                      "version"
                    ],
                    "properties": {
                      "version": {
                        "type": "string",
                        "enum": [
                          "scope-v1"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ success: true, data: { connection_id, scope_attestation } }"
          },
          "400": {
            "description": "VALIDATION_ERROR"
          },
          "401": {
            "description": "AUTH_REQUIRED"
          },
          "403": {
            "description": "IMPERSONATION_READ_ONLY, FORBIDDEN"
          },
          "404": {
            "description": "NOT_FOUND"
          },
          "405": {
            "description": "METHOD_NOT_ALLOWED"
          },
          "409": {
            "description": "SCOPE_NOT_NEEDED (the account is the company's own), CONFLICT (the connection changed; try again)"
          },
          "422": {
            "description": "SCOPE_NOT_ATTESTABLE (a personal Google account on Google Workspace)"
          },
          "500": {
            "description": "INTERNAL_ERROR"
          }
        }
      }
    }
  }
}
