{
  "openapi": "3.0.4",
  "info": {
    "title": "Aventelio Tenant API",
    "description": "Tenant-scoped queries and compliance actions. Use this tenant's hostname and enter its API key in Authorize. Generate, rotate or revoke keys in Administration → Tenant API. Lists return page, pageSize, total and items. Enums use their names and timestamps are UTC. For a status-change webhook, use application.id to retrieve /api/v1/applications/{id}/answers. API answers reflect current saved state, not necessarily the event snapshot. Try it out performs real operations on your tenant. The API key grants tenant administrative authority.",
    "version": "v1"
  },
  "servers": [
    {
      "url": "/",
      "description": "Current tenant portal"
    }
  ],
  "paths": {
    "/api/v1": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List available API endpoints",
        "description": "Endpoint directory and authentication information.",
        "operationId": "Directory",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "string"
                    },
                    "authentication": {
                      "type": "string"
                    },
                    "endpoints": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/tenant": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get tenant identity",
        "description": "Current tenant identity, portal title and support contact details. API key hashes are never returned.",
        "operationId": "Tenant",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tenantId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "tenantCode": {
                      "type": "string"
                    },
                    "tenantName": {
                      "type": "string"
                    },
                    "supportEmail": {
                      "type": "string"
                    },
                    "supportPhone": {
                      "type": "string"
                    },
                    "portalTitle": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/companies": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List companies",
        "description": "Paginated tenant companies.",
        "operationId": "GetCompanies",
        "parameters": [
          {
            "name": "flagId",
            "in": "query",
            "description": "Only companies with this tenant flag assigned.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 200,
                            "type": "string"
                          },
                          "abn": {
                            "maxLength": 50,
                            "type": "string",
                            "nullable": true
                          },
                          "tradingName": {
                            "maxLength": 200,
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "enum": [
                              "Registered",
                              "EoiInProgress",
                              "EoiSubmitted",
                              "EoiUnderReview",
                              "EoiChangesRequired",
                              "AssessmentInProgress",
                              "AssessmentSubmitted",
                              "AssessmentUnderReview",
                              "AssessmentChangesRequired",
                              "Approved",
                              "Unsuccessful",
                              "Inactive",
                              "InProgress",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired"
                            ],
                            "type": "string"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "flagsVersion": {
                            "type": "integer"
                          },
                          "flags": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "name": {
                                  "maxLength": 100,
                                  "type": "string"
                                },
                                "isActive": {
                                  "type": "boolean"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      },
      "post": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Create a company",
        "description": "Registers a company. Does not create a login, invitation or application.",
        "operationId": "CreateCompany",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              },
              "example": {
                "name": "Example Contractors",
                "abn": "12345678901",
                "tradingName": "Example"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              },
              "example": {
                "name": "Example Contractors",
                "abn": "12345678901",
                "tradingName": "Example"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              },
              "example": {
                "name": "Example Contractors",
                "abn": "12345678901",
                "tradingName": "Example"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "maxLength": 200,
                      "type": "string"
                    },
                    "abn": {
                      "maxLength": 50,
                      "type": "string",
                      "nullable": true
                    },
                    "tradingName": {
                      "maxLength": 200,
                      "type": "string",
                      "nullable": true
                    },
                    "status": {
                      "enum": [
                        "Registered",
                        "EoiInProgress",
                        "EoiSubmitted",
                        "EoiUnderReview",
                        "EoiChangesRequired",
                        "AssessmentInProgress",
                        "AssessmentSubmitted",
                        "AssessmentUnderReview",
                        "AssessmentChangesRequired",
                        "Approved",
                        "Unsuccessful",
                        "Inactive",
                        "InProgress",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "flagsVersion": {
                      "type": "integer"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/companies/{id}": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get a company",
        "description": "Company details and current compliance status.",
        "operationId": "GetCompany",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "maxLength": 200,
                      "type": "string"
                    },
                    "abn": {
                      "maxLength": 50,
                      "type": "string",
                      "nullable": true
                    },
                    "tradingName": {
                      "maxLength": 200,
                      "type": "string",
                      "nullable": true
                    },
                    "status": {
                      "enum": [
                        "Registered",
                        "EoiInProgress",
                        "EoiSubmitted",
                        "EoiUnderReview",
                        "EoiChangesRequired",
                        "AssessmentInProgress",
                        "AssessmentSubmitted",
                        "AssessmentUnderReview",
                        "AssessmentChangesRequired",
                        "Approved",
                        "Unsuccessful",
                        "Inactive",
                        "InProgress",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "flagsVersion": {
                      "type": "integer"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      },
      "put": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Update company details",
        "description": "Updates name, ABN and trading name. Compliance status is managed by the application workflow.",
        "operationId": "UpdateCompany",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              },
              "example": {
                "name": "Example Contractors",
                "abn": "12345678901",
                "tradingName": "Example"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              },
              "example": {
                "name": "Example Contractors",
                "abn": "12345678901",
                "tradingName": "Example"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              },
              "example": {
                "name": "Example Contractors",
                "abn": "12345678901",
                "tradingName": "Example"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "maxLength": 200,
                      "type": "string"
                    },
                    "abn": {
                      "maxLength": 50,
                      "type": "string",
                      "nullable": true
                    },
                    "tradingName": {
                      "maxLength": 200,
                      "type": "string",
                      "nullable": true
                    },
                    "status": {
                      "enum": [
                        "Registered",
                        "EoiInProgress",
                        "EoiSubmitted",
                        "EoiUnderReview",
                        "EoiChangesRequired",
                        "AssessmentInProgress",
                        "AssessmentSubmitted",
                        "AssessmentUnderReview",
                        "AssessmentChangesRequired",
                        "Approved",
                        "Unsuccessful",
                        "Inactive",
                        "InProgress",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "flagsVersion": {
                      "type": "integer"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/company-flags": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List available company flags",
        "description": "Tenant flag catalogue, including disabled definitions. Names are unique within the tenant.",
        "operationId": "FlagDefinitions",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      },
      "post": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Create a company flag",
        "description": "Create a named tenant flag for company selection.",
        "operationId": "CreateFlagDefinition",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlagDefinitionInput"
              },
              "example": {
                "name": "Available",
                "isActive": true
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/FlagDefinitionInput"
              },
              "example": {
                "name": "Available",
                "isActive": true
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/FlagDefinitionInput"
              },
              "example": {
                "name": "Available",
                "isActive": true
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "maxLength": 100,
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          },
          "409": {
            "description": "Application is not editable/reviewable, or submission validation failed."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/companies/{id}/flags": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get company flags",
        "description": "Selected flags and flagsVersion for optimistic updates.",
        "operationId": "CompanyFlags",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "flagsVersion": {
                      "type": "integer"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      },
      "put": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Replace company flags",
        "description": "Send flagIds as the complete selection; an empty list clears all flags. Optional version must match flagsVersion. Disabled flags can be retained or removed but cannot be newly assigned. Real changes create audit records and company.flags_changed webhooks; no-op updates do not.",
        "operationId": "SetCompanyFlags",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlagsInput"
              },
              "example": {
                "flagIds": [
                  "00000000-0000-0000-0000-000000000001"
                ],
                "version": 0
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/FlagsInput"
              },
              "example": {
                "flagIds": [
                  "00000000-0000-0000-0000-000000000001"
                ],
                "version": 0
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/FlagsInput"
              },
              "example": {
                "flagIds": [
                  "00000000-0000-0000-0000-000000000001"
                ],
                "version": 0
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "flagsVersion": {
                      "type": "integer"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          },
          "409": {
            "description": "Application is not editable/reviewable, or submission validation failed."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/company-flags/{id}": {
      "put": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Update a company flag",
        "description": "Rename or enable/disable a tenant flag. Disabled flags remain assigned to existing companies. Changes to assigned definitions trigger company.flags_changed events for affected companies.",
        "operationId": "UpdateFlagDefinition",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlagDefinitionInput"
              },
              "example": {
                "name": "Available",
                "isActive": true
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/FlagDefinitionInput"
              },
              "example": {
                "name": "Available",
                "isActive": true
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/FlagDefinitionInput"
              },
              "example": {
                "name": "Available",
                "isActive": true
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "maxLength": 100,
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          },
          "409": {
            "description": "Application is not editable/reviewable, or submission validation failed."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/tradespeople": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List tradespeople",
        "description": "Paginated tenant tradespeople.",
        "operationId": "GetTradespeople",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "firstName": {
                            "maxLength": 150,
                            "type": "string"
                          },
                          "lastName": {
                            "maxLength": 150,
                            "type": "string"
                          },
                          "email": {
                            "maxLength": 256,
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "complianceStatus": {
                            "enum": [
                              "Draft",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired",
                              "Approved",
                              "Unsuccessful"
                            ],
                            "type": "string"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      },
      "post": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Create a tradesperson",
        "description": "Creates a worker record without a login or company association.",
        "operationId": "CreateTradesperson",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TradespersonInput"
              },
              "example": {
                "firstName": "Alex",
                "lastName": "Smith",
                "email": "alex@example.com",
                "isActive": true
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TradespersonInput"
              },
              "example": {
                "firstName": "Alex",
                "lastName": "Smith",
                "email": "alex@example.com",
                "isActive": true
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TradespersonInput"
              },
              "example": {
                "firstName": "Alex",
                "lastName": "Smith",
                "email": "alex@example.com",
                "isActive": true
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "firstName": {
                      "maxLength": 150,
                      "type": "string"
                    },
                    "lastName": {
                      "maxLength": 150,
                      "type": "string"
                    },
                    "email": {
                      "maxLength": 256,
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "complianceStatus": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/tradespeople/{id}": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get a tradesperson",
        "description": "Worker identity, active flag and compliance status.",
        "operationId": "GetTradesperson",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "firstName": {
                      "maxLength": 150,
                      "type": "string"
                    },
                    "lastName": {
                      "maxLength": 150,
                      "type": "string"
                    },
                    "email": {
                      "maxLength": 256,
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "complianceStatus": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      },
      "put": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Update tradesperson details",
        "description": "Updates name, email and active flag.",
        "operationId": "UpdateTradesperson",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TradespersonInput"
              },
              "example": {
                "firstName": "Alex",
                "lastName": "Smith",
                "email": "alex@example.com",
                "isActive": true
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/TradespersonInput"
              },
              "example": {
                "firstName": "Alex",
                "lastName": "Smith",
                "email": "alex@example.com",
                "isActive": true
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/TradespersonInput"
              },
              "example": {
                "firstName": "Alex",
                "lastName": "Smith",
                "email": "alex@example.com",
                "isActive": true
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "firstName": {
                      "maxLength": 150,
                      "type": "string"
                    },
                    "lastName": {
                      "maxLength": 150,
                      "type": "string"
                    },
                    "email": {
                      "maxLength": 256,
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "complianceStatus": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/company-users": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List company users",
        "description": "Company membership, admin flags and user contact details.",
        "operationId": "CompanyUsers",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "companyId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "isCompanyAdmin": {
                            "type": "boolean"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/tradesperson-companies": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List tradesperson company associations",
        "description": "Tenant worker/company links and their active flags.",
        "operationId": "Associations",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "companyId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "tradespersonId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/users": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List tenant users",
        "description": "Tenant roles and contact details. Excludes platform administrators and identity credentials.",
        "operationId": "Users",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/invitations": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List invitations",
        "description": "Invitation metadata and expiry/acceptance timestamps. Invitation tokens are never returned.",
        "operationId": "Invitations",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "email": {
                            "maxLength": 256,
                            "type": "string"
                          },
                          "displayName": {
                            "maxLength": 200,
                            "type": "string",
                            "nullable": true
                          },
                          "role": {
                            "maxLength": 50,
                            "type": "string"
                          },
                          "companyId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "tradespersonId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "expiresUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "acceptedUtc": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/questionnaires": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List questionnaires",
        "description": "Questionnaire metadata and available version IDs.",
        "operationId": "Questionnaires",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 200,
                            "type": "string"
                          },
                          "stage": {
                            "enum": [
                              "EOI",
                              "Assessment",
                              "Tradesperson",
                              "Company"
                            ],
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "versions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "version": {
                                  "type": "integer"
                                },
                                "isPublished": {
                                  "type": "boolean"
                                },
                                "createdUtc": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/questionnaires/{id}": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get a questionnaire",
        "description": "Questionnaire metadata and its available versions. Use a version ID to retrieve questions.",
        "operationId": "Questionnaire",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "maxLength": 200,
                      "type": "string"
                    },
                    "stage": {
                      "enum": [
                        "EOI",
                        "Assessment",
                        "Tradesperson",
                        "Company"
                      ],
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "versions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "isPublished": {
                            "type": "boolean"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/questionnaire-versions/{id}": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get a questionnaire version",
        "description": "Ordered sections, questions, choices, help text and visibility rules, including inactive questions.",
        "operationId": "Version",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "questionnaireId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "isPublished": {
                      "type": "boolean"
                    },
                    "name": {
                      "type": "string"
                    },
                    "stage": {
                      "enum": [
                        "EOI",
                        "Assessment",
                        "Tradesperson",
                        "Company"
                      ],
                      "type": "string"
                    },
                    "sections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "title": {
                            "maxLength": 200,
                            "type": "string"
                          },
                          "sortOrder": {
                            "type": "integer"
                          },
                          "questions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "text": {
                                  "maxLength": 500,
                                  "type": "string"
                                },
                                "type": {
                                  "enum": [
                                    "Text",
                                    "MultilineText",
                                    "YesNo",
                                    "SingleChoice",
                                    "MultipleChoice",
                                    "Date",
                                    "Number",
                                    "Email",
                                    "Phone",
                                    "FileUpload",
                                    "Declaration",
                                    "Signature",
                                    "DocumentList",
                                    "TextBlock",
                                    "Dropdown",
                                    "Address",
                                    "PublicLiability"
                                  ],
                                  "type": "string"
                                },
                                "isRequired": {
                                  "type": "boolean"
                                },
                                "isActive": {
                                  "type": "boolean"
                                },
                                "sortOrder": {
                                  "type": "integer"
                                },
                                "helpText": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "visibilityQuestionId": {
                                  "type": "string",
                                  "format": "uuid",
                                  "nullable": true
                                },
                                "visibilityAction": {
                                  "enum": [
                                    "Show",
                                    "Hide"
                                  ],
                                  "type": "string"
                                },
                                "visibilityOperator": {
                                  "enum": [
                                    "Equals",
                                    "NotEquals",
                                    "Contains",
                                    "IsAnswered",
                                    "IsNotAnswered"
                                  ],
                                  "type": "string"
                                },
                                "visibilityValue": {
                                  "maxLength": 500,
                                  "type": "string",
                                  "nullable": true
                                },
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      "text": {
                                        "maxLength": 250,
                                        "type": "string"
                                      },
                                      "sortOrder": {
                                        "type": "integer"
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/applications": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List compliance applications",
        "description": "Filter by company, tradesperson, stage or status. For all questionnaires for a company, filter by companyId and retrieve each application's answers.",
        "operationId": "GetApplications",
        "parameters": [
          {
            "name": "companyId",
            "in": "query",
            "description": "Record ID belonging to this tenant.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tradespersonId",
            "in": "query",
            "description": "Record ID belonging to this tenant.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/ApplicationStage"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/SubmissionStatus"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          },
          {
            "name": "stageId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "companyId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "tradespersonId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "questionnaireVersionId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "stage": {
                            "enum": [
                              "EOI",
                              "Assessment",
                              "Tradesperson",
                              "Company"
                            ],
                            "type": "string"
                          },
                          "status": {
                            "enum": [
                              "Draft",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired",
                              "Approved",
                              "Unsuccessful"
                            ],
                            "type": "string"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "submittedUtc": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/applications/{id}": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get a compliance application",
        "description": "Application identity, exact questionnaire version, current status and timestamps.",
        "operationId": "Application",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "companyId": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    },
                    "tradespersonId": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    },
                    "questionnaireVersionId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "stage": {
                      "enum": [
                        "EOI",
                        "Assessment",
                        "Tradesperson",
                        "Company"
                      ],
                      "type": "string"
                    },
                    "status": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    },
                    "createdUtc": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "submittedUtc": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/applications/{id}/answers": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get questionnaire answers",
        "description": "Use the application.id from a webhook. Returns the exact questionnaire definition and every question with its raw saved value and timestamp. Unanswered values are null. Multiple-choice values use | separators. Includes inactive questions. Address questions also return a parsed address object.",
        "operationId": "Answers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "applicationId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "companyId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "tradespersonId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "stage": {
                      "enum": [
                        "EOI",
                        "Assessment",
                        "Tradesperson",
                        "Company"
                      ],
                      "type": "string"
                    },
                    "status": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    },
                    "questionnaire": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "questionnaireId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "version": {
                          "type": "integer"
                        },
                        "isPublished": {
                          "type": "boolean"
                        },
                        "name": {
                          "type": "string"
                        },
                        "stage": {
                          "enum": [
                            "EOI",
                            "Assessment",
                            "Tradesperson",
                            "Company"
                          ],
                          "type": "string"
                        },
                        "sections": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "title": {
                                "maxLength": 200,
                                "type": "string"
                              },
                              "sortOrder": {
                                "type": "integer"
                              },
                              "questions": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "text": {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    "type": {
                                      "enum": [
                                        "Text",
                                        "MultilineText",
                                        "YesNo",
                                        "SingleChoice",
                                        "MultipleChoice",
                                        "Date",
                                        "Number",
                                        "Email",
                                        "Phone",
                                        "FileUpload",
                                        "Declaration",
                                        "Signature",
                                        "DocumentList",
                                        "TextBlock",
                                        "Dropdown",
                                        "Address",
                                        "PublicLiability"
                                      ],
                                      "type": "string"
                                    },
                                    "isRequired": {
                                      "type": "boolean"
                                    },
                                    "isActive": {
                                      "type": "boolean"
                                    },
                                    "sortOrder": {
                                      "type": "integer"
                                    },
                                    "helpText": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "visibilityQuestionId": {
                                      "type": "string",
                                      "format": "uuid",
                                      "nullable": true
                                    },
                                    "visibilityAction": {
                                      "enum": [
                                        "Show",
                                        "Hide"
                                      ],
                                      "type": "string"
                                    },
                                    "visibilityOperator": {
                                      "enum": [
                                        "Equals",
                                        "NotEquals",
                                        "Contains",
                                        "IsAnswered",
                                        "IsNotAnswered"
                                      ],
                                      "type": "string"
                                    },
                                    "visibilityValue": {
                                      "maxLength": 500,
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "options": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "format": "uuid"
                                          },
                                          "text": {
                                            "maxLength": 250,
                                            "type": "string"
                                          },
                                          "sortOrder": {
                                            "type": "integer"
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "answers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "sectionId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "section": {
                            "type": "string"
                          },
                          "questionId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "question": {
                            "type": "string"
                          },
                          "type": {
                            "enum": [
                              "Text",
                              "MultilineText",
                              "YesNo",
                              "SingleChoice",
                              "MultipleChoice",
                              "Date",
                              "Number",
                              "Email",
                              "Phone",
                              "FileUpload",
                              "Declaration",
                              "Signature",
                              "DocumentList",
                              "TextBlock",
                              "Dropdown",
                              "Address",
                              "PublicLiability"
                            ],
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "value": {
                            "type": "string"
                          },
                          "updatedUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "address": {
                            "type": "object",
                            "properties": {
                              "flatNumber": {
                                "type": "string",
                                "nullable": true
                              },
                              "levelNumber": {
                                "type": "string",
                                "nullable": true
                              },
                              "streetNumber": {
                                "type": "string",
                                "nullable": true
                              },
                              "streetName": {
                                "type": "string",
                                "nullable": true
                              },
                              "streetType": {
                                "type": "string",
                                "nullable": true
                              },
                              "suburb": {
                                "type": "string",
                                "nullable": true
                              },
                              "state": {
                                "type": "string",
                                "nullable": true
                              },
                              "postcode": {
                                "type": "string",
                                "nullable": true
                              },
                              "gnafId": {
                                "type": "string",
                                "nullable": true
                              },
                              "gnafRelease": {
                                "type": "string",
                                "nullable": true
                              }
                            },
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/applications/{id}/answers/{questionId}": {
      "put": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Save a questionnaire answer",
        "description": "Draft or ChangesRequired applications only. Question must be active and belong to the application's version. Files and signatures use the portal flow; informational blocks cannot be answered. Submission validates values and required answers. Address values are JSON-encoded objects with flatNumber, levelNumber, streetNumber, streetName, streetType, suburb, state and postcode; postcode must remain a string.",
        "operationId": "SaveAnswer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "questionId",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnswerInput"
              },
              "example": {
                "value": "Yes"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AnswerInput"
              },
              "example": {
                "value": "Yes"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AnswerInput"
              },
              "example": {
                "value": "Yes"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "questionId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "value": {
                      "type": "string",
                      "nullable": true
                    },
                    "updatedUtc": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          },
          "409": {
            "description": "Application is not editable/reviewable, or submission validation failed."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/applications/{id}/submit": {
      "post": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Submit an application",
        "description": "Runs existing required-answer and type validation, updates status, and triggers audit, notifications and webhooks. Body is not required.",
        "operationId": "Submit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          },
          "409": {
            "description": "Application is not editable/reviewable, or submission validation failed."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/applications/{id}/decision": {
      "post": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Record a review decision",
        "description": "Submitted or UnderReview applications only. Decision must be Approved, ChangesRequired or Unsuccessful. reviewerUserId must be an active tenant ComplianceAdmin or ComplianceReviewer. The key authenticates the caller; reviewerUserId records attribution. Runs existing outcome notifications and webhooks.",
        "operationId": "Decision",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionInput"
              },
              "example": {
                "decision": "Approved",
                "reviewerUserId": "active-tenant-compliance-user-id",
                "comments": "Requirements satisfied."
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionInput"
              },
              "example": {
                "decision": "Approved",
                "reviewerUserId": "active-tenant-compliance-user-id",
                "comments": "Requirements satisfied."
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/DecisionInput"
              },
              "example": {
                "decision": "Approved",
                "reviewerUserId": "active-tenant-compliance-user-id",
                "comments": "Requirements satisfied."
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "enum": [
                        "Draft",
                        "Submitted",
                        "UnderReview",
                        "ChangesRequired",
                        "Approved",
                        "Unsuccessful"
                      ],
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          },
          "409": {
            "description": "Application is not editable/reviewable, or submission validation failed."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/evidence": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List evidence files",
        "description": "File metadata; optionally filter by applicationId. Stored filesystem paths are never returned.",
        "operationId": "Evidence",
        "parameters": [
          {
            "name": "applicationId",
            "in": "query",
            "description": "Record ID belonging to this tenant.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "complianceApplicationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "questionId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "originalFileName": {
                            "maxLength": 260,
                            "type": "string"
                          },
                          "contentType": {
                            "maxLength": 150,
                            "type": "string"
                          },
                          "length": {
                            "type": "integer"
                          },
                          "uploadedUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "expiryDate": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/evidence/{id}/download": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Download an evidence file",
        "description": "Downloads tenant-scoped evidence as an attachment.",
        "operationId": "Download",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Record ID belonging to this tenant.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "404": {
            "description": "Record not found in this tenant, or the evidence file is unavailable."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/reviews": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List application reviews",
        "description": "Review history, optionally filtered by applicationId.",
        "operationId": "Reviews",
        "parameters": [
          {
            "name": "applicationId",
            "in": "query",
            "description": "Record ID belonging to this tenant.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "complianceApplicationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "reviewerUserId": {
                            "type": "string"
                          },
                          "decision": {
                            "enum": [
                              "Draft",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired",
                              "Approved",
                              "Unsuccessful"
                            ],
                            "type": "string"
                          },
                          "comments": {
                            "type": "string",
                            "nullable": true
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/webhooks": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List webhook subscriptions",
        "description": "Subscription metadata and filters. Signing secrets are never returned.",
        "operationId": "Webhooks",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "maxLength": 150,
                            "type": "string"
                          },
                          "url": {
                            "maxLength": 2000,
                            "type": "string"
                          },
                          "eventType": {
                            "enum": [
                              "ApplicationStatusChanged",
                              "CompanyFlagsChanged"
                            ],
                            "type": "string"
                          },
                          "stage": {
                            "enum": [
                              "EOI",
                              "Assessment",
                              "Tradesperson",
                              "Company"
                            ],
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "enum": [
                              "Draft",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired",
                              "Approved",
                              "Unsuccessful"
                            ],
                            "type": "string",
                            "nullable": true
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/webhook-deliveries": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List webhook deliveries",
        "description": "Newest deliveries first, with application IDs and delivery outcomes.",
        "operationId": "Deliveries",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "webhookSubscriptionId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "eventId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "eventType": {
                            "enum": [
                              "ApplicationStatusChanged",
                              "CompanyFlagsChanged"
                            ],
                            "type": "string"
                          },
                          "companyId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "applicationId": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "stage": {
                            "enum": [
                              "EOI",
                              "Assessment",
                              "Tradesperson",
                              "Company"
                            ],
                            "type": "string",
                            "nullable": true
                          },
                          "previousStatus": {
                            "enum": [
                              "Draft",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired",
                              "Approved",
                              "Unsuccessful"
                            ],
                            "type": "string",
                            "nullable": true
                          },
                          "currentStatus": {
                            "enum": [
                              "Draft",
                              "Submitted",
                              "UnderReview",
                              "ChangesRequired",
                              "Approved",
                              "Unsuccessful"
                            ],
                            "type": "string",
                            "nullable": true
                          },
                          "attemptedUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "succeeded": {
                            "type": "boolean"
                          },
                          "httpStatusCode": {
                            "type": "integer",
                            "nullable": true
                          },
                          "error": {
                            "maxLength": 2000,
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/audit-events": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List audit events",
        "description": "Newest tenant audit events first.",
        "operationId": "Audit",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "userId": {
                            "type": "string",
                            "nullable": true
                          },
                          "eventType": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "entityType": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "entityId": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "detail": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/notifications": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List portal notifications",
        "description": "Newest tenant notifications first.",
        "operationId": "Notifications",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "title": {
                            "maxLength": 200,
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "link": {
                            "maxLength": 300,
                            "type": "string",
                            "nullable": true
                          },
                          "isRead": {
                            "type": "boolean"
                          },
                          "createdUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/email-templates": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List tenant email templates",
        "description": "Stored tenant template overrides, including plain text and HTML bodies.",
        "operationId": "Templates",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "templateKey": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "subject": {
                            "maxLength": 300,
                            "type": "string"
                          },
                          "body": {
                            "type": "string"
                          },
                          "htmlBody": {
                            "type": "string",
                            "nullable": true
                          },
                          "includeSignature": {
                            "type": "boolean"
                          },
                          "updatedUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/billing": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "List tenant billing records",
        "description": "Recorded billing months, newest first. Does not capture new usage or create an invoice.",
        "operationId": "Billing",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number, from 1 to 1000000.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Items per page, from 1 to 200. Default 50.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "pageSize": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "month": {
                            "type": "string",
                            "format": "date"
                          },
                          "invoiceNumber": {
                            "type": "integer"
                          },
                          "peakWorkers": {
                            "type": "integer"
                          },
                          "planName": {
                            "maxLength": 50,
                            "type": "string"
                          },
                          "amount": {
                            "type": "number",
                            "nullable": true
                          },
                          "firstCapturedUtc": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "lastCapturedUtc": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    },
    "/api/v1/reports/document-expiry": {
      "get": {
        "tags": [
          "TenantApi"
        ],
        "summary": "Get document expiry report",
        "description": "Current/latest evidence per question expiring within the selected horizon, including expired documents. Optional companyId and tradespersonId filters. This report is an unpaginated array.",
        "operationId": "Expiry",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "description": "Expiry horizon in days, clamped to 1–365. Includes already expired documents.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "format": "int32",
              "default": 90
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "description": "Record ID belonging to this tenant.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tradespersonId",
            "in": "query",
            "description": "Record ID belonging to this tenant.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "companyId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "company": {
                        "type": "string"
                      },
                      "ownerType": {
                        "type": "string"
                      },
                      "tradesperson": {
                        "type": "string",
                        "nullable": true
                      },
                      "document": {
                        "type": "string"
                      },
                      "fileName": {
                        "type": "string"
                      },
                      "stage": {
                        "type": "string"
                      },
                      "applicationStatus": {
                        "type": "string"
                      },
                      "expiryDate": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "daysRemaining": {
                        "type": "integer"
                      },
                      "expiryStatus": {
                        "type": "string"
                      },
                      "cells": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, incorrect, revoked, rotated or other-tenant API key."
          },
          "400": {
            "description": "Invalid request body, query parameters or reviewer."
          }
        },
        "security": [
          {
            "TenantApiKey": [ ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AnswerInput": {
        "required": [
          "value"
        ],
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ApplicationStage": {
        "type": "integer"
      },
      "CompanyInput": {
        "required": [
          "name",
          "abn",
          "tradingName"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "abn": {
            "type": "string",
            "nullable": true
          },
          "tradingName": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "DecisionInput": {
        "required": [
          "decision",
          "reviewerUserId",
          "comments"
        ],
        "type": "object",
        "properties": {
          "decision": {
            "$ref": "#/components/schemas/SubmissionStatus"
          },
          "reviewerUserId": {
            "type": "string"
          },
          "comments": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "FlagDefinitionInput": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "FlagsInput": {
        "required": [
          "flagIds"
        ],
        "type": "object",
        "properties": {
          "flagIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "version": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "format": "int32",
            "nullable": true
          }
        }
      },
      "SubmissionStatus": {
        "type": "integer"
      },
      "TradespersonInput": {
        "required": [
          "firstName",
          "lastName",
          "email"
        ],
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean",
            "default": true
          }
        }
      }
    },
    "securitySchemes": {
      "TenantApiKey": {
        "type": "apiKey",
        "description": "Tenant API key from Administration → Tenant API. Browser login alone does not authorize API calls.",
        "name": "X-API-Key",
        "in": "header"
      }
    }
  },
  "tags": [
    {
      "name": "TenantApi"
    }
  ]
}