{
 "openapi": "3.1.0",
 "info": {
  "title": "OHN-33 Developer and Partner Portal",
  "version": "1.0.0",
  "description": "Controlled partner onboarding, client credentials, sandbox, scope approval, usage and versioned contracts. Default-deny; every POST needs an Idempotency-Key; mutations use expected_version. A client secret is returned once and never stored, logged or replayed. Tokens come from the platform gateway (purpose partner_portal and organization_id are claims); the reference synthetic sign-in is not part of this contract."
 },
 "servers": [
  {
   "url": "/api/ohn/v1"
  }
 ],
 "paths": {
  "/health/ohn-33": {
   "get": {
    "summary": "Health (public)",
    "responses": {
     "200": {
      "description": "ok"
     },
     "503": {
      "description": "database unavailable"
     }
    }
   }
  },
  "/developer/apps": {
   "post": {
    "summary": "OHN-33-API-001 Register a partner application (F001, W001)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RegisterResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RegisterApp"
       }
      }
     }
    }
   },
   "get": {
    "summary": "List applications (cursor)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 32
      }
     },
     {
      "name": "environment",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AppList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/apps/{id}": {
   "get": {
    "summary": "Application with credentials inventory and sandbox tenant",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AppDetail"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/apps/{id}/history": {
   "get": {
    "summary": "Workflow history of the application, its scope requests and rotations",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/History"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/apps/{id}/trust-verify": {
   "post": {
    "summary": "Verify partner trust (W001 registration_submitted -> trust_verified)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AppResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Step"
       }
      }
     }
    }
   }
  },
  "/developer/apps/{id}/scope-requests": {
   "post": {
    "summary": "Request additional scopes (W002)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ScopeRequestResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ScopeRequest"
       }
      }
     }
    }
   },
   "get": {
    "summary": "List scope requests of an application",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ScopeRequestList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/scope-requests/{id}/review": {
   "post": {
    "summary": "Least-privilege review: may only narrow (W002)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ScopeRequestResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ScopeReview"
       }
      }
     }
    }
   }
  },
  "/developer/scope-requests/{id}/decide": {
   "post": {
    "summary": "Approve (twice, two different reviewers) or deny (W002)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ScopeRequestResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ScopeDecide"
       }
      }
     }
    }
   }
  },
  "/developer/scope-requests/{id}/deploy": {
   "post": {
    "summary": "Deploy a dual-approved scope request (W002; production patient scopes need a passing conformance run)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ScopeDeployResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Step"
       }
      }
     }
    }
   }
  },
  "/developer/apps/{id}/credentials/issue": {
   "post": {
    "summary": "Issue client credentials via OHN-38; the secret is returned once (W001 scopes_approved -> credentials_issued)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/IssueResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Step"
       }
      }
     }
    }
   }
  },
  "/developer/apps/{id}/credentials": {
   "get": {
    "summary": "Credential inventory (hints only, never secrets)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CredentialList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/apps/{id}/rotate": {
   "post": {
    "summary": "OHN-33-API-002 Rotate a client credential (F002, W003); the new secret is returned once",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RotateResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Rotate"
       }
      }
     }
    }
   }
  },
  "/developer/apps/{id}/rotations": {
   "get": {
    "summary": "List rotations of an application",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RotationList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/rotations/{id}/confirm": {
   "post": {
    "summary": "Confirm consumers moved to the new credential (W003)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RotationResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Step"
       }
      }
     }
    }
   }
  },
  "/developer/rotations/{id}/retire": {
   "post": {
    "summary": "Revoke the old credential after confirmation and the grace window (W003)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RotationResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Step"
       }
      }
     }
    }
   }
  },
  "/developer/apps/{id}/sandbox/enable": {
   "post": {
    "summary": "Enable the sandbox tenant (W001 credentials_issued -> sandbox_enabled)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SandboxResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Step"
       }
      }
     }
    }
   }
  },
  "/developer/sandbox": {
   "get": {
    "summary": "Sandbox monitor",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SandboxList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/conformance-runs": {
   "post": {
    "summary": "Run a sandbox conformance suite via OHN-46 (F003). Evidence only, never certification",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RunResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Conformance"
       }
      }
     }
    }
   },
   "get": {
    "summary": "List conformance runs",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     },
     {
      "name": "app",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RunList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/usage": {
   "get": {
    "summary": "OHN-33-API-003 Partner API usage and quota (cursor)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     },
     {
      "name": "app",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "operation",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 128
      }
     },
     {
      "name": "period_from",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
      }
     },
     {
      "name": "period_to",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/UsageList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/usage/records": {
   "post": {
    "summary": "Record daily usage (metering feed)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Recorded"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/UsageRecords"
       }
      }
     }
    }
   }
  },
  "/developer/contracts": {
   "get": {
    "summary": "OHN-33-API-004 Versioned API contracts (cursor)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ContractList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/contracts/sync": {
   "post": {
    "summary": "Sync the contract catalogue from OHN-21",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Synced"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/examples": {
   "get": {
    "summary": "Synthetic integration examples",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ExampleList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/dashboard": {
   "get": {
    "summary": "Developer dashboard",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Dashboard"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/audit": {
   "get": {
    "summary": "Credential audit (append-only; no secret material)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     },
     {
      "name": "app",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CredentialAuditList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/policy": {
   "get": {
    "summary": "Portal policy",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PolicyView"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   },
   "post": {
    "summary": "Write the portal policy (versioned)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PolicyResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PolicyWrite"
       }
      }
     }
    }
   }
  },
  "/developer/code-lists/{list}": {
   "get": {
    "summary": "Read a controlled code list (environment, scope)",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "list",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "environment",
        "scope"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CodeList"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   },
   "post": {
    "summary": "Upsert a controlled code list",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "list",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "environment",
        "scope"
       ]
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Recorded"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CodeListWrite"
       }
      }
     }
    }
   }
  },
  "/developer/maintenance/drain-outbox": {
   "post": {
    "summary": "Drain the outbox (delivers nothing without a configured sink)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Drained"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/report-catalog": {
   "get": {
    "summary": "Report catalogue",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ReportCatalog"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/reports/{reportId}": {
   "get": {
    "summary": "Run report OHN-33-R001..R003",
    "x-roles": [
     "partner_developer",
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "reportId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "enum": [
        "OHN-33-R001",
        "OHN-33-R002",
        "OHN-33-R003"
       ]
      }
     },
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "maxLength": 64
      }
     },
     {
      "name": "partner",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "period_from",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
      },
      "description": "A real calendar day; a malformed value is reported as \"Invalid calendar date\""
     },
     {
      "name": "period_to",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
      }
     },
     {
      "name": "environment",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
      }
     },
     {
      "name": "scope",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
      }
     },
     {
      "name": "status",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
      }
     },
     {
      "name": "version",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Report"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  },
  "/developer/reports/{reportId}/export": {
   "post": {
    "summary": "Create a signed, single-use, 5-minute CSV/PDF export",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "reportId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 8,
       "maxLength": 128
      }
     }
    ],
    "responses": {
     "400": {
      "description": "Idempotency-Key missing or malformed"
     },
     "409": {
      "description": "Version conflict, idempotency key reuse, separation of duties or illegal transition"
     },
     "201": {
      "description": "Success",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ExportResult"
        }
       }
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ExportCommand"
       }
      }
     }
    }
   }
  },
  "/developer/exports/{token}": {
   "get": {
    "summary": "Download an export (owner only, single use)",
    "x-roles": [
     "partner_security_reviewer"
    ],
    "parameters": [
     {
      "name": "token",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[A-Za-z0-9_-]{20,64}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success",
      "content": {
       "text/csv": {},
       "application/pdf": {}
      }
     },
     "401": {
      "description": "Unauthenticated"
     },
     "403": {
      "description": "Denied by policy (audited)"
     },
     "404": {
      "description": "Not found or not visible"
     },
     "422": {
      "description": "Validation failed or typed refusal"
     },
     "429": {
      "description": "Rate limited"
     },
     "503": {
      "description": "Dependency unavailable (nothing stored)"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Receipt": {
    "type": "object",
    "properties": {
     "receipt_id": {
      "type": "string",
      "format": "uuid"
     },
     "committed_at": {
      "type": "string"
     },
     "aggregate_id": {
      "type": "string",
      "format": "uuid"
     },
     "version": {
      "type": "integer"
     },
     "status": {
      "enum": [
       "committed",
       "denied"
      ]
     }
    }
   },
   "RegisterApp": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "organization_id": {
      "type": "string",
      "format": "uuid"
     },
     "application_name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 512
     },
     "redirect_uris": {
      "type": "array",
      "items": {
       "type": "string",
       "minLength": 1,
       "maxLength": 2048
      },
      "minItems": 1,
      "maxItems": 50
     },
     "requested_scopes": {
      "type": "array",
      "items": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
      },
      "minItems": 1,
      "maxItems": 100
     },
     "environment": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
     },
     "contact_email": {
      "type": "string",
      "format": "email",
      "maxLength": 254
     }
    },
    "required": [
     "organization_id",
     "application_name",
     "redirect_uris",
     "requested_scopes",
     "environment",
     "contact_email"
    ]
   },
   "Step": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "expected_version": {
      "type": "integer",
      "minimum": 1
     },
     "reason": {
      "type": "string",
      "minLength": 10,
      "maxLength": 4096
     }
    },
    "required": [
     "expected_version",
     "reason"
    ]
   },
   "ScopeRequest": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "requested_scopes": {
      "type": "array",
      "items": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
      },
      "minItems": 1,
      "maxItems": 100
     },
     "justification": {
      "type": "string",
      "minLength": 10,
      "maxLength": 4096
     }
    },
    "required": [
     "requested_scopes",
     "justification"
    ]
   },
   "ScopeReview": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "expected_version": {
      "type": "integer",
      "minimum": 1
     },
     "granted_scopes": {
      "type": "array",
      "items": {
       "type": "string",
       "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
      },
      "minItems": 1,
      "maxItems": 100
     },
     "reason": {
      "type": "string",
      "minLength": 10,
      "maxLength": 4096
     }
    },
    "required": [
     "expected_version",
     "granted_scopes",
     "reason"
    ]
   },
   "ScopeDecide": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "expected_version": {
      "type": "integer",
      "minimum": 1
     },
     "decision": {
      "enum": [
       "approve",
       "deny"
      ]
     },
     "reason": {
      "type": "string",
      "minLength": 10,
      "maxLength": 4096
     }
    },
    "required": [
     "expected_version",
     "decision",
     "reason"
    ]
   },
   "Rotate": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "client_id": {
      "type": "string",
      "format": "uuid"
     },
     "rotation_reason": {
      "type": "string",
      "minLength": 10,
      "maxLength": 4096
     },
     "effective_at": {
      "type": "string",
      "format": "date-time"
     },
     "grace_window_minutes": {
      "type": "integer",
      "minimum": 0,
      "maximum": 43200
     }
    },
    "required": [
     "client_id",
     "rotation_reason",
     "effective_at",
     "grace_window_minutes"
    ]
   },
   "Conformance": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "partner_app_id": {
      "type": "string",
      "format": "uuid"
     },
     "profile_pack": {
      "type": "string",
      "format": "uuid"
     },
     "test_suite": {
      "type": "string",
      "format": "uuid"
     },
     "synthetic_fixture_set": {
      "type": "string",
      "format": "uuid"
     },
     "requester_id": {
      "type": "string",
      "format": "uuid"
     }
    },
    "required": [
     "partner_app_id",
     "profile_pack",
     "test_suite",
     "synthetic_fixture_set",
     "requester_id"
    ]
   },
   "UsageRecords": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "records": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": false,
       "properties": {
        "app_id": {
         "type": "string",
         "format": "uuid"
        },
        "operation": {
         "type": "string",
         "minLength": 1,
         "maxLength": 128
        },
        "day": {
         "type": "string",
         "format": "date"
        },
        "requests": {
         "type": "integer",
         "minimum": 0,
         "maximum": 1000000000
        },
        "denials": {
         "type": "integer",
         "minimum": 0,
         "maximum": 1000000000,
         "description": "cannot exceed requests"
        },
        "p95_latency_ms": {
         "type": "integer",
         "minimum": 0,
         "maximum": 600000
        }
       },
       "required": [
        "app_id",
        "operation",
        "day",
        "requests",
        "denials",
        "p95_latency_ms"
       ]
      },
      "minItems": 1,
      "maxItems": 500
     }
    },
    "required": [
     "records"
    ]
   },
   "PolicyWrite": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "max_redirect_uris": {
      "type": "integer",
      "minimum": 1,
      "maximum": 50
     },
     "allow_loopback_redirect_in_sandbox": {
      "type": "boolean"
     },
     "credential_max_age_days": {
      "type": "integer",
      "minimum": 1,
      "maximum": 3650
     },
     "dormant_days": {
      "type": "integer",
      "minimum": 1,
      "maximum": 3650
     },
     "daily_quota": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000000000
     },
     "max_grace_window_minutes": {
      "type": "integer",
      "minimum": 0,
      "maximum": 43200
     },
     "conformance_validity_days": {
      "type": "integer",
      "minimum": 1,
      "maximum": 3650
     },
     "approval_reference": {
      "type": "string",
      "minLength": 3,
      "maxLength": 128
     },
     "expected_version": {
      "type": "integer",
      "minimum": 1
     },
     "reason": {
      "type": "string",
      "minLength": 10,
      "maxLength": 4096
     }
    },
    "required": [
     "max_redirect_uris",
     "allow_loopback_redirect_in_sandbox",
     "credential_max_age_days",
     "dormant_days",
     "daily_quota",
     "max_grace_window_minutes",
     "conformance_validity_days",
     "approval_reference",
     "reason"
    ]
   },
   "CodeListWrite": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "entries": {
      "type": "array",
      "items": {
       "type": "object",
       "additionalProperties": false,
       "properties": {
        "code": {
         "type": "string",
         "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
        },
        "label_en": {
         "type": "string",
         "minLength": 1,
         "maxLength": 128
        },
        "label_fr": {
         "type": "string",
         "minLength": 1,
         "maxLength": 128
        },
        "active": {
         "type": "boolean",
         "default": true
        },
        "restricted": {
         "type": "boolean",
         "default": false,
         "description": "marks a scope that reaches patient data"
        }
       },
       "required": [
        "code",
        "label_en",
        "label_fr"
       ]
      },
      "minItems": 1,
      "maxItems": 200
     }
    },
    "required": [
     "entries"
    ]
   },
   "ExportCommand": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "format": {
      "enum": [
       "csv",
       "pdf"
      ]
     },
     "filters": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
       "partner": {
        "type": "string",
        "format": "uuid"
       },
       "period_from": {
        "type": "string",
        "format": "date"
       },
       "period_to": {
        "type": "string",
        "format": "date"
       },
       "environment": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
       },
       "scope": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
       },
       "status": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_.:-]{0,63}$"
       },
       "version": {
        "type": "string",
        "format": "uuid"
       }
      }
     }
    },
    "required": [
     "format"
    ]
   },
   "Application": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "application_name": {
      "type": "string"
     },
     "redirect_uris": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "requested_scopes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "approved_scopes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "environment": {
      "type": "string"
     },
     "contact_email": {
      "type": "string"
     },
     "state": {
      "enum": [
       "registration_submitted",
       "trust_verified",
       "scopes_approved",
       "credentials_issued",
       "sandbox_enabled"
      ]
     },
     "trust_verified": {
      "type": "boolean"
     },
     "version": {
      "type": "integer"
     }
    }
   },
   "ScopeRequestView": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "app_id": {
      "type": "string",
      "format": "uuid"
     },
     "kind": {
      "enum": [
       "initial",
       "escalation"
      ]
     },
     "requested_scopes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "granted_scopes": {
      "type": [
       "array",
       "null"
      ],
      "items": {
       "type": "string"
      }
     },
     "state": {
      "enum": [
       "requested",
       "least_privilege_review",
       "approval_pending",
       "dual_approved",
       "denied",
       "deployed"
      ]
     },
     "approvals": {
      "type": "integer"
     },
     "version": {
      "type": "integer"
     }
    }
   },
   "CredentialView": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "app_id": {
      "type": "string",
      "format": "uuid"
     },
     "client_id": {
      "type": "string"
     },
     "kind": {
      "enum": [
       "sandbox",
       "production"
      ]
     },
     "status": {
      "enum": [
       "active",
       "retiring",
       "revoked"
      ]
     },
     "secret_hint": {
      "type": "string",
      "description": "Last four characters only"
     },
     "retire_not_before": {
      "type": [
       "string",
       "null"
      ]
     },
     "downstream_revocation": {
      "type": "string"
     }
    }
   },
   "RotationView": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "app_id": {
      "type": "string",
      "format": "uuid"
     },
     "old_credential_id": {
      "type": "string",
      "format": "uuid"
     },
     "new_credential_id": {
      "type": "string",
      "format": "uuid"
     },
     "state": {
      "enum": [
       "new_credential_issued",
       "consumers_confirmed",
       "old_revoked"
      ]
     },
     "grace_window_minutes": {
      "type": "integer"
     },
     "version": {
      "type": "integer"
     }
    }
   },
   "RunView": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "app_id": {
      "type": "string",
      "format": "uuid"
     },
     "status": {
      "enum": [
       "passed",
       "failed"
      ]
     },
     "pass_count": {
      "type": "integer"
     },
     "fail_count": {
      "type": "integer"
     },
     "result_scope": {
      "type": "object",
      "description": "States the suite and environment; certification is always false"
     }
    }
   },
   "RegisterResult": {
    "type": "object",
    "properties": {
     "application": {
      "$ref": "#/components/schemas/Application"
     },
     "scope_request": {
      "$ref": "#/components/schemas/ScopeRequestView"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "AppResult": {
    "type": "object",
    "properties": {
     "application": {
      "$ref": "#/components/schemas/Application"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "AppList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Application"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "AppDetail": {
    "type": "object",
    "properties": {
     "application": {
      "$ref": "#/components/schemas/Application"
     },
     "credentials": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CredentialView"
      }
     },
     "sandbox_tenant": {
      "type": [
       "object",
       "null"
      ]
     }
    }
   },
   "History": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "ScopeRequestResult": {
    "type": "object",
    "properties": {
     "scope_request": {
      "$ref": "#/components/schemas/ScopeRequestView"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "ScopeDeployResult": {
    "type": "object",
    "properties": {
     "scope_request": {
      "$ref": "#/components/schemas/ScopeRequestView"
     },
     "application": {
      "$ref": "#/components/schemas/Application"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "ScopeRequestList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ScopeRequestView"
      }
     }
    }
   },
   "IssueResult": {
    "type": "object",
    "properties": {
     "application": {
      "$ref": "#/components/schemas/Application"
     },
     "credential": {
      "$ref": "#/components/schemas/CredentialView"
     },
     "client_secret": {
      "type": "string",
      "description": "Shown once; never stored, logged or replayed (idempotent replays return [redacted])"
     },
     "secret_shown_once": {
      "type": "boolean"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "CredentialList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CredentialView"
      }
     }
    }
   },
   "RotateResult": {
    "type": "object",
    "properties": {
     "rotation": {
      "$ref": "#/components/schemas/RotationView"
     },
     "credential": {
      "$ref": "#/components/schemas/CredentialView"
     },
     "client_secret": {
      "type": "string",
      "description": "Shown once"
     },
     "secret_shown_once": {
      "type": "boolean"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "RotationList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/RotationView"
      }
     }
    }
   },
   "RotationResult": {
    "type": "object",
    "properties": {
     "rotation": {
      "$ref": "#/components/schemas/RotationView"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "SandboxResult": {
    "type": "object",
    "properties": {
     "application": {
      "$ref": "#/components/schemas/Application"
     },
     "sandbox_tenant": {
      "type": "object"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "SandboxList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "RunResult": {
    "type": "object",
    "properties": {
     "run": {
      "$ref": "#/components/schemas/RunView"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "RunList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/RunView"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "UsageList": {
    "type": "object",
    "properties": {
     "quota_per_day": {
      "type": [
       "integer",
       "null"
      ]
     },
     "quota_state": {
      "enum": [
       "configured",
       "not_configured"
      ]
     },
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "Recorded": {
    "type": "object",
    "properties": {
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "ContractList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "Synced": {
    "type": "object",
    "properties": {
     "synced": {
      "type": "integer"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "ExampleList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "Dashboard": {
    "type": "object",
    "properties": {
     "kpis": {
      "type": "object"
     },
     "status_distribution": {
      "type": "object"
     },
     "policy_configured": {
      "type": "boolean"
     },
     "trend": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "exceptions": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "CredentialAuditList": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "PolicyView": {
    "type": "object",
    "properties": {
     "configured": {
      "type": "boolean"
     },
     "version": {
      "type": "integer"
     },
     "config": {
      "type": [
       "object",
       "null"
      ]
     }
    }
   },
   "PolicyResult": {
    "type": "object",
    "properties": {
     "version": {
      "type": "integer"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   },
   "CodeList": {
    "type": "object",
    "properties": {
     "list": {
      "type": "string"
     },
     "items": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "Drained": {
    "type": "object",
    "properties": {
     "delivered": {
      "type": "integer"
     },
     "pending": {
      "type": "integer"
     }
    }
   },
   "ReportCatalog": {
    "type": "object",
    "properties": {
     "reports": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "Report": {
    "type": "object",
    "properties": {
     "report_id": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "columns": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "rows": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "summary": {
      "type": "object"
     },
     "state": {
      "enum": [
       "rendered",
       "no_authorized_data"
      ]
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "ExportResult": {
    "type": "object",
    "properties": {
     "export_id": {
      "type": "string",
      "format": "uuid"
     },
     "report_id": {
      "type": "string"
     },
     "format": {
      "type": "string"
     },
     "rows": {
      "type": "integer"
     },
     "expires_at": {
      "type": "string"
     },
     "single_use": {
      "type": "boolean"
     },
     "download_path": {
      "type": "string"
     },
     "receipt": {
      "$ref": "#/components/schemas/Receipt"
     }
    }
   }
  },
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ]
}