{
  "openapi": "3.0.3",
  "info": {
    "title": "PatrolTech Public API",
    "version": "2.2.0",
    "description": "Public subset of the PatrolTech API. Breaking changes require a major version bump.\n\n2.0.0: the request property `whatsappPhone` of `PATCH /api/auth/user/preferences` is\ndeclared as what the API has always accepted (a string of 1 to 20 characters, or null);\nit was declared as any value. Nullable response fields that hold a schema reference\n(`pricing`, `usage`) are declared as `anyOf` plus `nullable`.\n\nResponse envelope for `/api/*`: every JSON response is wrapped as\n`{ success, message, data, meta? }`. The 2xx schemas below describe `data`.\nErrors arrive as `{ success: false, message, data: null, meta }`, with the details\n(`errorCode`, `code`...) in `meta` unless the handler emitted the envelope itself.\n`/oauth/*` and `/.well-known/*` follow the OAuth RFCs: plain JSON, no envelope.\n\nResponses any `/api/*` operation can return, not repeated in each operation:\n- 401: the operation needs a bearer token and it is missing, malformed, invalid\n  (`meta.code: INVALID_TOKEN`), expired (`meta.code: TOKEN_EXPIRED`) or of a deleted\n  account (`meta.errorCode: ACCOUNT_DELETED`). Get a new token and retry.\n- 423: the organization the request targets (or all of the user’s organizations) is\n  suspended. The body is the envelope with `data: { code: ORGANIZATION_SUSPENDED,\n  organizationId, reason, scope, effectiveAt }`. Billing and account endpoints stay open.\n- 451: on a write (POST, PUT, PATCH, DELETE), the user has policies pending acceptance;\n  `meta.pending` lists them. Accept them in the dashboard and retry.\n- 429: too many requests for that endpoint. Wait and retry.\n- 500: unexpected server error. 502: a provider the operation depends on (payments)\n  failed; the operations where it can happen document it.\n\nWebhooks are in development. Tell us which events you need at info@patroltech.app;\nmeanwhile, poll the list endpoints.",
    "contact": {
      "name": "PatrolTech",
      "email": "info@patroltech.app",
      "url": "https://patroltech.online"
    },
    "license": {
      "name": "MIT",
      "url": "https://github.com/PatrolTech/sdk-api/blob/main/LICENSE"
    }
  },
  "externalDocs": {
    "description": "API reference",
    "url": "https://patroltech.github.io/sdk-api/"
  },
  "servers": [
    {
      "url": "https://api.patroltech.online"
    }
  ],
  "paths": {
    "/api/routes": {
      "get": {
        "operationId": "listRoutes",
        "summary": "List routes by organization",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "organizationId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "query",
            "name": "locationId",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "includeArchived",
            "required": false,
            "description": "`true` also lists the archived routes. By default they are left out.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated routes list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRoutesList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Without `locationId`: no organization-wide role (a user whose only role is on a location must send `locationId`). With `locationId`: no role on that location (nor in its organization), or the location does not belong to `organizationId`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Location not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/routes/{routeId}/checkpoints/{checkpointId}": {
      "post": {
        "operationId": "addCheckpointToRoute",
        "summary": "Add checkpoint to route",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "routeId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "checkpointId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddCheckpointToRouteBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Checkpoint added to route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRouteCheckpoint"
                }
              }
            }
          },
          "400": {
            "description": "`code: CHECKPOINT_NOT_IN_ROUTE_LOCATION`: the checkpoint is not on the route's location (or does not exist). `code: CHECKPOINT_ARCHIVED` (`data.checkpointIds`): the checkpoint is archived."
          }
        }
      },
      "delete": {
        "operationId": "removeCheckpointFromRoute",
        "summary": "Remove checkpoint from route",
        "description": "The rounds in progress on the route are cancelled. Removing its last checkpoint deactivates the route (`isActive: false`): an empty route cannot be patrolled. Adding checkpoints back does not reactivate it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "routeId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "checkpointId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Checkpoint removed from route"
          }
        }
      }
    },
    "/api/routes/{routeId}/timewindows": {
      "post": {
        "operationId": "addTimeWindowToRoute",
        "summary": "Add time window to route",
        "description": "**TIMEZONE CONTRACT**: `startTime`/`endTime` are UTC `HH:MM` and `days`\nare ISO weekdays in UTC. The client converts local time → UTC before\nsending; the backend never converts them.\n\nSend `timezone` (IANA, e.g. \"Europe/Madrid\") with the zone the times\nwere converted from: the backend stores it with the current UTC offset\nand re-projects the UTC times at every DST change so the window keeps\nits local time. Without it the window is never realigned. If the route\nalready has a stored zone, that one wins and the window's `timezone` is\nignored.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "routeId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddTimeWindowBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Time window added to route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRouteTimeWindow"
                }
              }
            }
          },
          "400": {
            "description": "The new window overlaps one the route already has: `code` is `TIME_WINDOWS_OVERLAP` and `data.windows` carries both conflicting windows (UTC). Also returned when `timezone` is not a valid IANA zone, as a plain error whose `message` is `Invalid timezone: <zone>` (no `code`). Nothing is created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeWindowsOverlapResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/routes/timewindows/{timeWindowId}": {
      "delete": {
        "operationId": "removeTimeWindowFromRoute",
        "summary": "Remove time window from route",
        "description": "Needs EDITOR on the route's location (or in its organization). A route with a location also needs its organization linked to that location as `owner` or `provider`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "timeWindowId",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Time window removed from route"
          },
          "403": {
            "description": "No EDITOR role on the route's location (nor in its organization), the route's organization is not linked to its location as `owner` or `provider`, or `meta.errorCode: AGENT_WRITE_NOT_ALLOWED`: an AI agent session (a token from `/oauth/agent-session`) never makes this write, even with the write scope"
          },
          "404": {
            "description": "Time window not found, or its route no longer exists"
          }
        }
      }
    },
    "/api/routes/{id}/details": {
      "get": {
        "operationId": "getRouteWithDetails",
        "summary": "Get route with checkpoints and time windows",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Route details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRouteWithDetails"
                }
              }
            }
          },
          "404": {
            "description": "Route not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/routes/complete": {
      "post": {
        "operationId": "createRouteComplete",
        "summary": "Create route with checkpoints and time windows",
        "description": "Created active when it has checkpoints; without them (`checkpoints` empty or omitted) it is created inactive, whatever the body says: a route without checkpoints cannot be active.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RouteFormBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Route created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRouteWithDetails"
                }
              }
            }
          },
          "400": {
            "description": "Two of the submitted time windows overlap. Nothing is created; `data.windows` carries both conflicting windows (UTC). Also returned, with `code: CHECKPOINT_NOT_IN_ROUTE_LOCATION` and `data: null`, when a checkpoint is not on the route's location, and with `code: CHECKPOINT_ARCHIVED` and `data.checkpointIds` when a checkpoint is archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeWindowsOverlapResponse"
                }
              }
            }
          },
          "409": {
            "description": "`code: LOCATION_ARCHIVED`: the location is archived. Nothing is created; restore the location first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RouteArchiveConflict"
                }
              }
            }
          }
        }
      }
    },
    "/api/routes/{routeId}/rounds": {
      "get": {
        "operationId": "getRouteRounds",
        "summary": "Get route rounds with pagination",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "routeId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Route rounds page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRouteRounds"
                }
              }
            }
          }
        }
      }
    },
    "/api/routes/{routeId}/rounds/{roundId}/checkpoints": {
      "get": {
        "operationId": "getRouteRoundCheckpoints",
        "summary": "Get the per-checkpoint scan breakdown for a route round",
        "description": "Lists every checkpoint of the route (in route order) and whether it\nwas scanned during this specific round, with the scan time when it\nwas. Checkpoints are matched to scans by their POSITION in the route\n(`order`), not by checkpoint id — a checkpoint can occupy more than\none slot in an ordered route.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "routeId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "roundId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Per-checkpoint round breakdown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRouteRoundCheckpoints"
                }
              }
            }
          },
          "404": {
            "description": "Round or route not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/routes/{id}/active": {
      "patch": {
        "operationId": "toggleRouteActive",
        "summary": "Toggle route active state",
        "description": "A route without checkpoints cannot be activated (400 `ROUTE_HAS_NO_CHECKPOINTS`), nor an archived one (409 `ROUTE_ARCHIVED`: unarchive it first); deactivating it is always allowed.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToggleRouteActiveBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Route updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiSuccessRoute"
                }
              }
            }
          },
          "400": {
            "description": "`code: ROUTE_HAS_NO_CHECKPOINTS`: the route has no checkpoints and cannot be activated. Nothing is changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Route not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "`code: ROUTE_ARCHIVED`: the route is archived and cannot be activated. Nothing is changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RouteArchiveConflict"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent-proposals/batches": {
      "post": {
        "operationId": "proposeAgentActions",
        "summary": "Propose a batch of write actions awaiting confirmation",
        "description": "In one transaction it withdraws the still-`proposed` proposals of this user and contextKey (`expired` if they had already expired, `cancelled` if not) and stores the new batch with a new `batchId`, positions 0..n-1 and expiry now + ttlMin. A live proposal that the new batch repeats unchanged (same action, params, organization and idempotency key) is carried over: its copy in the new batch replaces it instead of it being cancelled, so a client that re-sends its pending batch plus one more action does not spend the daily quota twice. With a suspended organization the proposal is accepted (the user belongs to it); when it is executed, the real endpoint will answer 423. Proposals are scoped by the user and, for an agent token, by its OAuth client: another client of the same user never sees them. If the token's user no longer exists the answer is 401 with `meta.errorCode: USER_NOT_FOUND`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProposeAgentActionsBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The stored batch, in the proposed order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentProposal"
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST: invalid body (more than 10 actions, ttlMin outside 1..60, contextKey ending in whitespace…); or PARAMS_TOO_LARGE: the params of an action are over 16384 bytes. Nothing is stored"
          },
          "403": {
            "description": "ORGANIZATION_NOT_ALLOWED: the user does not belong to the organization of an action; nothing is stored. Or USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one); or insufficient_scope: an agent token with only the read scope cannot write"
          },
          "429": {
            "description": "RATE_LIMITED: more than 30 batches per minute from this user; or PROPOSAL_QUOTA_EXCEEDED: they already created 300 proposals in the last 24 hours (carried-over copies are not counted twice). Nothing is stored"
          }
        }
      }
    },
    "/api/agent-proposals/batches/{batchId}": {
      "get": {
        "operationId": "getAgentProposalBatch",
        "summary": "The actions of a batch, in the order they were proposed",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "batchId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300,
              "pattern": "\\S$",
              "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace."
            },
            "required": true,
            "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace.",
            "name": "contextKey",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "The actions of the batch of this user and contextKey; empty if there are none (also when batchId is not a UUID)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentProposal"
                  }
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST: contextKey is missing or invalid"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one)"
          }
        }
      }
    },
    "/api/agent-proposals/live": {
      "get": {
        "operationId": "getLiveAgentProposal",
        "summary": "The first still-proposed action of the latest live batch of the contextKey",
        "description": "It is returned even if it has already expired: the caller decides what to say.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300,
              "pattern": "\\S$",
              "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace."
            },
            "required": true,
            "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace.",
            "name": "contextKey",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "The action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProposal"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST: contextKey is missing or invalid"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one)"
          },
          "404": {
            "description": "NO_LIVE_PROPOSAL: no action of this contextKey is still proposed"
          }
        }
      }
    },
    "/api/agent-proposals/executed-recently": {
      "get": {
        "operationId": "agentProposalExecutedRecently",
        "summary": "Was any action of this contextKey executed in the last few minutes?",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300,
              "pattern": "\\S$",
              "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace."
            },
            "required": true,
            "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace.",
            "name": "contextKey",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1440,
              "description": "Minutes: integer between 1 and 1440."
            },
            "required": true,
            "description": "Minutes: integer between 1 and 1440.",
            "name": "withinMin",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Yes or no",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProposalExecutedRecently"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST: contextKey is missing or invalid, or withinMin is not an integer between 1 and 1440"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one)"
          }
        }
      }
    },
    "/api/agent-proposals/{id}": {
      "get": {
        "operationId": "getAgentProposal",
        "summary": "A proposal of the user",
        "description": "The id is case-insensitive.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The proposal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProposal"
                }
              }
            }
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one)"
          },
          "404": {
            "description": "PROPOSAL_NOT_FOUND: it does not exist, the id is not a UUID, or it belongs to another user or OAuth client: the same answer for all"
          }
        }
      }
    },
    "/api/agent-proposals/{id}/claim": {
      "post": {
        "operationId": "claimAgentProposal",
        "summary": "Claim a proposal to execute it (proposed → executing, atomic)",
        "description": "Of two simultaneous claims only one receives 200. An expired proposal that nobody had touched is marked `expired` here.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClaimAgentProposalBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Claimed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProposal"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST: contextKey is missing or invalid"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one); or insufficient_scope: an agent token with only the read scope cannot write"
          },
          "404": {
            "description": "PROPOSAL_NOT_FOUND: it does not exist for this user, OAuth client and contextKey (or the id is not a UUID)"
          },
          "409": {
            "description": "PROPOSAL_NOT_CLAIMABLE: already claimed, done, withdrawn or expired; data.status is the current status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProposalNotClaimable"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent-proposals/{id}/executed": {
      "post": {
        "operationId": "markAgentProposalExecuted",
        "summary": "Mark a claimed proposal as executed, with its result",
        "description": "The action has already run, so the row always becomes `executed`, whatever the size of the result: a result over 16384 bytes is stored truncated as `{ truncated: true, preview }`, and a body over the HTTP limit (1 MB) as `{ truncated: true, preview: \"\", reason: \"request_body_too_large\" }`. It is never left `executing` (it could be reopened and executed twice). This is bookkeeping on the caller's own row, so it is exempt from the 423 and 451 walls. An `executing` action that nobody closes within an hour is closed automatically as `failed` with error `stale_executing`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkAgentProposalExecutedBody"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Marked"
          },
          "400": {
            "description": "INVALID_REQUEST: invalid body"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one); or insufficient_scope: an agent token with only the read scope cannot write"
          },
          "404": {
            "description": "PROPOSAL_NOT_FOUND: the id is not a UUID"
          },
          "409": {
            "description": "PROPOSAL_NOT_EXECUTING: it is not `executing`, or it is not a proposal of this user and OAuth client: it is only closed from executing"
          }
        }
      }
    },
    "/api/agent-proposals/{id}/failed": {
      "post": {
        "operationId": "markAgentProposalFailed",
        "summary": "Mark a claimed proposal as failed, with its error",
        "description": "Bookkeeping on the caller's own row, so it is exempt from the 423 and 451 walls. A body over the HTTP limit (1 MB) closes it as `failed` with error \"request body too large\".",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkAgentProposalFailedBody"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Marked"
          },
          "400": {
            "description": "INVALID_REQUEST: the error field is missing or not a string"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one); or insufficient_scope: an agent token with only the read scope cannot write"
          },
          "404": {
            "description": "PROPOSAL_NOT_FOUND: the id is not a UUID"
          },
          "409": {
            "description": "PROPOSAL_NOT_EXECUTING: it is not `executing`, or it is not a proposal of this user and OAuth client: it is only closed from executing"
          }
        }
      }
    },
    "/api/agent-proposals/reopen": {
      "post": {
        "operationId": "reopenAgentProposals",
        "summary": "Leave as proposals again the actions that have not been done yet",
        "description": "The user's actions that are `proposed`, or `executing` and claimed less than an hour ago, and belong to the latest batch of their contextKey go back to `proposed` with a renewed expiry. The rest are not touched: finished ones, ones from a batch older than the latest proposed, `executing` ones claimed over an hour ago (they may have run: they are closed as `failed` instead) and ids of another user or OAuth client. If the token's user no longer exists the answer is 401 with `meta.errorCode: USER_NOT_FOUND`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReopenAgentProposalsBody"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "INVALID_REQUEST: no ids, more than 10 ids, an id that is not a UUID, or ttlMin outside 1..60"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one); or insufficient_scope: an agent token with only the read scope cannot write"
          }
        }
      }
    },
    "/api/agent-proposals/cancel": {
      "post": {
        "operationId": "cancelAgentProposals",
        "summary": "Withdraw the whole live batch of the contextKey",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelAgentProposalsBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One of the withdrawn ones, with its final status (cancelled, or expired if it came late)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProposal"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST: contextKey is missing or invalid"
          },
          "403": {
            "description": "USER_SESSION_REQUIRED: the token is not a user session (for instance, a patroller one); or insufficient_scope: an agent token with only the read scope cannot write"
          },
          "404": {
            "description": "NO_LIVE_PROPOSAL: no action of this contextKey is still proposed"
          }
        }
      }
    },
    "/api/auth/user/preferences": {
      "get": {
        "operationId": "getUserPreferences",
        "summary": "Get user preferences",
        "description": "The caller's own language, timezone and notification preferences. Change them with `updateUserPreferences`. A token that is not a user session (for instance, a patroller one) has no preferences: 404.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "User preferences",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserPreferencesResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateUserPreferences",
        "summary": "Update user preferences",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePreferencesBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preferences updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdatePreferencesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid language code"
          },
          "403": {
            "description": "meta.errorCode AGENT_CANNOT_CHANGE_IDENTITY: an AI agent session (a token from `/oauth/agent-session`) does not change the account's phones (phone, whatsappPhone); only the user's own session does. Nothing was changed (only when the body carries whatsappPhone)"
          }
        }
      }
    },
    "/api/user-roles/{userRoleId}": {
      "put": {
        "operationId": "updateUserRole",
        "summary": "Update the role type of an existing user role",
        "description": "Needs an organization-wide ADMIN role in the organization the role belongs to (for a location role, the organization of that location). Promoting a VIEWER to EDITOR or ADMIN takes a manager seat and goes through the plan limit (402).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "userRoleId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateUserRoleBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserRoleResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid role type"
          },
          "402": {
            "description": "`code: USER_LIMIT_REACHED`: promoting a VIEWER to EDITOR or ADMIN would exceed the plan's `max_users`. The body carries `limit`, `currentUsage` and `upsell`. Nothing changes."
          },
          "403": {
            "description": "Not an ADMIN of the organization, or meta.errorCode AGENT_CANNOT_GRANT_ACCESS: an AI agent session (a token from `/oauth/agent-session`) never gives or changes a role, even with the write scope. Also when the role does not exist and the body does not name its organization (`Organization could not be resolved`): its organization cannot be resolved, so it is refused before looking further."
          },
          "404": {
            "description": "User role not found (only reachable when the body carries an `organizationId` the caller administers)"
          }
        }
      },
      "delete": {
        "operationId": "deleteUserRole",
        "summary": "Remove a role from a user",
        "description": "Needs an organization-wide ADMIN role in the organization the role belongs to (for a location role, the organization of that location).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "userRoleId",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Role removed"
          },
          "403": {
            "description": "Not an ADMIN of the organization, the role does not exist (its organization cannot be resolved: `Organization could not be resolved`), or `meta.errorCode: AGENT_WRITE_NOT_ALLOWED`: an AI agent session (a token from `/oauth/agent-session`) never makes this write, even with the write scope"
          },
          "404": {
            "description": "User role not found (only reachable when the body carries an `organizationId` the caller administers)"
          }
        }
      }
    },
    "/api/organizations/list": {
      "get": {
        "operationId": "listOrganizations",
        "summary": "List organizations the authenticated user has access to",
        "description": "The organizations where the caller has a role (VIEWER or above), either on the organization or on one of its non-archived locations. Empty when there are none.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Organization map, keyed by organization id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListOrganizationsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/organizations/users": {
      "get": {
        "operationId": "getOrganizationUsers",
        "summary": "List users in an organization",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "organizationId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Users retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrgUsersResponse"
                }
              }
            }
          },
          "403": {
            "description": "No access to this organization"
          }
        }
      },
      "post": {
        "operationId": "createOrganizationUser",
        "summary": "Create a user and assign them to an organization",
        "description": "Needs an organization-wide ADMIN role in `organizationId`. A new email creates the account and sends it an invitation to set its password; an existing one only gets the role (and a notification). An EDITOR or ADMIN role takes a manager seat and goes through the plan limit (402); VIEWER never does.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrgUserBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role assigned to an existing user",
            "content": {
              "application/json": {
                "schema": {
                  "nullable": true,
                  "description": "Always null: the user is not returned. `meta.emailSent` (only for a new account) says whether the invitation email went out."
                }
              }
            }
          },
          "201": {
            "description": "User created and role assigned",
            "content": {
              "application/json": {
                "schema": {
                  "nullable": true,
                  "description": "Always null: the user is not returned. `meta.emailSent` (only for a new account) says whether the invitation email went out."
                }
              }
            }
          },
          "400": {
            "description": "Missing email, LOCATION role without locationId, or the person already has a role on that scope (or the new account is invalid, e.g. without `name`)"
          },
          "402": {
            "description": "`code: USER_LIMIT_REACHED`: an EDITOR or ADMIN role would exceed the plan's `max_users`. The body carries `limit`, `currentUsage` and `upsell`. Nothing is created."
          },
          "403": {
            "description": "Not an ADMIN of the organization (also without `organizationId`: `Organization could not be resolved`), or locationId is not a location of this organization, or meta.errorCode AGENT_CANNOT_GRANT_ACCESS: an AI agent session (a token from `/oauth/agent-session`) never invites or assigns anyone, even with the write scope"
          },
          "409": {
            "description": "meta.errorCode ACCOUNT_DELETED: the email belongs to a deleted account. The role is not assigned; the person has to contact support to recover it."
          }
        }
      }
    },
    "/api/organizations/{organizationId}/support-summary": {
      "get": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "operationId": "getOrganizationSupportSummary",
        "summary": "Org-scoped support summary: rounds by status in a window, patroller headcount, checkpoint count and suspicious scans",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "organizationId",
            "in": "path"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "exclusiveMinimum": true,
              "maximum": 365
            },
            "required": false,
            "name": "windowDays",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Aggregated support summary for the organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportSummary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid windowDays"
          },
          "401": {
            "description": "Missing or invalid JWT"
          },
          "403": {
            "description": "No VIEWER access to this organization"
          }
        }
      }
    },
    "/api/checkpoints": {
      "get": {
        "operationId": "listCheckpoints",
        "summary": "List checkpoints for a location",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "qr_static",
                "nfc_uid",
                "manual_code",
                "geofence",
                "nfc_sun",
                "nfc_url_signed",
                "ble_beacon",
                "iot_button",
                "photo_evidence",
                "qr_dynamic"
              ]
            },
            "required": false,
            "name": "methodType",
            "in": "query"
          },
          {
            "schema": {
              "type": "boolean",
              "nullable": true
            },
            "required": false,
            "name": "includeArchived",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Checkpoints retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListCheckpointsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Location ID is required"
          }
        }
      },
      "post": {
        "operationId": "createCheckpoint",
        "summary": "Create a checkpoint",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCheckpointBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Checkpoint created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckpointResponse"
                }
              }
            }
          },
          "400": {
            "description": "VERIFICATION_TYPE_RETIRED: the inline method is `manual_code`, which can no longer be created. Also VALIDATION_ERROR for a malformed body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationTypeRetired"
                }
              }
            }
          },
          "409": {
            "description": "VERIFICATION_CODE_TAKEN: the chosen code is already used by a live checkpoint of the organization (body below). Also EXTRA_CHECKPOINT_CONFIRMATION_REQUIRED on paid plans when the checkpoint adds a charge that needs confirming (`confirmExtraBilling`). LOCATION_ARCHIVED when its location is archived: nothing is created.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/VerificationCodeTaken"
                    },
                    {
                      "$ref": "#/components/schemas/CheckpointLocationArchivedConflict"
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Invalid verificationMethod config for its type (e.g. a qr_static code over 1000 bytes, or VERIFICATION_CODE_IS_ACCESS_LINK when the qr_static code is a link of the guard app itself (its organization, login or install links), which the team app never records as a scan) or a type not implemented yet"
          }
        }
      }
    },
    "/api/checkpoints/{id}": {
      "put": {
        "operationId": "updateCheckpoint",
        "summary": "Update a checkpoint",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCheckpointBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkpoint updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckpointResponse"
                }
              }
            }
          },
          "404": {
            "description": "Checkpoint not found"
          }
        }
      }
    },
    "/api/checkpoints/{id}/archive": {
      "post": {
        "operationId": "archiveCheckpoint",
        "summary": "Archive a checkpoint (history preserved; cannot be assigned to new rounds)",
        "description": "Takes the checkpoint off every route it was on (positions are closed up and the rounds in progress on those routes are cancelled). A route left without checkpoints is deactivated. `affectedRoutes` lists those routes.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Checkpoint archived",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArchiveCheckpointResponse"
                }
              }
            }
          },
          "403": {
            "description": "No EDITOR role on the checkpoint location (nor in its organization), or `meta.errorCode: AGENT_WRITE_NOT_ALLOWED`: an AI agent session (a token from `/oauth/agent-session`) never makes this write, even with the write scope"
          },
          "404": {
            "description": "Checkpoint not found"
          },
          "409": {
            "description": "Checkpoint is already archived"
          }
        }
      }
    },
    "/api/checkpoints/{id}/unarchive": {
      "post": {
        "operationId": "unarchiveCheckpoint",
        "summary": "Unarchive a checkpoint",
        "description": "For the plan, bringing a checkpoint back into the active count is the same as creating one: it goes through the same limit (402 at the Free cap) and is charged as an extra the same way (409 to confirm).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnarchiveCheckpointBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkpoint unarchived",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckpointResponse"
                }
              }
            }
          },
          "402": {
            "description": "`code: CHECKPOINT_LIMIT_REACHED`: a Free plan at its checkpoint limit (unarchiving counts as creating one). The body carries `limit`, `currentUsage` and `upsell`. It stays archived."
          },
          "403": {
            "description": "No EDITOR role on the checkpoint location (nor in its organization), or `meta.errorCode: AGENT_WRITE_NOT_ALLOWED`: an AI agent session (a token from `/oauth/agent-session`) never makes this write, even with the write scope"
          },
          "404": {
            "description": "Checkpoint not found"
          },
          "409": {
            "description": "Checkpoint is not archived, the extra charge needs confirming (EXTRA_CHECKPOINT_CONFIRMATION_REQUIRED), or VERIFICATION_CODE_TAKEN when a live checkpoint of the organization took its code while it was archived (body below). LOCATION_ARCHIVED when its location is archived: restore the location first.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/VerificationCodeTaken"
                    },
                    {
                      "$ref": "#/components/schemas/CheckpointLocationArchivedConflict"
                    }
                  ]
                }
              }
            }
          },
          "502": {
            "description": "`code: BILLING_UPDATE_FAILED`: the confirmed extra charge could not be billed. Nothing was charged and it stays archived: retry."
          }
        }
      }
    },
    "/api/locations/{locationId}/qr-sheet": {
      "post": {
        "operationId": "createLocationQrSheetLink",
        "summary": "Create a one-hour link to the printable QR sheet of a location",
        "description": "The sheet holds one QR per finalized, non archived checkpoint with an active qr_static method, in creation order, 12 per A4 page. Each QR encodes the configured code (the checkpoint identifier when the code is empty or longer than 1,000 bytes); a checkpoint with nothing a scan would accept is left out. The PDF itself is not returned: open the link from `downloadQrSheet`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "locationId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateQrSheetBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Link created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateQrSheetResponse"
                }
              }
            }
          },
          "400": {
            "description": "Body does not match CreateQrSheetBody"
          },
          "403": {
            "description": "The caller is not an EDITOR of the location (a role on an archived location does not count)"
          },
          "404": {
            "description": "LOCATION_NOT_FOUND: no such location, or one without organization (errorCode in the response metadata)"
          },
          "422": {
            "description": "NO_PRINTABLE_CHECKPOINTS: nothing to print; or QR_SHEET_TOO_LARGE: more than 600 printable checkpoints, send `checkpointIds` to print a subset (errorCode in the response metadata)"
          }
        }
      }
    },
    "/api/qr-sheets/{token}": {
      "get": {
        "operationId": "downloadQrSheet",
        "summary": "Download the QR sheet PDF of a signed link",
        "description": "No Authorization header: the link is the credential. The sheet is rebuilt from the checkpoints as they are now, and the user the link was issued to must still be an active EDITOR of the location.",
        "security": [],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "token",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF, inline, not cacheable",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "description": "QR_SHEET_ACCESS_REVOKED: the user is no longer active or no longer an EDITOR of the location (errorCode in the response metadata)"
          },
          "410": {
            "description": "QR_SHEET_LINK_INVALID: tampered, forged, expired, malformed or unknown link, always the same answer (errorCode in the response metadata)"
          },
          "422": {
            "description": "NO_PRINTABLE_CHECKPOINTS: nothing printable is left; or QR_SHEET_TOO_LARGE: the location now has more than 600 printable checkpoints (errorCode in the response metadata)"
          },
          "423": {
            "description": "ORGANIZATION_SUSPENDED: the organization of the location is suspended. Same body as any other 423 (see the contract description); the link carries no session, so the suspension is checked here."
          },
          "429": {
            "description": "Too many downloads: 30 per minute per IP and 10 per minute per user; errorCode RATE_LIMITED"
          }
        }
      }
    },
    "/api/features/access-control/access-logs": {
      "get": {
        "operationId": "listAccessLogs",
        "summary": "List access history for a location",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "zone",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "ENTRY",
                "EXIT"
              ]
            },
            "required": false,
            "name": "type",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "authorizedPersonId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "to",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Access history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessLogsListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/features/access-control/access-logs/active": {
      "get": {
        "operationId": "getActiveEntries",
        "summary": "Get currently active entries (not yet exited)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "zone",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Active entries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActiveEntriesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/features/incident-reporting/incidents": {
      "get": {
        "operationId": "listIncidents",
        "summary": "List incidents with optional filters",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "LOW",
                "MEDIUM",
                "HIGH",
                "CRITICAL"
              ]
            },
            "required": false,
            "name": "priority",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "reportedByPatrollerId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "categoryId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "checkpointId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "to",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "required": false,
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "createdAt",
                "priority",
                "status"
              ],
              "default": "createdAt"
            },
            "required": false,
            "name": "sortBy",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ],
              "default": "DESC"
            },
            "required": false,
            "name": "sortOrder",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Incidents list. Without `locationId`, only the incidents of the locations of the vertical the request is made for (the `X-Client-Name` prefix or the `Origin` host; without either, the organization's `entryVertical`): in an organization with locations of both verticals, each client lists its own.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncidentsListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query, or the request names two different locations (in the query and the body, or `locationId` repeated)"
          },
          "403": {
            "description": "The incident-reporting feature is off for the operation's location (without a location, in every location of the vertical the request declares), the caller's role is not enough, or a patroller token names another organization"
          },
          "423": {
            "description": "GUARD_APP_BLOCKED: the guard app of this organization is blocked (a `panel_and_app` suspension is in force).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GuardAppBlockedResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/features/incident-reporting/incidents/{id}": {
      "get": {
        "operationId": "getIncidentDetail",
        "summary": "Get full incident detail including timeline and media",
        "description": "Access and the incident-reporting feature are checked on the incident's own location: the caller's role there (organization-wide or on that location) and the feature as resolved for that location. `locationId` and `organizationId` are optional; if sent, they must be the incident's. An incident that does not exist, one where the caller has no role on its location, and a request naming another organization or location all answer 404, so they cannot be told apart. An incident of a suspended organization of the caller answers 423 (`ORGANIZATION_SUSPENDED`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own location; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own location; any other answers 404.",
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own organization; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own organization; any other answers 404.",
            "name": "organizationId",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Incident detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncidentDetailResponse"
                }
              }
            }
          },
          "403": {
            "description": "The incident-reporting feature is off for the operation's location (without a location, in every location of the vertical the request declares), the caller's role is not enough, or a patroller token names another organization"
          },
          "404": {
            "description": "Incident not found: it does not exist, the caller has no role on its location, or the request names another organization or location (the three answer the same)"
          },
          "423": {
            "description": "ORGANIZATION_SUSPENDED: the incident belongs to one of the caller's organizations and that organization is suspended. It is checked on the incident's organization even when the request names none. Same body as any other 423 (see the contract description)."
          }
        }
      }
    },
    "/api/features/incident-reporting/incidents/{id}/status": {
      "patch": {
        "operationId": "updateIncidentStatus",
        "summary": "Update the status of an incident",
        "description": "Access and the incident-reporting feature are checked on the incident's own location: the caller's role there (organization-wide or on that location) and the feature as resolved for that location. `locationId` and `organizationId` are optional; if sent, they must be the incident's. An incident that does not exist, one where the caller has no role on its location, and a request naming another organization or location all answer 404, so they cannot be told apart. An incident of a suspended organization of the caller answers 423 (`ORGANIZATION_SUSPENDED`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own location; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own location; any other answers 404.",
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own organization; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own organization; any other answers 404.",
            "name": "organizationId",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateIncidentStatusBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "updated"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid status transition or missing required comment"
          },
          "403": {
            "description": "The incident-reporting feature is off for the operation's location (without a location, in every location of the vertical the request declares), the caller's role is not enough, or a patroller token names another organization"
          },
          "404": {
            "description": "Incident not found: it does not exist, the caller has no role on its location, or the request names another organization or location (the three answer the same)"
          },
          "423": {
            "description": "ORGANIZATION_SUSPENDED: the incident belongs to one of the caller's organizations and that organization is suspended. It is checked on the incident's organization even when the request names none. Same body as any other 423 (see the contract description)."
          }
        }
      }
    },
    "/api/features/incident-reporting/incidents/{id}/comments": {
      "post": {
        "operationId": "addIncidentComment",
        "summary": "Add a comment to an incident",
        "description": "Access and the incident-reporting feature are checked on the incident's own location: the caller's role there (organization-wide or on that location) and the feature as resolved for that location. `locationId` and `organizationId` are optional; if sent, they must be the incident's. An incident that does not exist, one where the caller has no role on its location, and a request naming another organization or location all answer 404, so they cannot be told apart. An incident of a suspended organization of the caller answers 423 (`ORGANIZATION_SUSPENDED`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own location; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own location; any other answers 404.",
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own organization; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own organization; any other answers 404.",
            "name": "organizationId",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddIncidentCommentBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Comment added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IncidentTimelineEntryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "403": {
            "description": "The incident-reporting feature is off for the operation's location (without a location, in every location of the vertical the request declares), the caller's role is not enough, or a patroller token names another organization"
          },
          "404": {
            "description": "Incident not found: it does not exist, the caller has no role on its location, or the request names another organization or location (the three answer the same)"
          },
          "423": {
            "description": "With a guard app token, GUARD_APP_BLOCKED: the guard app of this organization is blocked (a `panel_and_app` suspension is in force). With a dashboard token, ORGANIZATION_SUSPENDED: the incident belongs to one of the caller's organizations and that organization is suspended. It is checked on the incident's organization even when the request names none. Same body as any other 423 (see the contract description).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GuardAppBlockedResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/features/incident-reporting/incidents/{id}/assign": {
      "patch": {
        "operationId": "assignIncident",
        "summary": "Assign or unassign an incident to a user",
        "description": "Access and the incident-reporting feature are checked on the incident's own location: the caller's role there (organization-wide or on that location) and the feature as resolved for that location. `locationId` and `organizationId` are optional; if sent, they must be the incident's. An incident that does not exist, one where the caller has no role on its location, and a request naming another organization or location all answer 404, so they cannot be told apart. An incident of a suspended organization of the caller answers 423 (`ORGANIZATION_SUSPENDED`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own location; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own location; any other answers 404.",
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Optional. If sent, it must be the incident's own organization; any other answers 404."
            },
            "required": false,
            "description": "Optional. If sent, it must be the incident's own organization; any other answers 404.",
            "name": "organizationId",
            "in": "query"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignIncidentBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Incident assigned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "updated"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, or meta.errorCode ASSIGNEE_NOT_IN_ORGANIZATION: the assignee has no role in the incident's organization"
          },
          "403": {
            "description": "The incident-reporting feature is off for the operation's location (without a location, in every location of the vertical the request declares), the caller's role is not enough, or a patroller token names another organization"
          },
          "404": {
            "description": "Incident not found: it does not exist, the caller has no role on its location, or the request names another organization or location (the three answer the same)"
          },
          "423": {
            "description": "ORGANIZATION_SUSPENDED: the incident belongs to one of the caller's organizations and that organization is suspended. It is checked on the incident's organization even when the request names none. Same body as any other 423 (see the contract description)."
          }
        }
      }
    },
    "/api/payments/prices": {
      "get": {
        "operationId": "getPaymentPrices",
        "summary": "Catalogue of the active plans with their per-checkpoint pricing",
        "description": "Public catalogue: no authentication required. Without a session, `organizationId` is ignored and prices come in the currency of the country (`country`, or the request's). With a session, the currency of `organizationId` is used only if the user belongs to that organization; otherwise it is ignored too, so it never reveals another organization's billing currency. If the request carries `Authorization`, the token must be valid (401 otherwise).",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Organization of the authenticated user to price for: `price` and `currency` come in ITS currency, the one the payment provider will charge it in. Ignored without a session, or for an organization the user does not belong to."
            },
            "required": false,
            "description": "Organization of the authenticated user to price for: `price` and `currency` come in ITS currency, the one the payment provider will charge it in. Ignored without a session, or for an organization the user does not belong to.",
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2,
              "description": "Billing country (ISO 3166-1 alpha-2) the customer picked in the plan selector. When present it takes precedence over the organization's currency, so prices can be recomputed when the country changes. Without it, the organization's currency is used and, if unknown, the country of the request's IP (`CF-IPCountry`)."
            },
            "required": false,
            "description": "Billing country (ISO 3166-1 alpha-2) the customer picked in the plan selector. When present it takes precedence over the organization's currency, so prices can be recomputed when the country changes. Without it, the organization's currency is used and, if unknown, the country of the request's IP (`CF-IPCountry`).",
            "name": "country",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Active plans. `price`/`currency` in the organization's currency; `pricing` amounts in cents, in both eur and usd in case the consumer needs both.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentPricesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/payments/checkout-session": {
      "post": {
        "operationId": "createCheckoutSession",
        "summary": "Open a checkout with the payment provider for an organization that does not pay yet",
        "description": "The organization goes in the `organizationId` query parameter or in the `x-organization-id` header: one of them is required (400 ORGANIZATION_ID_REQUIRED otherwise) and, if both are sent, the query parameter wins. For compatibility, `organizationId` in the body is also accepted and takes precedence over both. ADMIN. Only for organizations without a live subscription: one that already pays changes plan from the dashboard. Creating the session charges nothing: payment happens on the provider's page and the plan is activated once paid. If the organization already has more checkpoints than the plan includes, the session also charges the extra ones. Sites and managers have no extras: a plan that does not include the ones it already has is refused (409 PLAN_LIMITS_EXCEEDED); Business, the top plan, is never refused.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Organization to operate on. Send it here or in the `x-organization-id` header; if both are sent, this parameter wins."
            },
            "required": false,
            "description": "Organization to operate on. Send it here or in the `x-organization-id` header; if both are sent, this parameter wins.",
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Organization to operate on. Send it here or in the `organizationId` query parameter; if both are sent, the query parameter wins."
            },
            "required": false,
            "description": "Organization to operate on. Send it here or in the `organizationId` query parameter; if both are sent, the query parameter wins.",
            "name": "x-organization-id",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCheckoutSessionBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout session created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCheckoutSessionResponse"
                }
              }
            }
          },
          "400": {
            "description": "ORGANIZATION_ID_REQUIRED, VALIDATION_ERROR or CHECKOUT_SESSION_FAILED (the plan is not a paid one, or neither the organization nor the user has a billing email)"
          },
          "403": {
            "description": "ORGANIZATION_ACCESS_DENIED (no role in the organization) or INSUFFICIENT_ORGANIZATION_ROLE (not an ADMIN). AGENT_CANNOT_MANAGE_BILLING: an AI agent session (a token from `/oauth/agent-session`) does not manage billing (paying, changing plan, cancelling, resuming or opening the portal); only the user's own session does. Nothing was changed"
          },
          "404": {
            "description": "ORGANIZATION_NOT_FOUND or LICENSE_TIER_NOT_FOUND"
          },
          "409": {
            "description": "ALREADY_SUBSCRIBED: the organization already pays a subscription and no second one is opened; change the plan from the dashboard. PLAN_LIMITS_EXCEEDED: the organization has more sites or managers than the plan includes (e.g. Pro with more than 3 sites or 5 managers); choose a bigger plan. BILLING_BUSY (the billing of the customer is being updated: retry in a few seconds) or LICENSE_CONCURRENT_MODIFICATION (another process changed the license at the same time: retry)"
          },
          "502": {
            "description": "BILLING_PROVIDER_ERROR: the payment provider refused (or did not answer) the request. Nothing was charged; an earlier checkout session may have been closed. It can be retried."
          }
        }
      }
    },
    "/api/payments/customer-portal": {
      "post": {
        "operationId": "createCustomerPortalSession",
        "summary": "Open a session of the payment provider's customer portal (payment method, invoices)",
        "description": "The organization goes in the `organizationId` query parameter or in the `x-organization-id` header: one of them is required (400 ORGANIZATION_ID_REQUIRED otherwise) and, if both are sent, the query parameter wins. For compatibility, `organizationId` in the body is also accepted and takes precedence over both. ADMIN.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Organization to operate on. Send it here or in the `x-organization-id` header; if both are sent, this parameter wins."
            },
            "required": false,
            "description": "Organization to operate on. Send it here or in the `x-organization-id` header; if both are sent, this parameter wins.",
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Organization to operate on. Send it here or in the `organizationId` query parameter; if both are sent, the query parameter wins."
            },
            "required": false,
            "description": "Organization to operate on. Send it here or in the `organizationId` query parameter; if both are sent, the query parameter wins.",
            "name": "x-organization-id",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerPortalSessionBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "URL of the portal session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCustomerPortalSessionResponse"
                }
              }
            }
          },
          "400": {
            "description": "ORGANIZATION_ID_REQUIRED or VALIDATION_ERROR (returnUrl)"
          },
          "403": {
            "description": "ORGANIZATION_ACCESS_DENIED (no role in the organization) or INSUFFICIENT_ORGANIZATION_ROLE (not an ADMIN). AGENT_CANNOT_MANAGE_BILLING: an AI agent session (a token from `/oauth/agent-session`) does not manage billing (paying, changing plan, cancelling, resuming or opening the portal); only the user's own session does. Nothing was changed"
          },
          "404": {
            "description": "ORGANIZATION_NOT_FOUND"
          },
          "409": {
            "description": "MISSING_STRIPE_CUSTOMER: the organization is not a customer of the payment provider yet (it never opened a checkout), so there is no portal to open"
          },
          "502": {
            "description": "BILLING_PROVIDER_ERROR: the payment provider refused (or did not answer) the request. No portal was opened and nothing was charged. It can be retried."
          }
        }
      }
    },
    "/api/licenses/organization/{organizationId}": {
      "get": {
        "operationId": "getLicenseInfo",
        "summary": "License, tier, usage and upgrade options of an organization",
        "description": "Open to VIEWER: limits and usage are operational data. Billing details are only returned to EDITOR and above. `currency` is the currency the organization is PRICED in (also while it does not pay yet).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "organizationId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "License information",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetLicenseInfoResponse"
                }
              }
            }
          },
          "404": {
            "description": "NO_LICENSE: the organization has no license"
          }
        }
      }
    },
    "/.well-known/oauth-authorization-server": {
      "get": {
        "operationId": "getOAuthAuthorizationServerMetadata",
        "summary": "OAuth authorization server metadata (RFC 8414)",
        "responses": {
          "200": {
            "description": "Server metadata; 404 when OAuth is disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthAuthorizationServerMetadata"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/jwks.json": {
      "get": {
        "operationId": "getOAuthJwks",
        "summary": "Public keys that verify the access tokens",
        "responses": {
          "200": {
            "description": "JWK set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthJwks"
                }
              }
            }
          },
          "503": {
            "description": "OAuth disabled on this server (`temporarily_unavailable`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/authorize": {
      "get": {
        "operationId": "startOAuthAuthorization",
        "summary": "Start the authorization code flow with PKCE S256",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "code"
              ]
            },
            "required": true,
            "name": "response_type",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "client_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "redirect_uri",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "scope",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "state",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "code_challenge",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "S256"
              ]
            },
            "required": true,
            "name": "code_challenge_method",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "resource",
            "in": "query"
          }
        ],
        "responses": {
          "302": {
            "description": "To the consent screen; once the client is trusted, a CIMD client gets its errors at its `redirect_uri` with `error`, `state` and `iss`"
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "`server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "OAuth disabled on this server (`temporarily_unavailable`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/register": {
      "post": {
        "operationId": "registerOAuthClient",
        "summary": "Dynamic registration of a public client (RFC 7591)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthRegisterClientRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered client metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthRegisterClientResponse"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_redirect_uri` or `invalid_client_metadata`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Body too large (`invalid_request`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "`server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "OAuth disabled on this server (`temporarily_unavailable`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "requestOAuthToken",
        "summary": "Exchange an authorization code (PKCE) or rotate a refresh token",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token pair",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthTokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "RFC 6749 §5.2 error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Body too large (`invalid_request`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "`server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "OAuth disabled on this server (`temporarily_unavailable`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/revoke": {
      "post": {
        "operationId": "revokeOAuthToken",
        "summary": "Revoke a token (RFC 7009)",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/OAuthRevokeRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OAuthRevokeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Revoked, or unknown token (no body)"
          },
          "400": {
            "description": "`invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Body too large (`invalid_request`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "`server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "OAuth disabled on this server (`temporarily_unavailable`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/agent-session": {
      "post": {
        "operationId": "createOAuthAgentSession",
        "summary": "Exchange an OAuth access token for a short-lived user JWT, an AI agent session, that calls `/api`",
        "security": [
          {
            "oauthAccessToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "User session for the agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthAgentSessionResponse"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_token`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "`server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "OAuth disabled on this server (`temporarily_unavailable`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/locations": {
      "get": {
        "operationId": "listLocations",
        "summary": "List locations for an organization",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "`true` also lists the archived locations. By default they are left out."
            },
            "required": false,
            "description": "`true` also lists the archived locations. By default they are left out.",
            "name": "includeArchived",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Locations retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListLocationsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Organization ID is required"
          }
        }
      },
      "post": {
        "operationId": "createLocation",
        "summary": "Create a location",
        "description": "Needs ADMIN in the organization. The creator gets ADMIN on the new location and every patroller of the organization is assigned to it. Tokens issued from then on carry the new location role. It counts for the plan's `max_locations`, which is checked before the request body.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLocationBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Location created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationResponse"
                }
              }
            }
          },
          "400": {
            "description": "`code: INVALID_LOCATION_NAME`: the name is missing, empty once trimmed or longer than 255 characters. Nothing is created."
          },
          "402": {
            "description": "`code: LOCATION_LIMIT_REACHED`: the organization is at its plan's `max_locations`. The body carries `limit`, `currentUsage` and `upsell`. Nothing is created."
          },
          "403": {
            "description": "No ADMIN role in the organization (or no `organizationId`), the plan does not include locations (`code: FEATURE_NOT_AVAILABLE`), or `meta.errorCode: AGENT_WRITE_NOT_ALLOWED`: an AI agent session (a token from `/oauth/agent-session`) never makes this write, even with the write scope"
          }
        }
      }
    },
    "/api/locations/{id}": {
      "put": {
        "operationId": "updateLocation",
        "summary": "Update a location",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateLocationBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Location updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient permissions"
          },
          "404": {
            "description": "Location not found"
          }
        }
      },
      "delete": {
        "operationId": "deleteLocation",
        "summary": "Delete a location",
        "description": "Needs ADMIN on the location (or in its organization). Only a location without history can be deleted. One with scans, scanned checkpoints or routes with rounds or alerts is refused with 409 LOCATION_HAS_HISTORY before anything is deleted, and must be archived instead (`POST /api/locations/{id}/archive`). Deleting it deletes its checkpoints and routes too.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Location deleted"
          },
          "403": {
            "description": "Insufficient permissions (no ADMIN role), or `meta.errorCode: AGENT_WRITE_NOT_ALLOWED`: an AI agent session (a token from `/oauth/agent-session`) never makes this write, even with the write scope"
          },
          "404": {
            "description": "Location not found"
          },
          "409": {
            "description": "`LAST_LOCATION`: it is the organization's last active location (archived ones do not count); an organization keeps at least one. `LOCATION_HAS_HISTORY`: it has history.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationConflict"
                }
              }
            }
          }
        }
      }
    },
    "/api/patrollers": {
      "get": {
        "operationId": "listPatrollers",
        "summary": "List patrollers for an organization",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "required": false,
            "name": "includeArchived",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Patrollers retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListPatrollersResponse"
                }
              }
            }
          },
          "403": {
            "description": "Without `locationId`: no organization-wide role (a user whose only role is on a location must send `locationId`). With `locationId`: no role on that location (nor in its organization), or the location does not belong to `organizationId`"
          },
          "404": {
            "description": "Location not found"
          }
        }
      },
      "post": {
        "operationId": "createPatroller",
        "summary": "Create a patroller",
        "description": "Needs an organization-wide EDITOR role (or above) in `organizationId`. The patroller is assigned to every location of the organization. Patrollers are unlimited on every plan.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePatrollerBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Patroller created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatrollerResponse"
                }
              }
            }
          },
          "400": {
            "description": "`VALIDATION_ERROR`: the body does not match the schema"
          },
          "403": {
            "description": "Not an EDITOR of the organization, or meta.errorCode AGENT_CANNOT_GRANT_ACCESS: an AI agent session (a token from `/oauth/agent-session`) never adds or restores a guard, whose app signs in with its identifier. Also without `organizationId` (`Organization could not be resolved`)"
          },
          "409": {
            "description": "`code: PATROLLER_IDENTIFIER_TAKEN`: the `identifier` sent is already used by another patroller (it is unique across PatrolTech). Nothing is created: send another or omit it."
          }
        }
      }
    },
    "/api/patrollers/{id}": {
      "put": {
        "operationId": "updatePatroller",
        "summary": "Update a patroller",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePatrollerBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Patroller updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatrollerResponse"
                }
              }
            }
          },
          "404": {
            "description": "Patroller not found"
          }
        }
      }
    },
    "/api/patrollers/identifier/{identifier}": {
      "get": {
        "operationId": "getPatrollerByIdentifier",
        "summary": "Get a patroller by their identifier",
        "description": "The identifier is unique across PatrolTech and is what the guard app signs in with, so the lookup never reveals one the caller may not see: a patroller of an organization where the caller has no organization-wide role, and any patroller for a VIEWER whose organization hides part of the patrollers' identity (visibility policy), get the same 404 as an identifier that does not exist.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "identifier",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Patroller retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatrollerResponse"
                }
              }
            }
          },
          "404": {
            "description": "Patroller not found, not in an organization of the caller's, or hidden from a VIEWER by the visibility policy: the same answer for all three"
          }
        }
      }
    },
    "/api/patrollers/ranking": {
      "get": {
        "operationId": "getPatrollerRanking",
        "summary": "Get patroller ranking with scan and round metrics",
        "description": "VIEWER or above. With `locationId`, a role on that location is enough and the ranking only counts its scans and rounds. The window is clamped to the plan's data retention (`retentionCutoff`). For a VIEWER under the patroller visibility policy, a hidden name comes as the organization's alias (or blank), a hidden identifier blank, and with the name hidden `patrollerId` comes null.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "to",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Patroller ranking retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatrollerRankingResponse"
                }
              }
            }
          },
          "400": {
            "description": "`from`/`to` is not a date, or `locationId` is repeated"
          },
          "403": {
            "description": "Without `locationId`: no organization-wide role (a user whose only role is on a location must send `locationId`). With `locationId`: no role on that location (nor in its organization), or the location does not belong to `organizationId`"
          },
          "404": {
            "description": "Location not found"
          }
        }
      }
    },
    "/api/patrollers/{id}/stats": {
      "get": {
        "operationId": "getPatrollerStats",
        "summary": "Get individual patroller statistics",
        "description": "Needs an organization-wide role (VIEWER or above) in the patroller's organization.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "to",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Patroller stats retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatrollerStatsResponse"
                }
              }
            }
          },
          "400": {
            "description": "`from`/`to` is not a date"
          },
          "403": {
            "description": "No role in the patroller's organization"
          },
          "404": {
            "description": "Patroller not found"
          }
        }
      }
    },
    "/api/scans": {
      "get": {
        "operationId": "listScans",
        "summary": "List scans for an organization with optional filters",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "organizationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "name": "locationId",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            },
            "required": false,
            "name": "page",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "checkpoint",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "patroller",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "nullable": true,
              "format": "date-time"
            },
            "required": false,
            "name": "dateFrom",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "nullable": true,
              "format": "date-time"
            },
            "required": false,
            "name": "dateTo",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "flagged",
                "clean"
              ]
            },
            "required": false,
            "name": "fraudStatus",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "counted",
                "verified",
                "pending_review",
                "rejected"
              ],
              "description": "`counted` = every scan except `rejected` (what the round and the scan certificate count); also applies to rows redacted by retention, which carry no status"
            },
            "required": false,
            "description": "`counted` = every scan except `rejected` (what the round and the scan certificate count); also applies to rows redacted by retention, which carry no status",
            "name": "validationStatus",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Scans retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListScansResponse"
                }
              }
            }
          },
          "403": {
            "description": "Without `locationId`: no organization-wide role (a user whose only role is on a location must send `locationId`). With `locationId`: no role on that location (nor in its organization), or the location does not belong to `organizationId`"
          },
          "404": {
            "description": "Location not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiSuccessRoutesList": {
        "$ref": "#/components/schemas/PaginatedRoutes"
      },
      "ApiError": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "errorCode": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "message"
        ]
      },
      "AddCheckpointToRouteBody": {
        "type": "object",
        "required": [
          "order"
        ],
        "properties": {
          "order": {
            "type": "integer"
          }
        }
      },
      "ApiSuccessRouteCheckpoint": {
        "$ref": "#/components/schemas/RouteCheckpoint"
      },
      "AddTimeWindowBody": {
        "type": "object",
        "required": [
          "startTime",
          "endTime",
          "days"
        ],
        "properties": {
          "startTime": {
            "type": "string"
          },
          "endTime": {
            "type": "string"
          },
          "days": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "timezone": {
            "type": "string",
            "description": "IANA timezone the window was configured in (e.g. \"Europe/Madrid\"). Times stay UTC; this records which local time they came from so the backend can re-project them when the offset changes (DST)."
          }
        }
      },
      "ApiSuccessRouteTimeWindow": {
        "$ref": "#/components/schemas/RouteTimeWindow"
      },
      "TimeWindowsOverlapResponse": {
        "type": "object",
        "required": [
          "success",
          "message",
          "code",
          "data"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "TIME_WINDOWS_OVERLAP"
            ]
          },
          "data": {
            "type": "object",
            "required": [
              "code",
              "windows"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "TIME_WINDOWS_OVERLAP"
                ]
              },
              "windows": {
                "type": "array",
                "description": "The two conflicting windows (UTC), in the order they were checked.",
                "minItems": 2,
                "maxItems": 2,
                "items": {
                  "$ref": "#/components/schemas/AddTimeWindowBody"
                }
              }
            }
          }
        }
      },
      "ApiSuccessRouteWithDetails": {
        "$ref": "#/components/schemas/RouteWithDetails"
      },
      "RouteFormBody": {
        "type": "object",
        "required": [
          "name",
          "locationId",
          "requiresOrderedScan"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "scheduleTimezone": {
            "type": "string",
            "description": "IANA timezone the route schedule is expressed in, chosen by the user. Takes precedence over the stored one and over each window timezone: only a client that converted the times with it sends this field."
          },
          "name": {
            "type": "string"
          },
          "organizationId": {
            "type": "string"
          },
          "locationId": {
            "type": "string"
          },
          "requiresOrderedScan": {
            "type": "boolean"
          },
          "guardMode": {
            "$ref": "#/components/schemas/RouteGuardMode"
          },
          "scheduleMode": {
            "$ref": "#/components/schemas/RouteScheduleMode"
          },
          "checkpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "checkpointId",
                "order"
              ],
              "properties": {
                "checkpointId": {
                  "type": "string"
                },
                "order": {
                  "type": "integer"
                }
              }
            }
          },
          "timeWindows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AddTimeWindowBody"
            }
          },
          "expectedVersion": {
            "type": "integer",
            "description": "The `version` the client loaded. If stale, the update is rejected with 409 so a concurrent edit is never silently overwritten."
          },
          "isActive": {
            "type": "boolean",
            "description": "Update only (ignored on create: a new route is active when it has checkpoints). A route without checkpoints cannot be active: saved with an empty list it is deactivated, and activating one without sending checkpoints is refused with 400 `ROUTE_HAS_NO_CHECKPOINTS`. Anything but a boolean is refused with 400."
          }
        }
      },
      "RouteArchiveConflict": {
        "type": "object",
        "required": [
          "success",
          "message",
          "code",
          "data"
        ],
        "description": "409 of creating, updating, deleting, archiving, unarchiving or activating a route. `code` is at the top level; LOCATION_ARCHIVED means the location of the route, or the one an update assigns to a route without one, is archived.",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "ROUTE_HAS_HISTORY",
              "ROUTE_ALREADY_ARCHIVED",
              "ROUTE_NOT_ARCHIVED",
              "ROUTE_ARCHIVED",
              "LOCATION_ARCHIVED"
            ]
          },
          "data": {
            "type": "object",
            "nullable": true
          },
          "error": {
            "type": "string"
          }
        }
      },
      "ApiSuccessRouteRounds": {
        "$ref": "#/components/schemas/RouteRoundsPage"
      },
      "ApiSuccessRouteRoundCheckpoints": {
        "type": "object",
        "required": [
          "roundId",
          "routeId",
          "status",
          "scannedCount",
          "totalCount",
          "checkpoints"
        ],
        "properties": {
          "roundId": {
            "type": "string"
          },
          "routeId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "scannedCount": {
            "type": "integer"
          },
          "totalCount": {
            "type": "integer"
          },
          "checkpoints": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RouteRoundCheckpointItem"
            }
          },
          "redacted": {
            "type": "boolean"
          }
        }
      },
      "ToggleRouteActiveBody": {
        "type": "object",
        "required": [
          "isActive"
        ],
        "properties": {
          "isActive": {
            "type": "boolean"
          }
        }
      },
      "ApiSuccessRoute": {
        "$ref": "#/components/schemas/Route"
      },
      "ProposeAgentActionsBody": {
        "type": "object",
        "properties": {
          "contextKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "pattern": "\\S$",
            "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace."
          },
          "ttlMin": {
            "type": "integer",
            "minimum": 1,
            "maximum": 60,
            "description": "Minutes until it expires if not confirmed."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentProposalItem"
            },
            "minItems": 1,
            "maxItems": 10
          }
        },
        "required": [
          "contextKey",
          "ttlMin",
          "items"
        ]
      },
      "AgentProposal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "contextKey": {
            "type": "string"
          },
          "batchId": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string"
          },
          "params": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            }
          },
          "organizationId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "proposed",
              "executing",
              "executed",
              "failed",
              "cancelled",
              "expired"
            ]
          },
          "idempotencyKey": {
            "type": "string",
            "nullable": true
          },
          "result": {
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Expiry: creation + ttlMin, with millisecond precision."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "contextKey",
          "batchId",
          "action",
          "params",
          "organizationId",
          "status",
          "idempotencyKey",
          "error",
          "expiresAt",
          "createdAt",
          "updatedAt"
        ]
      },
      "AgentProposalExecutedRecently": {
        "type": "object",
        "properties": {
          "executed": {
            "type": "boolean"
          }
        },
        "required": [
          "executed"
        ]
      },
      "ClaimAgentProposalBody": {
        "type": "object",
        "properties": {
          "contextKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "pattern": "\\S$",
            "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace."
          }
        },
        "required": [
          "contextKey"
        ]
      },
      "AgentProposalNotClaimable": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "proposed",
              "executing",
              "executed",
              "failed",
              "cancelled",
              "expired"
            ]
          }
        },
        "required": [
          "status"
        ]
      },
      "MarkAgentProposalExecutedBody": {
        "type": "object",
        "properties": {
          "result": {
            "nullable": true,
            "description": "Result of the execution (JSON). If it exceeds 16384 bytes it is stored truncated as `{ truncated: true, preview }` (the start of its JSON) and the action still becomes `executed`: it is never left `executing`. A body over the HTTP limit (1 MB) is stored as `{ truncated: true, preview: \"\", reason: \"request_body_too_large\" }`."
          }
        }
      },
      "MarkAgentProposalFailedBody": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Truncated to 1000 characters. An empty error is stored as \"unknown error\". A body over the HTTP limit (1 MB) is stored as \"request body too large\"."
          }
        },
        "required": [
          "error"
        ]
      },
      "ReopenAgentProposalsBody": {
        "type": "object",
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "minItems": 1,
            "maxItems": 10
          },
          "ttlMin": {
            "type": "integer",
            "minimum": 1,
            "maximum": 60,
            "description": "Integer between 1 and 60."
          }
        },
        "required": [
          "ids",
          "ttlMin"
        ]
      },
      "CancelAgentProposalsBody": {
        "type": "object",
        "properties": {
          "contextKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "pattern": "\\S$",
            "description": "Key of the client's conversation or session. It only tells sessions of the same user apart; it never grants access to another user's proposals. It must not end with whitespace."
          }
        },
        "required": [
          "contextKey"
        ]
      },
      "UserPreferencesResponse": {
        "type": "object",
        "properties": {
          "preferredLanguage": {
            "type": "string",
            "nullable": true
          },
          "preferredTimezone": {
            "type": "string",
            "nullable": true
          },
          "notificationPreferences": {
            "type": "object",
            "nullable": true,
            "properties": {
              "channels": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "boolean"
                  }
                },
                "description": "Per alert type, which channels are on (`{ <alertType>: { <channel>: boolean } }`). Empty when the user never changed an alert: the defaults apply."
              },
              "globalChannels": {
                "type": "object",
                "additionalProperties": {
                  "type": "boolean"
                },
                "description": "Per channel, an override for every alert type (for instance, all email off). It cannot be set through this API, and it wins over `channels`."
              }
            },
            "required": [
              "channels"
            ],
            "description": "null when the user has no notification preferences stored."
          }
        },
        "required": [
          "preferredLanguage",
          "preferredTimezone",
          "notificationPreferences"
        ]
      },
      "UpdatePreferencesBody": {
        "type": "object",
        "properties": {
          "preferredLanguage": {
            "type": "string",
            "enum": [
              "es",
              "en",
              "fr"
            ]
          },
          "preferredTimezone": {
            "type": "string",
            "maxLength": 50
          },
          "notificationPreferences": {
            "type": "object",
            "properties": {
              "channels": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "whatsappPhone": {
            "type": "string",
            "nullable": true,
            "minLength": 1,
            "maxLength": 20,
            "description": "Phone number for WhatsApp notifications, 1 to 20 characters; null removes it. Omit it to leave the current one unchanged."
          }
        }
      },
      "UpdatePreferencesResponse": {
        "type": "object",
        "properties": {
          "preferredLanguage": {
            "type": "string"
          },
          "preferredTimezone": {
            "type": "string",
            "nullable": true
          },
          "notificationPreferences": {
            "type": "object",
            "nullable": true,
            "properties": {
              "channels": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "boolean"
                  }
                },
                "description": "Per alert type, which channels are on (`{ <alertType>: { <channel>: boolean } }`). Empty when the user never changed an alert: the defaults apply."
              },
              "globalChannels": {
                "type": "object",
                "additionalProperties": {
                  "type": "boolean"
                },
                "description": "Per channel, an override for every alert type (for instance, all email off). It cannot be set through this API, and it wins over `channels`."
              }
            },
            "required": [
              "channels"
            ],
            "description": "null when the user has no notification preferences stored."
          },
          "whatsappPhone": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "preferredLanguage",
          "preferredTimezone",
          "notificationPreferences",
          "whatsappPhone"
        ]
      },
      "UpdateUserRoleBody": {
        "type": "object",
        "properties": {
          "roleType": {
            "type": "string",
            "enum": [
              "ADMIN",
              "EDITOR",
              "VIEWER"
            ]
          }
        },
        "required": [
          "roleType"
        ]
      },
      "UserRoleResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "roleType": {
            "type": "string",
            "enum": [
              "ADMIN",
              "EDITOR",
              "VIEWER"
            ]
          },
          "roleScope": {
            "type": "string",
            "enum": [
              "ORGANIZATION",
              "LOCATION"
            ]
          },
          "scopeId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "id",
          "userId",
          "roleType",
          "roleScope",
          "scopeId"
        ]
      },
      "ListOrganizationsResponse": {
        "type": "object",
        "additionalProperties": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "format": "uuid"
            },
            "name": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "description": "One of security_company, homeowners_association, maintenance_company, other, cleaning_company or facility_services."
            },
            "entryVertical": {
              "$ref": "#/components/schemas/Vertical"
            }
          },
          "required": [
            "id",
            "name",
            "type",
            "entryVertical"
          ]
        }
      },
      "OrgUsersResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string"
                },
                "phone": {
                  "type": "string",
                  "nullable": true
                },
                "lastLogin": {
                  "type": "string",
                  "nullable": true
                },
                "UserRoles": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "roleType": {
                        "type": "string"
                      },
                      "roleScope": {
                        "type": "string"
                      },
                      "scopeId": {
                        "type": "string",
                        "format": "uuid"
                      }
                    },
                    "required": [
                      "id",
                      "roleType",
                      "roleScope",
                      "scopeId"
                    ]
                  }
                }
              },
              "required": [
                "id",
                "name",
                "email"
              ]
            }
          },
          "count": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "count",
          "totalPages"
        ]
      },
      "CreateOrgUserBody": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Ignored: the server always generates the id of a new user."
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Matched case-insensitively against existing users; stored lower-cased."
          },
          "phone": {
            "type": "string"
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "roleType": {
            "type": "string",
            "enum": [
              "ADMIN",
              "EDITOR",
              "VIEWER"
            ],
            "default": "VIEWER",
            "description": "Omitted (or not a role): VIEWER, least privilege. VIEWER does not use a manager seat of the plan."
          },
          "roleScope": {
            "type": "string",
            "enum": [
              "ORGANIZATION",
              "LOCATION"
            ],
            "default": "ORGANIZATION"
          },
          "locationId": {
            "type": "string",
            "format": "uuid",
            "description": "Required when roleScope is LOCATION; must be a location of (or linked to) organizationId."
          }
        },
        "required": [
          "name",
          "email",
          "organizationId"
        ]
      },
      "SupportSummary": {
        "type": "object",
        "properties": {
          "rounds": {
            "type": "object",
            "properties": {
              "windowDays": {
                "type": "integer"
              },
              "inProgress": {
                "type": "integer"
              },
              "completed": {
                "type": "integer"
              },
              "incomplete": {
                "type": "integer"
              },
              "expired": {
                "type": "integer"
              }
            },
            "required": [
              "windowDays",
              "inProgress",
              "completed",
              "incomplete",
              "expired"
            ]
          },
          "patrollers": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "active": {
                "type": "integer"
              },
              "inactive": {
                "type": "integer"
              },
              "alert": {
                "type": "integer"
              }
            },
            "required": [
              "total",
              "active",
              "inactive",
              "alert"
            ]
          },
          "checkpoints": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              }
            },
            "required": [
              "total"
            ]
          },
          "suspiciousScans": {
            "type": "object",
            "properties": {
              "windowDays": {
                "type": "integer"
              },
              "flagged": {
                "type": "integer"
              }
            },
            "required": [
              "windowDays",
              "flagged"
            ]
          }
        },
        "required": [
          "rounds",
          "patrollers",
          "checkpoints",
          "suspiciousScans"
        ]
      },
      "ListCheckpointsResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "identifier": {
                  "type": "string",
                  "nullable": true
                },
                "category": {
                  "type": "string",
                  "nullable": true
                },
                "tags": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "string"
                  }
                },
                "latitude": {
                  "type": "number",
                  "nullable": true
                },
                "longitude": {
                  "type": "number",
                  "nullable": true
                },
                "locationId": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "qrCode": {
                  "type": "string",
                  "nullable": true
                },
                "organizationId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "fraudRules": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "gpsProximity": {
                      "type": "object",
                      "properties": {
                        "maxDistanceMeters": {
                          "type": "number",
                          "minimum": 0,
                          "exclusiveMinimum": true
                        },
                        "maxAccuracyMeters": {
                          "type": "number",
                          "minimum": 0,
                          "exclusiveMinimum": true
                        }
                      },
                      "required": [
                        "maxDistanceMeters"
                      ]
                    },
                    "undergroundMode": {
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "enabled"
                      ]
                    }
                  }
                },
                "verificationMethod": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "qr_static",
                        "nfc_uid",
                        "manual_code",
                        "geofence",
                        "nfc_sun",
                        "nfc_url_signed",
                        "ble_beacon",
                        "iot_button",
                        "photo_evidence",
                        "qr_dynamic"
                      ]
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "securityLevel": {
                      "type": "string",
                      "enum": [
                        "low",
                        "medium",
                        "high"
                      ]
                    },
                    "config": {
                      "type": "object",
                      "additionalProperties": {
                        "nullable": true
                      }
                    },
                    "provisioningStatus": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "key_generated",
                        "chip_assigned",
                        "provisioned",
                        "failed",
                        "revoked"
                      ]
                    },
                    "provisionedAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time"
                    },
                    "lastProvisioningError": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "active",
                    "securityLevel",
                    "config",
                    "provisioningStatus",
                    "provisionedAt",
                    "lastProvisioningError"
                  ]
                },
                "firstScanAt": {
                  "type": "string",
                  "nullable": true,
                  "format": "date-time"
                },
                "archivedAt": {
                  "type": "string",
                  "nullable": true,
                  "format": "date-time"
                },
                "supersededById": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "isLocked": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "name",
                "locationId"
              ]
            }
          },
          "count": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "count",
          "totalPages"
        ]
      },
      "CreateCheckpointBody": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "identifier": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "latitude": {
            "type": "number",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "locationId": {
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "fraudRules": {
            "type": "object",
            "nullable": true,
            "properties": {
              "gpsProximity": {
                "type": "object",
                "properties": {
                  "maxDistanceMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  },
                  "maxAccuracyMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  }
                },
                "required": [
                  "maxDistanceMeters"
                ]
              },
              "undergroundMode": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          },
          "verificationMethod": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "qr_static",
                  "nfc_uid",
                  "manual_code",
                  "geofence",
                  "nfc_sun",
                  "nfc_url_signed",
                  "ble_beacon",
                  "iot_button",
                  "photo_evidence",
                  "qr_dynamic"
                ]
              },
              "active": {
                "type": "boolean"
              },
              "securityLevel": {
                "type": "string",
                "enum": [
                  "low",
                  "medium",
                  "high"
                ]
              },
              "config": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                },
                "description": "Per-type config. For `qr_static` and `manual_code`, `code` is a non-empty string; a `qr_static` code is printed as a QR, so it is at most 1000 bytes of UTF-8 once trimmed (longer is a config validation error)."
              }
            },
            "required": [
              "type",
              "config"
            ]
          },
          "confirmExtraBilling": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "locationId"
        ]
      },
      "CheckpointResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "identifier": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "latitude": {
            "type": "number",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "locationId": {
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "qrCode": {
            "type": "string",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "fraudRules": {
            "type": "object",
            "nullable": true,
            "properties": {
              "gpsProximity": {
                "type": "object",
                "properties": {
                  "maxDistanceMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  },
                  "maxAccuracyMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  }
                },
                "required": [
                  "maxDistanceMeters"
                ]
              },
              "undergroundMode": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          },
          "verificationMethod": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "type": {
                "type": "string",
                "enum": [
                  "qr_static",
                  "nfc_uid",
                  "manual_code",
                  "geofence",
                  "nfc_sun",
                  "nfc_url_signed",
                  "ble_beacon",
                  "iot_button",
                  "photo_evidence",
                  "qr_dynamic"
                ]
              },
              "active": {
                "type": "boolean"
              },
              "securityLevel": {
                "type": "string",
                "enum": [
                  "low",
                  "medium",
                  "high"
                ]
              },
              "config": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "provisioningStatus": {
                "type": "string",
                "enum": [
                  "pending",
                  "key_generated",
                  "chip_assigned",
                  "provisioned",
                  "failed",
                  "revoked"
                ]
              },
              "provisionedAt": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              },
              "lastProvisioningError": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "type",
              "active",
              "securityLevel",
              "config",
              "provisioningStatus",
              "provisionedAt",
              "lastProvisioningError"
            ]
          },
          "firstScanAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "archivedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "supersededById": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "isLocked": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "name",
          "locationId"
        ]
      },
      "VerificationTypeRetired": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "VERIFICATION_TYPE_RETIRED"
            ]
          }
        },
        "required": [
          "success",
          "message",
          "code"
        ]
      },
      "VerificationCodeTaken": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "VERIFICATION_CODE_TAKEN"
            ]
          },
          "conflictingCheckpointId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "success",
          "message",
          "code",
          "conflictingCheckpointId"
        ]
      },
      "CheckpointLocationArchivedConflict": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "LOCATION_ARCHIVED"
            ]
          },
          "data": {
            "nullable": true
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "message",
          "code",
          "data",
          "error"
        ]
      },
      "UpdateCheckpointBody": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "latitude": {
            "type": "number",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "fraudRules": {
            "type": "object",
            "nullable": true,
            "properties": {
              "gpsProximity": {
                "type": "object",
                "properties": {
                  "maxDistanceMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  },
                  "maxAccuracyMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  }
                },
                "required": [
                  "maxDistanceMeters"
                ]
              },
              "undergroundMode": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          }
        }
      },
      "ArchiveCheckpointResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "identifier": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "latitude": {
            "type": "number",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "locationId": {
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "qrCode": {
            "type": "string",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "fraudRules": {
            "type": "object",
            "nullable": true,
            "properties": {
              "gpsProximity": {
                "type": "object",
                "properties": {
                  "maxDistanceMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  },
                  "maxAccuracyMeters": {
                    "type": "number",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  }
                },
                "required": [
                  "maxDistanceMeters"
                ]
              },
              "undergroundMode": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          },
          "verificationMethod": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "type": {
                "type": "string",
                "enum": [
                  "qr_static",
                  "nfc_uid",
                  "manual_code",
                  "geofence",
                  "nfc_sun",
                  "nfc_url_signed",
                  "ble_beacon",
                  "iot_button",
                  "photo_evidence",
                  "qr_dynamic"
                ]
              },
              "active": {
                "type": "boolean"
              },
              "securityLevel": {
                "type": "string",
                "enum": [
                  "low",
                  "medium",
                  "high"
                ]
              },
              "config": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "provisioningStatus": {
                "type": "string",
                "enum": [
                  "pending",
                  "key_generated",
                  "chip_assigned",
                  "provisioned",
                  "failed",
                  "revoked"
                ]
              },
              "provisionedAt": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              },
              "lastProvisioningError": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "type",
              "active",
              "securityLevel",
              "config",
              "provisioningStatus",
              "provisionedAt",
              "lastProvisioningError"
            ]
          },
          "firstScanAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "archivedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "supersededById": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "isLocked": {
            "type": "boolean"
          },
          "affectedRoutes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "leftEmpty": {
                  "type": "boolean",
                  "description": "No checkpoint is left on the route."
                },
                "deactivated": {
                  "type": "boolean",
                  "description": "The route was active and archiving deactivated it for being left without checkpoints."
                }
              },
              "required": [
                "id",
                "name",
                "leftEmpty",
                "deactivated"
              ]
            },
            "description": "Routes the checkpoint was taken off (empty when it was on none). A route left without checkpoints is deactivated."
          }
        },
        "required": [
          "id",
          "name",
          "locationId",
          "affectedRoutes"
        ]
      },
      "UnarchiveCheckpointBody": {
        "type": "object",
        "properties": {
          "confirmExtraBilling": {
            "type": "boolean",
            "description": "Accepts the charge of the extra checkpoint. Needed when the previous answer was 409 EXTRA_CHECKPOINT_CONFIRMATION_REQUIRED."
          }
        }
      },
      "CreateQrSheetBody": {
        "type": "object",
        "properties": {
          "checkpointIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "minItems": 1,
            "maxItems": 100,
            "description": "Print only these checkpoints. Ids of another location, archived, draft or non-QR checkpoints are skipped. Omit to print every printable checkpoint of the location."
          }
        }
      },
      "CreateQrSheetResponse": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Link to the PDF. It works without a session until `expiresAt`, but only while the user who requested it is still an active EDITOR of the location."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "checkpointCount": {
            "type": "integer",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "pageCount": {
            "type": "integer",
            "minimum": 0,
            "exclusiveMinimum": true
          }
        },
        "required": [
          "url",
          "expiresAt",
          "checkpointCount",
          "pageCount"
        ]
      },
      "AccessLogsListResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "locationId": {
                  "type": "string",
                  "format": "uuid"
                },
                "zone": {
                  "type": "string",
                  "nullable": true
                },
                "authorizedPersonId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "authorizedPersonIdentifier": {
                  "type": "string",
                  "nullable": true
                },
                "authorizedPersonName": {
                  "type": "string",
                  "nullable": true
                },
                "registeredByUserId": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "ENTRY",
                    "EXIT"
                  ]
                },
                "timestamp": {
                  "type": "string"
                },
                "visitorName": {
                  "type": "string",
                  "nullable": true
                },
                "visitorDocument": {
                  "type": "string",
                  "nullable": true
                },
                "visitorCompany": {
                  "type": "string",
                  "nullable": true
                },
                "destination": {
                  "type": "string",
                  "nullable": true
                },
                "notes": {
                  "type": "string",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string"
                },
                "redacted": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "locationId",
                "zone",
                "authorizedPersonId",
                "authorizedPersonIdentifier",
                "authorizedPersonName",
                "registeredByUserId",
                "type",
                "timestamp",
                "visitorName",
                "visitorDocument",
                "visitorCompany",
                "destination",
                "notes",
                "createdAt",
                "redacted"
              ]
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "total",
          "page",
          "limit"
        ]
      },
      "ActiveEntriesResponse": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "format": "uuid"
            },
            "locationId": {
              "type": "string",
              "format": "uuid"
            },
            "zone": {
              "type": "string",
              "nullable": true
            },
            "authorizedPersonId": {
              "type": "string",
              "nullable": true,
              "format": "uuid"
            },
            "authorizedPersonIdentifier": {
              "type": "string",
              "nullable": true
            },
            "authorizedPersonName": {
              "type": "string",
              "nullable": true
            },
            "registeredByUserId": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "ENTRY",
                "EXIT"
              ]
            },
            "timestamp": {
              "type": "string"
            },
            "visitorName": {
              "type": "string",
              "nullable": true
            },
            "visitorDocument": {
              "type": "string",
              "nullable": true
            },
            "visitorCompany": {
              "type": "string",
              "nullable": true
            },
            "destination": {
              "type": "string",
              "nullable": true
            },
            "notes": {
              "type": "string",
              "nullable": true
            },
            "createdAt": {
              "type": "string"
            },
            "redacted": {
              "type": "boolean"
            }
          },
          "required": [
            "id",
            "locationId",
            "zone",
            "authorizedPersonId",
            "authorizedPersonIdentifier",
            "authorizedPersonName",
            "registeredByUserId",
            "type",
            "timestamp",
            "visitorName",
            "visitorDocument",
            "visitorCompany",
            "destination",
            "notes",
            "createdAt",
            "redacted"
          ]
        }
      },
      "IncidentsListResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "locationId": {
                  "type": "string",
                  "format": "uuid"
                },
                "organizationId": {
                  "type": "string",
                  "format": "uuid"
                },
                "title": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "OPEN",
                    "IN_PROGRESS",
                    "RESOLVED",
                    "DISCARDED",
                    "CLOSED"
                  ]
                },
                "priority": {
                  "type": "string",
                  "enum": [
                    "LOW",
                    "MEDIUM",
                    "HIGH",
                    "CRITICAL"
                  ]
                },
                "categoryId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "subcategoryId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "categoryName": {
                  "type": "string",
                  "nullable": true
                },
                "subcategoryName": {
                  "type": "string",
                  "nullable": true
                },
                "reportedByPatrollerId": {
                  "type": "string"
                },
                "reporterName": {
                  "type": "string",
                  "nullable": true
                },
                "assignedToUserId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "assignedToName": {
                  "type": "string",
                  "nullable": true
                },
                "latitude": {
                  "type": "number",
                  "nullable": true
                },
                "longitude": {
                  "type": "number",
                  "nullable": true
                },
                "scanId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "routeRoundId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "resolvedAt": {
                  "type": "string",
                  "nullable": true
                },
                "closedAt": {
                  "type": "string",
                  "nullable": true
                },
                "clientId": {
                  "type": "string"
                },
                "checkpoints": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "name"
                    ]
                  }
                },
                "createdAt": {
                  "type": "string"
                },
                "updatedAt": {
                  "type": "string"
                },
                "redacted": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "locationId",
                "organizationId",
                "title",
                "description",
                "status",
                "priority",
                "categoryId",
                "subcategoryId",
                "categoryName",
                "subcategoryName",
                "reportedByPatrollerId",
                "reporterName",
                "assignedToUserId",
                "assignedToName",
                "latitude",
                "longitude",
                "scanId",
                "routeRoundId",
                "resolvedAt",
                "closedAt",
                "clientId",
                "checkpoints",
                "createdAt",
                "updatedAt",
                "redacted"
              ]
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "total",
          "page",
          "limit"
        ]
      },
      "GuardAppBlockedResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "GUARD_APP_BLOCKED"
                ]
              }
            },
            "required": [
              "code"
            ]
          }
        },
        "required": [
          "success",
          "message",
          "data"
        ]
      },
      "IncidentDetailResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "locationId": {
            "type": "string",
            "format": "uuid"
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "OPEN",
              "IN_PROGRESS",
              "RESOLVED",
              "DISCARDED",
              "CLOSED"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "LOW",
              "MEDIUM",
              "HIGH",
              "CRITICAL"
            ]
          },
          "categoryId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "subcategoryId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "categoryName": {
            "type": "string",
            "nullable": true
          },
          "subcategoryName": {
            "type": "string",
            "nullable": true
          },
          "reportedByPatrollerId": {
            "type": "string"
          },
          "reporterName": {
            "type": "string",
            "nullable": true
          },
          "assignedToUserId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "assignedToName": {
            "type": "string",
            "nullable": true
          },
          "latitude": {
            "type": "number",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "scanId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "routeRoundId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "resolvedAt": {
            "type": "string",
            "nullable": true
          },
          "closedAt": {
            "type": "string",
            "nullable": true
          },
          "clientId": {
            "type": "string"
          },
          "checkpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "redacted": {
            "type": "boolean"
          },
          "timeline": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "incidentId": {
                  "type": "string",
                  "format": "uuid"
                },
                "type": {
                  "type": "string"
                },
                "content": {
                  "type": "string",
                  "nullable": true
                },
                "authorName": {
                  "type": "string",
                  "nullable": true
                },
                "oldValue": {
                  "type": "string",
                  "nullable": true
                },
                "newValue": {
                  "type": "string",
                  "nullable": true
                },
                "mediaUrl": {
                  "type": "string",
                  "nullable": true
                },
                "mediaThumbnailUrl": {
                  "type": "string",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "incidentId",
                "type",
                "content",
                "authorName",
                "oldValue",
                "newValue",
                "mediaUrl",
                "mediaThumbnailUrl",
                "createdAt"
              ]
            }
          },
          "media": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "url": {
                  "type": "string"
                },
                "thumbnailUrl": {
                  "type": "string",
                  "nullable": true
                },
                "filename": {
                  "type": "string",
                  "nullable": true
                },
                "createdAt": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "url",
                "thumbnailUrl",
                "filename",
                "createdAt"
              ]
            }
          }
        },
        "required": [
          "id",
          "locationId",
          "organizationId",
          "title",
          "description",
          "status",
          "priority",
          "categoryId",
          "subcategoryId",
          "categoryName",
          "subcategoryName",
          "reportedByPatrollerId",
          "reporterName",
          "assignedToUserId",
          "assignedToName",
          "latitude",
          "longitude",
          "scanId",
          "routeRoundId",
          "resolvedAt",
          "closedAt",
          "clientId",
          "checkpoints",
          "createdAt",
          "updatedAt",
          "redacted",
          "timeline",
          "media"
        ]
      },
      "UpdateIncidentStatusBody": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "OPEN",
              "IN_PROGRESS",
              "RESOLVED",
              "DISCARDED",
              "CLOSED"
            ]
          },
          "comment": {
            "type": "string",
            "nullable": true,
            "maxLength": 2000
          }
        },
        "required": [
          "status"
        ]
      },
      "AddIncidentCommentBody": {
        "type": "object",
        "properties": {
          "comment": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          }
        },
        "required": [
          "comment"
        ]
      },
      "IncidentTimelineEntryResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "incidentId": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string"
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "authorName": {
            "type": "string",
            "nullable": true
          },
          "oldValue": {
            "type": "string",
            "nullable": true
          },
          "newValue": {
            "type": "string",
            "nullable": true
          },
          "mediaUrl": {
            "type": "string",
            "nullable": true
          },
          "mediaThumbnailUrl": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "incidentId",
          "type",
          "content",
          "authorName",
          "oldValue",
          "newValue",
          "mediaUrl",
          "mediaThumbnailUrl",
          "createdAt"
        ]
      },
      "AssignIncidentBody": {
        "type": "object",
        "properties": {
          "assignToUserId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          }
        },
        "required": [
          "assignToUserId"
        ]
      },
      "PaymentPricesResponse": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "tierId": {
              "type": "string",
              "format": "uuid",
              "description": "What to send to `createCheckoutSession` to subscribe to this plan."
            },
            "tierName": {
              "type": "string"
            },
            "tierIdentifier": {
              "type": "string"
            },
            "price": {
              "type": "number",
              "description": "Monthly base price in major units (not cents), in `currency`."
            },
            "currency": {
              "type": "string"
            },
            "billingInterval": {
              "type": "string"
            },
            "features": {
              "type": "object",
              "additionalProperties": {
                "nullable": true
              }
            },
            "limits": {
              "type": "object",
              "additionalProperties": {
                "nullable": true
              }
            },
            "pricing": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/PlanPricing"
                }
              ],
              "nullable": true,
              "description": "null for Free, or for an older plan that is no longer sold."
            }
          },
          "required": [
            "tierId",
            "tierName",
            "tierIdentifier",
            "price",
            "currency",
            "billingInterval",
            "features",
            "limits",
            "pricing"
          ]
        }
      },
      "CreateCheckoutSessionBody": {
        "type": "object",
        "properties": {
          "tierId": {
            "type": "string",
            "format": "uuid"
          },
          "interval": {
            "type": "string",
            "enum": [
              "month",
              "year"
            ],
            "default": "month",
            "description": "Billing interval chosen by the user."
          },
          "successUrl": {
            "type": "string",
            "format": "uri"
          },
          "cancelUrl": {
            "type": "string",
            "format": "uri"
          },
          "country": {
            "type": "string",
            "nullable": true,
            "description": "ISO-2 country confirmed in the plan selector. Ignored when the organization already has its currency fixed."
          }
        },
        "required": [
          "tierId",
          "successUrl",
          "cancelUrl"
        ]
      },
      "CreateCheckoutSessionResponse": {
        "type": "object",
        "properties": {
          "sessionUrl": {
            "type": "string",
            "format": "uri",
            "description": "The payment provider's checkout page. It expires after about 23 hours."
          }
        },
        "required": [
          "sessionUrl"
        ]
      },
      "CreateCustomerPortalSessionBody": {
        "type": "object",
        "properties": {
          "returnUrl": {
            "type": "string",
            "format": "uri",
            "description": "Where the user returns when leaving the payment provider's portal."
          }
        },
        "required": [
          "returnUrl"
        ]
      },
      "CreateCustomerPortalSessionResponse": {
        "type": "object",
        "properties": {
          "sessionUrl": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "sessionUrl"
        ]
      },
      "GetLicenseInfoResponse": {
        "type": "object",
        "properties": {
          "license": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "organizationId": {
                "type": "string",
                "format": "uuid"
              },
              "tierId": {
                "type": "string",
                "format": "uuid"
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "trial",
                  "bonus",
                  "expired",
                  "cancelled",
                  "past_due"
                ]
              },
              "trialStartDate": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              },
              "trialEndDate": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              },
              "currentPeriodStart": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              },
              "currentPeriodEnd": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              },
              "cancelAtPeriodEnd": {
                "type": "boolean"
              },
              "bonusOrigin": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "trial",
                  "extension",
                  "second_trial",
                  "grace",
                  "courtesy",
                  null
                ],
                "description": "Why the licence is a `bonus` (null otherwise): `trial` is the 14-day Business trial given at signup (or the 7-day launch trial), `extension` and `second_trial` are granted by an operator, `grace` is a few days of margin on the current plan for an account over the free limits, `courtesy` is any other manual grant. A trial, its extension and a second trial are always on the Business plan; all but a courtesy end on `currentPeriodEnd`."
              },
              "metadata": {
                "type": "object",
                "nullable": true,
                "additionalProperties": {
                  "nullable": true
                }
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": [
              "id",
              "organizationId",
              "tierId",
              "status",
              "trialStartDate",
              "trialEndDate",
              "currentPeriodStart",
              "currentPeriodEnd",
              "cancelAtPeriodEnd",
              "bonusOrigin",
              "metadata",
              "createdAt",
              "updatedAt"
            ]
          },
          "tier": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "identifier": {
                "type": "string"
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "price": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "billingInterval": {
                "type": "string",
                "enum": [
                  "month",
                  "year"
                ]
              },
              "features": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "limits": {
                "type": "object",
                "additionalProperties": {
                  "nullable": true
                }
              },
              "isActive": {
                "type": "boolean"
              },
              "sortOrder": {
                "type": "integer"
              }
            },
            "required": [
              "id",
              "name",
              "identifier",
              "description",
              "price",
              "currency",
              "billingInterval",
              "features",
              "limits",
              "isActive",
              "sortOrder"
            ]
          },
          "isTrialActive": {
            "type": "boolean",
            "description": "True while the organization is in a trial that has not ended: the 14-day Business trial (a `bonus` licence whose `bonusOrigin` is `trial`, `extension` or `second_trial`) or a payment-provider trial (status `trial`)."
          },
          "isBusinessTrial": {
            "type": "boolean",
            "description": "True while the licence is on the Business trial and it has not ended: a `bonus` on the Business plan whose `bonusOrigin` is `trial`, `extension` or `second_trial`, before its end date (the backend rule). Clients read this instead of deriving it from the origin."
          },
          "trialDaysRemaining": {
            "type": "number",
            "nullable": true,
            "description": "Whole days left in the active trial (rounded up, never negative); null when not in a trial."
          },
          "canUpgradeTo": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "identifier": {
                  "type": "string"
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "price": {
                  "type": "number"
                },
                "currency": {
                  "type": "string"
                },
                "billingInterval": {
                  "type": "string",
                  "enum": [
                    "month",
                    "year"
                  ]
                },
                "features": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "limits": {
                  "type": "object",
                  "additionalProperties": {
                    "nullable": true
                  }
                },
                "isActive": {
                  "type": "boolean"
                },
                "sortOrder": {
                  "type": "integer"
                }
              },
              "required": [
                "id",
                "name",
                "identifier",
                "description",
                "price",
                "currency",
                "billingInterval",
                "features",
                "limits",
                "isActive",
                "sortOrder"
              ]
            }
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LicenseUsage"
              }
            ],
            "nullable": true
          },
          "exceedsFreeAllowance": {
            "type": "boolean",
            "description": "True when what the organization uses (checkpoints, locations or managers) is over the Free plan limits, whatever plan or bonus it has now. It does not mean the organization is blocked: a block applies only on the Free plan with no subscription and no running bonus. False when it pays a subscription that renews; a subscription set to cancel at period end counts, since it goes back to Free when the period ends."
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR",
              "USD"
            ]
          },
          "hasActiveSubscription": {
            "type": "boolean",
            "description": "True when the organization already pays a live subscription with the payment provider (active, trialing or past due, including one set to cancel at period end), the same rule that makes checkout answer ALREADY_SUBSCRIBED. False for a free plan, a bonus, or a cancelled or expired subscription. Use it to offer subscription management instead of a new checkout."
          }
        },
        "required": [
          "license",
          "tier",
          "isTrialActive",
          "isBusinessTrial",
          "trialDaysRemaining",
          "canUpgradeTo",
          "usage",
          "exceedsFreeAllowance",
          "currency",
          "hasActiveSubscription"
        ]
      },
      "OAuthAuthorizationServerMetadata": {
        "type": "object",
        "properties": {
          "issuer": {
            "type": "string"
          },
          "authorization_endpoint": {
            "type": "string"
          },
          "token_endpoint": {
            "type": "string"
          },
          "registration_endpoint": {
            "type": "string"
          },
          "revocation_endpoint": {
            "type": "string"
          },
          "jwks_uri": {
            "type": "string"
          },
          "response_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code_challenge_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "revocation_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "client_id_metadata_document_supported": {
            "type": "boolean"
          },
          "authorization_response_iss_parameter_supported": {
            "type": "boolean"
          }
        },
        "required": [
          "issuer",
          "authorization_endpoint",
          "token_endpoint",
          "registration_endpoint",
          "revocation_endpoint",
          "jwks_uri",
          "response_types_supported",
          "grant_types_supported",
          "code_challenge_methods_supported",
          "token_endpoint_auth_methods_supported",
          "revocation_endpoint_auth_methods_supported",
          "scopes_supported",
          "client_id_metadata_document_supported",
          "authorization_response_iss_parameter_supported"
        ]
      },
      "OAuthJwks": {
        "type": "object",
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "nullable": true
              }
            }
          }
        },
        "required": [
          "keys"
        ]
      },
      "OAuthErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "error_description"
        ]
      },
      "OAuthRegisterClientRequest": {
        "type": "object",
        "properties": {
          "client_name": {
            "type": "string"
          },
          "logo_uri": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_method": {
            "type": "string"
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "redirect_uris"
        ]
      },
      "OAuthRegisterClientResponse": {
        "type": "object",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_id_issued_at": {
            "type": "integer"
          },
          "client_name": {
            "type": "string"
          },
          "logo_uri": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "none"
            ]
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "client_id",
          "client_id_issued_at",
          "client_name",
          "redirect_uris",
          "token_endpoint_auth_method",
          "grant_types",
          "response_types"
        ]
      },
      "OAuthTokenRequest": {
        "type": "object",
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "authorization_code",
              "refresh_token"
            ]
          },
          "client_id": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "redirect_uri": {
            "type": "string"
          },
          "code_verifier": {
            "type": "string"
          },
          "refresh_token": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          },
          "resource": {
            "type": "string"
          }
        },
        "required": [
          "grant_type",
          "client_id"
        ]
      },
      "OAuthTokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer"
          },
          "refresh_token": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          }
        },
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "refresh_token",
          "scope"
        ]
      },
      "OAuthRevokeRequest": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "token_type_hint": {
            "type": "string",
            "enum": [
              "access_token",
              "refresh_token"
            ]
          },
          "client_id": {
            "type": "string"
          }
        },
        "required": [
          "token",
          "client_id"
        ]
      },
      "OAuthAgentSessionResponse": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "expires_at": {
            "type": "integer"
          },
          "scope": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          }
        },
        "required": [
          "token",
          "expires_at",
          "scope",
          "user_id"
        ]
      },
      "ListLocationsResponse": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "format": "uuid"
            },
            "name": {
              "type": "string",
              "nullable": true
            },
            "address": {
              "type": "string"
            },
            "city": {
              "type": "string",
              "nullable": true
            },
            "organizationId": {
              "type": "string",
              "nullable": true,
              "format": "uuid"
            },
            "vertical": {
              "$ref": "#/components/schemas/Vertical"
            },
            "archivedAt": {
              "type": "string",
              "nullable": true,
              "format": "date-time"
            },
            "createdAt": {
              "type": "string",
              "format": "date-time"
            },
            "updatedAt": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "id",
            "address",
            "vertical"
          ]
        }
      },
      "CreateLocationBody": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Trimmed before it is checked and stored."
          },
          "address": {
            "type": "string",
            "nullable": true,
            "description": "May be empty or `null` (stored as an empty string)."
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "name",
          "organizationId"
        ]
      },
      "LocationResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "type": "string"
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "vertical": {
            "$ref": "#/components/schemas/Vertical"
          },
          "archivedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "address",
          "vertical"
        ]
      },
      "UpdateLocationBody": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "address": {
            "type": "string",
            "nullable": true,
            "description": "`null` clears it (stored as an empty string)."
          },
          "city": {
            "type": "string"
          }
        },
        "description": "Only name, address and city are applied; any other field is ignored."
      },
      "LocationConflict": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "LAST_LOCATION",
              "LOCATION_HAS_HISTORY",
              "LOCATION_ALREADY_ARCHIVED",
              "LOCATION_NOT_ARCHIVED"
            ]
          },
          "data": {
            "nullable": true
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "message",
          "code",
          "data",
          "error"
        ]
      },
      "ListPatrollersResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "identifier": {
                  "type": "string"
                },
                "email": {
                  "type": "string",
                  "nullable": true
                },
                "phone": {
                  "type": "string",
                  "nullable": true
                },
                "organizationId": {
                  "type": "string",
                  "format": "uuid"
                },
                "organizationName": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "archivedAt": {
                  "type": "string",
                  "nullable": true,
                  "format": "date-time"
                },
                "lastScanDate": {
                  "type": "string",
                  "nullable": true,
                  "format": "date-time"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "active",
                    "inactive",
                    "alert"
                  ]
                }
              },
              "required": [
                "id",
                "name",
                "identifier",
                "organizationId",
                "createdAt",
                "status"
              ]
            }
          },
          "count": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "count",
          "totalPages"
        ]
      },
      "CreatePatrollerBody": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "identifier": {
            "type": "string",
            "maxLength": 8,
            "description": "What the guard app signs in with, unique across PatrolTech (at most 8 characters, the size of the column). Omitted: the server generates one (8 upper-case hex characters)."
          },
          "email": {
            "type": "string",
            "nullable": true,
            "format": "email"
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "name",
          "organizationId"
        ]
      },
      "PatrollerResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "identifier": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "organizationName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "archivedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "lastScanDate": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "alert"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "identifier",
          "organizationId",
          "createdAt",
          "status"
        ]
      },
      "UpdatePatrollerBody": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "format": "email"
          },
          "phone": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PatrollerRankingResponse": {
        "type": "object",
        "properties": {
          "summary": {
            "type": "object",
            "properties": {
              "totalScans": {
                "type": "integer"
              },
              "activePatrollers": {
                "type": "integer"
              },
              "avgScansPerPatroller": {
                "type": "number"
              },
              "bestCompletionRate": {
                "type": "number"
              }
            },
            "required": [
              "totalScans",
              "activePatrollers",
              "avgScansPerPatroller",
              "bestCompletionRate"
            ]
          },
          "ranking": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "patrollerId": {
                  "type": "string",
                  "nullable": true,
                  "format": "uuid"
                },
                "patrollerName": {
                  "type": "string"
                },
                "patrollerIdentifier": {
                  "type": "string"
                },
                "totalScans": {
                  "type": "integer"
                },
                "roundsCompleted": {
                  "type": "integer"
                },
                "completionRate": {
                  "type": "number",
                  "description": "Percent (0-100, rounded) of the checkpoints scanned out of all the checkpoints of the rounds of the patroller in the window; 0 without rounds. It is not the share of rounds completed (see `roundsCompleted`)."
                },
                "avgTimeBetweenScans": {
                  "type": "number",
                  "nullable": true
                },
                "archived": {
                  "type": "boolean"
                }
              },
              "required": [
                "patrollerId",
                "patrollerName",
                "patrollerIdentifier",
                "totalScans",
                "roundsCompleted",
                "completionRate",
                "avgTimeBetweenScans",
                "archived"
              ]
            }
          },
          "topCheckpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "checkpointName": {
                  "type": "string"
                },
                "totalScans": {
                  "type": "integer"
                }
              },
              "required": [
                "checkpointName",
                "totalScans"
              ]
            }
          },
          "retentionCutoff": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "Earliest instant the plan's data retention lets the ranking count; null when unlimited."
          }
        },
        "required": [
          "summary",
          "ranking",
          "topCheckpoints",
          "retentionCutoff"
        ]
      },
      "PatrollerStatsResponse": {
        "type": "object",
        "properties": {
          "totalScans": {
            "type": "integer"
          },
          "roundsCompleted": {
            "type": "integer"
          },
          "totalRounds": {
            "type": "integer"
          },
          "completionRate": {
            "type": "number",
            "description": "Percent (0-100, rounded) of the checkpoints scanned out of all the checkpoints of the rounds of the patroller in the window; 0 without rounds. It is not the share of rounds completed (see `roundsCompleted`)."
          },
          "avgTimeBetweenScans": {
            "type": "number",
            "nullable": true
          },
          "scansByDay": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              },
              "required": [
                "date",
                "count"
              ]
            }
          },
          "incidentsReported": {
            "type": "integer"
          },
          "incidentsOpen": {
            "type": "integer"
          },
          "retentionCutoff": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "Days of `scansByDay` before this instant are outside the plan's data retention; null when unlimited."
          }
        },
        "required": [
          "totalScans",
          "roundsCompleted",
          "totalRounds",
          "completionRate",
          "avgTimeBetweenScans",
          "scansByDay",
          "retentionCutoff"
        ]
      },
      "ListScansResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScanListItem"
            }
          },
          "count": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        },
        "required": [
          "results",
          "count",
          "totalPages"
        ]
      },
      "PaginatedRoutes": {
        "type": "object",
        "required": [
          "results",
          "count",
          "totalPages"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Route"
            }
          },
          "count": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        }
      },
      "RouteCheckpoint": {
        "type": "object",
        "required": [
          "id",
          "routeId",
          "checkpointId",
          "order"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "routeId": {
            "type": "string"
          },
          "checkpointId": {
            "type": "string"
          },
          "order": {
            "type": "integer"
          },
          "checkpoint": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "RouteTimeWindow": {
        "type": "object",
        "required": [
          "id",
          "routeId",
          "startTime",
          "endTime",
          "days"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "routeId": {
            "type": "string"
          },
          "startTime": {
            "type": "string"
          },
          "endTime": {
            "type": "string"
          },
          "days": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "timezone": {
            "type": "string",
            "nullable": true,
            "description": "IANA timezone the window was configured in, or null for windows created before it was recorded. Clients must edit the schedule in THIS timezone, not in the timezone of whoever opens the form: sending back a different one would re-label the route and shift it on the next DST change."
          },
          "utcOffsetMinutes": {
            "type": "integer",
            "nullable": true,
            "description": "Offset in minutes applied when the local times were converted to UTC, or null. Recorded so the backend can re-project the window when the offset changes (DST)."
          }
        }
      },
      "RouteWithDetails": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Route"
          },
          {
            "type": "object",
            "properties": {
              "checkpoints": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RouteCheckpoint"
                }
              },
              "isFirstRoute": {
                "type": "boolean",
                "description": "Only on create. True when this is the first route of the organization, decided atomically server-side."
              },
              "timeWindows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RouteTimeWindow"
                }
              }
            }
          }
        ]
      },
      "RouteGuardMode": {
        "type": "string",
        "enum": [
          "strict",
          "flexible"
        ]
      },
      "RouteScheduleMode": {
        "type": "string",
        "enum": [
          "strict",
          "flexible"
        ]
      },
      "RouteRoundsPage": {
        "type": "object",
        "required": [
          "results",
          "count",
          "totalPages"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RouteRound"
            }
          },
          "count": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        }
      },
      "RouteRoundCheckpointItem": {
        "type": "object",
        "required": [
          "checkpointId",
          "checkpointName",
          "order",
          "scanned",
          "scanTime"
        ],
        "properties": {
          "checkpointId": {
            "type": "string"
          },
          "checkpointName": {
            "type": "string",
            "nullable": true
          },
          "order": {
            "type": "integer"
          },
          "scanned": {
            "type": "boolean"
          },
          "scanTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "Route": {
        "type": "object",
        "required": [
          "id",
          "name",
          "identifier",
          "requiresOrderedScan",
          "guardMode",
          "scheduleMode",
          "isActive",
          "organizationId",
          "locationId",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "identifier": {
            "type": "string"
          },
          "requiresOrderedScan": {
            "type": "boolean"
          },
          "guardMode": {
            "$ref": "#/components/schemas/RouteGuardMode"
          },
          "scheduleMode": {
            "$ref": "#/components/schemas/RouteScheduleMode"
          },
          "isActive": {
            "type": "boolean"
          },
          "organizationId": {
            "type": "string"
          },
          "locationId": {
            "type": "string"
          },
          "version": {
            "type": "integer",
            "description": "Optimistic-concurrency counter. Send it back as `expectedVersion` on update."
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the route was archived because it has history; null while in use. An archived route is inactive and left out of lists unless `includeArchived=true`."
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        }
      },
      "AgentProposalItem": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "Name of the catalogue action."
          },
          "params": {
            "type": "object",
            "additionalProperties": {
              "nullable": true
            },
            "description": "Parameters of the action: must be a JSON object (not an array or a bare value). Its JSON is at most 16384 bytes (400 PARAMS_TOO_LARGE)."
          },
          "organizationId": {
            "type": "string",
            "nullable": true,
            "format": "uuid",
            "description": "Organization the action affects. If given, the user must belong to it (any role); otherwise 403 ORGANIZATION_NOT_ALLOWED."
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "required": [
          "action",
          "params"
        ]
      },
      "Vertical": {
        "type": "string",
        "enum": [
          "security",
          "cleaning"
        ],
        "description": "Business vertical of an organization or location: `security` or `cleaning`."
      },
      "PlanPricing": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "pro",
              "business"
            ]
          },
          "includedCheckpoints": {
            "type": "integer",
            "description": "Checkpoints included in the base price."
          },
          "monthly": {
            "type": "object",
            "properties": {
              "base": {
                "type": "object",
                "properties": {
                  "eur": {
                    "type": "integer"
                  },
                  "usd": {
                    "type": "integer"
                  }
                },
                "required": [
                  "eur",
                  "usd"
                ]
              },
              "extra": {
                "type": "object",
                "properties": {
                  "eur": {
                    "type": "integer"
                  },
                  "usd": {
                    "type": "integer"
                  }
                },
                "required": [
                  "eur",
                  "usd"
                ],
                "description": "Cost of EACH checkpoint above the included ones."
              }
            },
            "required": [
              "base",
              "extra"
            ]
          },
          "yearly": {
            "type": "object",
            "properties": {
              "base": {
                "type": "object",
                "properties": {
                  "eur": {
                    "type": "integer"
                  },
                  "usd": {
                    "type": "integer"
                  }
                },
                "required": [
                  "eur",
                  "usd"
                ]
              },
              "extra": {
                "type": "object",
                "properties": {
                  "eur": {
                    "type": "integer"
                  },
                  "usd": {
                    "type": "integer"
                  }
                },
                "required": [
                  "eur",
                  "usd"
                ]
              }
            },
            "required": [
              "base",
              "extra"
            ],
            "description": "Yearly amounts, already multiplied. Derived from the monthly ones, like the yearly prices that are actually charged."
          },
          "monthsBilledYearly": {
            "type": "integer",
            "description": "Months paid when choosing yearly billing (12 minus this = free months)."
          }
        },
        "required": [
          "plan",
          "includedCheckpoints",
          "monthly",
          "yearly",
          "monthsBilledYearly"
        ]
      },
      "LicenseUsage": {
        "type": "object",
        "properties": {
          "checkpoints": {
            "type": "object",
            "properties": {
              "used": {
                "type": "integer"
              },
              "included": {
                "type": "integer",
                "nullable": true
              },
              "extra": {
                "type": "integer"
              }
            },
            "required": [
              "used",
              "included",
              "extra"
            ]
          },
          "locations": {
            "type": "object",
            "properties": {
              "used": {
                "type": "integer"
              },
              "limit": {
                "type": "integer",
                "nullable": true
              }
            },
            "required": [
              "used",
              "limit"
            ]
          },
          "managers": {
            "type": "object",
            "properties": {
              "used": {
                "type": "integer"
              },
              "limit": {
                "type": "integer",
                "nullable": true
              }
            },
            "required": [
              "used",
              "limit"
            ]
          }
        },
        "required": [
          "checkpoints",
          "locations",
          "managers"
        ]
      },
      "ScanListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "checkpointName": {
            "type": "string",
            "nullable": true
          },
          "patrollerName": {
            "type": "string",
            "nullable": true
          },
          "patrollerIdentification": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "deviceInfo": {
            "type": "object",
            "nullable": true,
            "properties": {
              "deviceName": {
                "type": "string",
                "nullable": true
              },
              "platform": {
                "type": "string",
                "nullable": true
              },
              "osVersion": {
                "type": "string",
                "nullable": true
              },
              "manufacturer": {
                "type": "string",
                "nullable": true
              },
              "batteryLevel": {
                "type": "number",
                "nullable": true
              },
              "batteryStatus": {
                "type": "string",
                "nullable": true
              },
              "connectionType": {
                "type": "string",
                "nullable": true
              },
              "connectionDownlink": {
                "type": "number",
                "nullable": true
              }
            },
            "required": [
              "deviceName",
              "platform",
              "osVersion",
              "manufacturer",
              "batteryLevel",
              "batteryStatus",
              "connectionType",
              "connectionDownlink"
            ]
          },
          "location": {
            "type": "object",
            "nullable": true,
            "properties": {
              "latitude": {
                "type": "number"
              },
              "longitude": {
                "type": "number"
              }
            },
            "required": [
              "latitude",
              "longitude"
            ]
          },
          "fraudFlags": {
            "type": "object",
            "nullable": true,
            "properties": {
              "flagged": {
                "type": "boolean"
              },
              "gpsProximity": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "pass",
                      "fail",
                      "skipped"
                    ]
                  },
                  "distanceMeters": {
                    "type": "number",
                    "nullable": true
                  },
                  "accuracyMeters": {
                    "type": "number",
                    "nullable": true
                  },
                  "effectiveDistanceMeters": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "required": [
                  "status",
                  "distanceMeters",
                  "accuracyMeters",
                  "effectiveDistanceMeters"
                ]
              },
              "undergroundMode": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "pass",
                      "fail",
                      "skipped"
                    ]
                  },
                  "connectionType": {
                    "type": "string",
                    "nullable": true
                  },
                  "connectionDownlink": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "required": [
                  "status",
                  "connectionType",
                  "connectionDownlink"
                ]
              }
            },
            "required": [
              "flagged"
            ]
          },
          "validationStatus": {
            "type": "string",
            "nullable": true,
            "enum": [
              "verified",
              "pending_review",
              "rejected",
              null
            ]
          },
          "validationReason": {
            "type": "string",
            "nullable": true
          },
          "redacted": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "checkpointName",
          "patrollerName",
          "patrollerIdentification",
          "timestamp",
          "deviceInfo",
          "location",
          "fraudFlags",
          "validationStatus",
          "validationReason",
          "redacted"
        ]
      },
      "RouteRound": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "oauthAccessToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "OAuth access token issued by POST /oauth/token"
      }
    }
  }
}
