{"openapi":"3.1.0","info":{"title":"BKL Backend","description":"\nBackend API for guarding operations: the **companies** that do the guarding, the\n**clients** they do it for, the **sites** and **posts** being guarded, the\n**guards** who stand them, the **shifts** they are rostered for, the\n**check-ins** that prove they were there, and the **incidents** they report.\n\n### Getting started\n\n* Register a company with `POST /api/v1/companies` - the person's `full_name`, the\n  company's `name`, `email` and `phone`, a `password`, and `terms_and_conditions`\n* Log in with `POST /api/v1/auth/login` and send the token as\n  `Authorization: Bearer <access_token>` (or use **Authorize** above, slug as username)\n* Register guards under it with `POST /api/v1/companies/{company_id}/users`\n\nA hands-on walkthrough with copy-pasteable `curl` calls lives at\n[`/testing`](/testing). ReDoc lives at [`/redoc`](/redoc).\n\n### Two things worth knowing\n\n**A check-in is measured against its site.** Give a site a pin and a radius and\nevery check-in there is judged once, when it is written, and the verdict is kept:\n`verified`, `outside_radius`, `unverified_source`, `no_coordinates` or\n`no_site_pin`. `location_source=device` is the only source that can be verified -\nWhatsApp's location request lets the sender type an address instead of sharing\ntheir position, and the message looks the same either way. Until a site has a pin,\ncheck-ins there are recorded `no_site_pin` rather than quietly accepted.\n\n**Auth is required.** `REQUIRE_AUTH_FOR_READS` and\n`REQUIRE_AUTH_FOR_GUARD_ACTIONS` both default to **on**: every read and every\nguard action needs `Authorization: Bearer <token>`. Log in as a company\n(`/auth/login`) or a person (`/auth/user/login`), or - for a front end or\nintegration acting for one known account - send the deployment's\n`SERVICE_API_TOKEN`, which authenticates as its configured company.\n\nA caller is held to its own company and its branches, on **every** route - the\nones with a company in the path and the ones naming a single record. Reading\nanother tenant's guard, shift, attendance row, incident or site is a 403. See\n[`GET /api/v1/auth/posture`](/docs#/auth/posture_api_v1_auth_posture_get).\n\n**Times are instants, in UTC.** Every timestamp is stored and returned in UTC;\nrender it in whatever zone suits. Two things are not instants and need to know\nwhere the company is - what *today* means for a date-only field like\n`psira_expiry`, and what a datetime sent with **no offset** means (wall-clock time\nin the deployment's zone, not UTC). See\n[`GET /api/v1/time`](/docs#/health/server_time_api_v1_time_get).\n\nCheck-in, check-out and incident reports are `multipart/form-data`: photos are\nuploaded to MinIO, into a bucket of the company's own, created on first use.\n\n### Getting your existing staff list in\n\n`POST /api/v1/companies/{company_id}/users/import/preview` reads a `.xlsx` or\n`.csv` staff list and reports, row by row, what importing it would do - without\nwriting anything. Post the same file to `.../import` to commit it, all rows or\nnone. Headings are matched loosely and the header row need not be the first, so an\nexisting staff list usually needs no editing at all.\n","version":"0.1.0"},"paths":{"/health":{"get":{"tags":["health"],"summary":"Liveness probe","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Health Get"}}}}}}},"/health/db":{"get":{"tags":["health"],"summary":"Readiness probe (checks Postgres)","operationId":"health_db_health_db_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/health/storage":{"get":{"tags":["health"],"summary":"Readiness probe (checks MinIO)","operationId":"health_storage_health_storage_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/time":{"get":{"tags":["health"],"summary":"The server's clock and timezone","description":"Every timestamp this API returns is an **instant**, sent in UTC - render it in whatever zone suits. Two things are not instants, and this is where to find out what they mean:\n\n* **A datetime you send with no offset** is read as wall-clock time in `timezone`, not UTC, because that is what an `<input type=\"datetime-local\">` produces. Send `...Z` or `+02:00` and nothing is assumed.\n* **A date-only field** such as `psira_expiry` carries no timezone at all, and is compared against `today` - the date where the company operates, not where the server runs.\n\nSet with `TIMEZONE`.","operationId":"server_time_api_v1_time_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerTime"}}}}}}},"/api/v1/auth/login":{"post":{"tags":["auth"],"summary":"Log in as a company","description":"Exchange a company's slug and password for a bearer token. Send it as `Authorization: Bearer <access_token>` to create users and sub-companies under that company, and to update or delete them. `user` is null on this token - see `/auth/user/login` for a token that names a person.","operationId":"login_api_v1_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyLogin"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/auth/token":{"post":{"tags":["auth"],"summary":"Log in as a company (OAuth2 form)","description":"Same as `/auth/login`, as an OAuth2 password form so Swagger's **Authorize** button works. Put the company slug in `username`.","operationId":"token_api_v1_auth_token_post","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_token_api_v1_auth_token_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/auth/user/login":{"post":{"tags":["auth","auth"],"summary":"Log in as a named person","description":"Exchange a company slug, a cell number and a password for a token that names a **person** rather than their company. Every action taken with it is recorded against them - which is what makes an audit trail say who closed an incident, instead of naming the shared company login.\n\nThe company is part of the credentials because a cell number identifies a user *within* a company: one person may work for two of them. A user registered without a password cannot log in, which is every guard by default - give them one with `PATCH /users/{user_id}` when they need to.\n\nA token from here carries the person's role. `owner` and `admin` may administer the company exactly as a company login does; `member` - a guard - may check themselves in and out and report incidents, and nothing else.","operationId":"user_login_api_v1_auth_user_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserLogin"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/auth/me":{"get":{"tags":["auth"],"summary":"The company the token belongs to","description":"Works for both kinds of token: a user's token answers with the company that person belongs to. Use `/auth/me/user` for the person.","operationId":"me_api_v1_auth_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyRead"}}}}},"security":[{"OAuth2PasswordBearer":[]}]}},"/api/v1/auth/me/user":{"get":{"tags":["auth"],"summary":"The person the token belongs to","description":"404 when the token is a company token, which names no person.","operationId":"me_user_api_v1_auth_me_user_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}}},"security":[{"OAuth2PasswordBearer":[]}]}},"/api/v1/auth/posture":{"get":{"tags":["auth"],"summary":"What this deployment requires","description":"Whether reads and guard actions currently need a token. Both default to **on**: a read or a check-in without `Authorization: Bearer <token>` is a 401.\n\nThey can be set to false to run the old open behaviour while a client that does not yet send a token is migrated; while off, every unauthenticated call to a protected route is logged at WARNING with its path. `REQUIRE_AUTH_FOR_READS` and `REQUIRE_AUTH_FOR_GUARD_ACTIONS` are the two switches.","operationId":"posture_api_v1_auth_posture_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthPosture"}}}}}}},"/api/v1/companies":{"post":{"tags":["companies"],"summary":"Register a company","description":"Two different acts, told apart by `parent_id`.\n\n**Registering a company** (no `parent_id`) needs no login, and collects `full_name` - the person signing up - plus the company's `name`, `email` and `phone`, a `password`, and `terms_and_conditions`, which must be `true`. `company_number` and `business_registration_number` are optional; the second is the PSiRA business registration, worth capturing because tenders ask for it. Acceptance is stored as the moment it happened, `terms_accepted_at`, because a yes with no date is not evidence of anything.\n\n**Adding a branch** (`parent_id` set) is an existing tenant adding one of its own places. Nobody is signing up, so none of the fields above are asked for - this is exactly the request it always was. Log in as that main company first; the tree is only two levels deep, so the parent must itself be a main company.\n\n`slug` is derived from `name` when omitted, must be unique across all companies, and is the company's login name alongside `password`.","operationId":"create_company_api_v1_companies_post","security":[{"OAuth2PasswordBearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyCreate"},"examples":{"registration":{"summary":"Register a company (no login needed)","description":"The sign-up form. `full_name` is the person; `name`, `email` and `phone` are the company's. `terms_and_conditions` must be true, and the moment of acceptance is recorded.","value":{"full_name":"Thabo Mokoena","name":"Acme Security","email":"hello@acme.example.com","phone":"+27 11 555 0100","password":"c0mpany-secret","terms_and_conditions":true,"company_number":"2019/123456/07","business_registration_number":"1234567"}},"registration_minimum":{"summary":"Register with only the required fields","value":{"full_name":"Thabo Mokoena","name":"Acme Security","email":"hello@acme.example.com","phone":"+27 11 555 0100","password":"c0mpany-secret","terms_and_conditions":true}},"branch":{"summary":"Branch beneath a main company (log in as it first)","description":"Adding a site, not signing up: no person, no terms. Unchanged from before.","value":{"name":"Acme Johannesburg","password":"branch-secret","parent_id":"<id of the main company you are logged in as>"}}}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["companies"],"summary":"List companies","operationId":"list_companies_api_v1_companies_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match name or slug","title":"Search"},"description":"Match name or slug"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},{"name":"parent_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Only companies beneath this one","title":"Parent Id"},"description":"Only companies beneath this one"},{"name":"only_main","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"true = main and standalone only, false = sub-companies only","title":"Only Main"},"description":"true = main and standalone only, false = sub-companies only"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_CompanyRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/registration-fields":{"get":{"tags":["companies"],"summary":"What registering a company collects","description":"The two shapes `POST /companies` accepts, as data a form can be built from.\n\nWorth having because the endpoint's OpenAPI request body cannot express this: a registration and a branch are different requests to the same path, so only the fields common to both appear in its `required` array. `full_name`, `email`, `phone` and `terms_and_conditions` are required to register and not asked for on a branch - **drive your form from this, not from the schema's `required`**.","operationId":"registration_fields_api_v1_companies_registration_fields_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegistrationFields"}}}}}}},"/api/v1/companies/{company_id}":{"get":{"tags":["companies"],"summary":"Get a company","operationId":"get_company_api_v1_companies__company_id__get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["companies"],"summary":"Update a company","description":"Requires logging in as this company or its main company.","operationId":"update_company_api_v1_companies__company_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["companies"],"summary":"Delete a company","description":"Deletes the company and cascades to its users and attendance records. Refused with a 409 while it still has sub-companies. Requires logging in as this company or its main company.","operationId":"delete_company_api_v1_companies__company_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/sub-companies":{"get":{"tags":["companies"],"summary":"Companies beneath this one","description":"The branches of a main company. Always empty for a sub-company, since the tree is only two levels deep.","operationId":"list_sub_companies_api_v1_companies__company_id__sub_companies_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_CompanyRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/sites":{"get":{"tags":["companies","sites"],"summary":"Sites under this company","description":"Every site this company runs, alphabetically. A site is a company one level beneath this one - the same rows as `/sub-companies`, in the slim shape a site list needs: where it is, whether it is in service, and how many guards are on its books. `search` matches the site name, slug or address, so 'sandton' finds everything there. Empty for a company that is itself a site, since companies go only one level deep.\n\nEach row now also carries `site_id`, `latitude`, `longitude` and `check_in_radius_m` from the site record behind it. **`GET /sites` is the fuller list**: it is not limited to one level, it groups sites under clients, and it holds the posts. This endpoint is kept because it has callers.","operationId":"list_sites_api_v1_companies__company_id__sites_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match site name, slug or address","title":"Search"},"description":"Match site name, slug or address"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"true = in service only, false = retired only","title":"Is Active"},"description":"true = in service only, false = retired only"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_SiteRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/users":{"post":{"tags":["companies","users"],"summary":"Register a user under a company","description":"**Two fields are required: `full_name` and `phone`** - the name, and the WhatsApp number. Everything else is optional: the PSiRA details, the grade, the category, the site, the guard number, the email and the password. A guard can be put on the books from a name and a number and filled in later.\n\nThe number identifies the user within this company and must be unique here. It is normalized to E.164 before storage, so '+27 82 123 4567' and '+27821234567' are the same number. `password` is optional because users do not log in - their company does - until one is given to them.\n\nRequires logging in as this company or its main company.","operationId":"create_company_user_api_v1_companies__company_id__users_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["companies","users"],"summary":"List a company's users","operationId":"list_company_users_api_v1_companies__company_id__users_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match phone, email or full name","title":"Search"},"description":"Match phone, email or full name"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Also include users of this company's sub-companies","default":false,"title":"Include Sub Companies"},"description":"Also include users of this company's sub-companies"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_UserRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/users/by-phone":{"get":{"tags":["companies","users"],"summary":"Look up a user by cell number","description":"Resolves a user within this company by their identifier. The number is normalized before matching, so any common formatting works. Set `include_sub_companies=true` on a main company to search its branches too - where the same number is registered in more than one of them, this company's own user is returned first.","operationId":"get_company_user_by_phone_api_v1_companies__company_id__users_by_phone_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"phone","in":"query","required":true,"schema":{"type":"string","description":"Cell number, any common format","title":"Phone"},"description":"Cell number, any common format"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Also search this company's sub-companies","default":false,"title":"Include Sub Companies"},"description":"Also search this company's sub-companies"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/register":{"post":{"tags":["users"],"summary":"Register a user (company in the body)","description":"Same as `POST /companies/{company_id}/users`, but the company is named in the request body instead of the path - and with the same two required fields, `full_name` and `phone`. The company may be a main company or one beneath it; every user belongs to exactly one. The WhatsApp number must be unique within that company. Requires logging in as that company or its main company.","operationId":"register_user_api_v1_users_register_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRegister"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"OAuth2PasswordBearer":[]}]}},"/api/v1/users":{"get":{"tags":["users"],"summary":"List users across companies","operationId":"list_users_api_v1_users_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Company Id"}},{"name":"site_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Only guards posted to this site","title":"Site Id"},"description":"Only guards posted to this site"},{"name":"category","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/GuardCategory"},{"type":"null"}],"title":"Category"}},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match phone, email, name or guard number","title":"Search"},"description":"Match phone, email, name or guard number"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_UserRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/roles":{"get":{"tags":["users"],"summary":"Roles a user can be given","description":"Every accepted value for `role` when registering or updating a user, in order of seniority. Values are lowercase and matched exactly. Roles are currently labels only: access is controlled by the company login, not by a user's role.","operationId":"list_roles_api_v1_users_roles_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/RoleRead"},"type":"array","title":"Response List Roles Api V1 Users Roles Get"}}}}}}},"/api/v1/users/categories":{"get":{"tags":["users"],"summary":"The guard categories","description":"What to send as `category`, and what each one means for firearm competency.","operationId":"list_categories_api_v1_users_categories_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/CategoryRead"},"type":"array","title":"Response List Categories Api V1 Users Categories Get"}}}}}}},"/api/v1/users/psira-grades":{"get":{"tags":["users"],"summary":"The PSiRA grades","description":"A to E, most senior first.","operationId":"list_grades_api_v1_users_psira_grades_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/GradeRead"},"type":"array","title":"Response List Grades Api V1 Users Psira Grades Get"}}}}}}},"/api/v1/users/{user_id}":{"get":{"tags":["users"],"summary":"Get a user","description":"Readable by the user's own company and by its main company. A token from anywhere else is refused, whatever `REQUIRE_AUTH_FOR_READS` says.","operationId":"get_user_api_v1_users__user_id__get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["users"],"summary":"Update a user","description":"Requires logging in as the user's company or its main company.\n\n`full_name` and `phone` can be **corrected** but not **cleared**: sending either as null is refused, because a guard must have a name and a WhatsApp number. Leave a field out to keep what is there. Every other field accepts null to clear it.\n\nA guard's **site, post, category and company can all be changed here** - the first of those could not be changed at all before. Each one that does change leaves an entry in the guard's history (`GET /users/{user_id}/assignments`) naming who moved them, when, and the `assignment_reason` if one was sent. Moving a guard to another company needs a login that manages both ends.","operationId":"update_user_api_v1_users__user_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["users"],"summary":"Delete a user","description":"Requires logging in as the user's company or its main company.","operationId":"delete_user_api_v1_users__user_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/assignments":{"get":{"tags":["users"],"summary":"A guard's posting history","description":"Every recorded move: site, post, company, category or guard number, newest first, with who made the change and why. Written only from the moment this history existed - a guard moved before that has no entry for it, and inventing one would be a lie.","operationId":"user_assignments_api_v1_users__user_id__assignments_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_AssignmentRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/photo":{"put":{"tags":["users"],"summary":"Set or replace the account photo","description":"`multipart/form-data` with a single `photo` file. A photo is optional for every user - one without it simply has `photo_url: null`. Replacing a photo removes the old object once the new one is committed. The file is stored in the user's own company bucket (`<MINIO_BUCKET_PREFIX>-<company slug>`), created on first use. Requires logging in as the user's company or its main company.","operationId":"set_user_photo_api_v1_users__user_id__photo_put","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_set_user_photo_api_v1_users__user_id__photo_put"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["users"],"summary":"Remove the account photo","description":"Clears the photo and deletes the stored object. Succeeds whether or not the user had one, so it is safe to call twice. Requires logging in as the user's company or its main company.","operationId":"delete_user_photo_api_v1_users__user_id__photo_delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/check-in":{"post":{"tags":["attendance"],"summary":"Check in","description":"`multipart/form-data`. Every field is optional, photo included - an empty form is a valid check-in. `assigned_check_in_at` and `assigned_check_out_at` record the shift the guard was rostered for, so the actual times can later be read against it; send either, both or neither. The photo is stored in the company's own bucket (`<MINIO_BUCKET_PREFIX>-<company slug>`), created on first use. Returns 409 if the user is already checked in.","operationId":"check_in_api_v1_users__user_id__check_in_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_check_in_api_v1_users__user_id__check_in_post"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttendanceRecordRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/check-out":{"post":{"tags":["attendance"],"summary":"Check out","description":"`multipart/form-data`. Closes the open shift with its own coordinates, note and photo. The assigned shift is recorded once, at check-in, and is not resent here. Returns 409 if not checked in.","operationId":"check_out_api_v1_users__user_id__check_out_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_check_out_api_v1_users__user_id__check_out_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttendanceRecordRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/attendance/current":{"get":{"tags":["attendance"],"summary":"The user's open shift","description":"404 when the user is not currently checked in.","operationId":"current_record_api_v1_users__user_id__attendance_current_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttendanceRecordRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/attendance":{"get":{"tags":["attendance"],"summary":"A user's attendance history","operationId":"user_attendance_api_v1_users__user_id__attendance_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"},{"name":"is_open","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Only open / only closed","title":"Is Open"},"description":"Only open / only closed"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_AttendanceRecordRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/attendance":{"get":{"tags":["attendance"],"summary":"The company's check-in / check-out table","description":"Every shift recorded for this company, newest first. Filter by user, by open/closed, and by check-in date range. Set `include_sub_companies=true` on a main company to roll its branches into one table. Each row embeds the user's name and cell number, and a freshly-signed link to each photo.\n\n`needs_review=true` is the one a dashboard wants: check-ins outside the site's radius, or sent as a typed address rather than a shared position. Each row carries `check_in_location_status`, `check_in_distance_m` and the site it was measured against.","operationId":"company_attendance_api_v1_companies__company_id__attendance_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Filter to one user","title":"User Id"},"description":"Filter to one user"},{"name":"site_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Filter to one site","title":"Site Id"},"description":"Filter to one site"},{"name":"is_open","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"true = currently on site, false = closed shifts","title":"Is Open"},"description":"true = currently on site, false = closed shifts"},{"name":"location_status","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/LocationStatus"},{"type":"null"}],"description":"Filter to one geofence verdict, e.g. `outside_radius`.","title":"Location Status"},"description":"Filter to one geofence verdict, e.g. `outside_radius`."},{"name":"needs_review","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"true = check-ins a human should look at: outside the site's radius, or a location that was typed rather than shared. Rows with no verdict predate the geofence and are on neither side of this.","title":"Needs Review"},"description":"true = check-ins a human should look at: outside the site's radius, or a location that was typed rather than shared. Rows with no verdict predate the geofence and are on neither side of this."},{"name":"checked_in_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601, inclusive lower bound","title":"Checked In From"},"description":"ISO 8601, inclusive lower bound"},{"name":"checked_in_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601, inclusive upper bound","title":"Checked In To"},"description":"ISO 8601, inclusive upper bound"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Roll up the branches too, for a whole-group view","default":false,"title":"Include Sub Companies"},"description":"Roll up the branches too, for a whole-group view"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_AttendanceRecordRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/storage":{"get":{"tags":["attendance"],"summary":"Where this company's photos are stored","description":"The bucket new objects for this company go to, and whether it has been created yet. What the name is derived from is set by `MINIO_BUCKET_NAMING`: `slug`, as every existing object was named, or `id`, which no rename can move. Objects already stored stay reachable wherever they were written - every row records its own bucket.","operationId":"company_storage_api_v1_companies__company_id__storage_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","title":"Response Company Storage Api V1 Companies  Company Id  Storage Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/attendance/{record_id}":{"get":{"tags":["attendance"],"summary":"One attendance record","operationId":"get_record_api_v1_attendance__record_id__get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"record_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Attendance record UUID","title":"Record Id"},"description":"Attendance record UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttendanceRecordRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/attendance/location-statuses":{"get":{"tags":["attendance"],"summary":"The geofence verdicts","description":"What `check_in_location_status` can say, and what each one means. Kept beside the enum so a new verdict cannot be added without describing it.","operationId":"list_location_statuses_api_v1_attendance_location_statuses_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"type":"object"},"type":"array","title":"Response List Location Statuses Api V1 Attendance Location Statuses Get"}}}}}}},"/api/v1/attendance/location-sources":{"get":{"tags":["attendance"],"summary":"The location sources","description":"What to send as `location_source` on a check-in or check-out.","operationId":"list_location_sources_api_v1_attendance_location_sources_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"type":"object"},"type":"array","title":"Response List Location Sources Api V1 Attendance Location Sources Get"}}}}}}},"/api/v1/sites/{site_id}/handover":{"get":{"tags":["attendance","attendance"],"summary":"The last handover note left at a site","description":"What the guard going off duty wrote down for whoever comes on next - the occurrence book, which until now lived on paper. 404 when nobody has left one at this site yet.","operationId":"site_handover_api_v1_sites__site_id__handover_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Site UUID","title":"Site Id"},"description":"Site UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HandoverRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/{user_id}/incidents":{"post":{"tags":["incidents"],"summary":"Report an incident","description":"`multipart/form-data`. `message` is required; everything else is optional, so a client that sends only a message files exactly the report it always did. The photo goes to the reporting user's company bucket (`<MINIO_BUCKET_PREFIX>-<company slug>`), created on first use, under an `incident/<date>/` key. Reporting does not depend on being checked in.\n\nNew fields: `type`, `severity`, coordinates with a `location_source`, `location_description`, and `police_involved` with a `saps_case_number`. Send more than one photograph by repeating the `photos` part - the first stays on `photo_url`, where it has always been.\n\nEvery report now gets a short `reference` - `INC-0001`, unique within the company - which is what people quote instead of the UUID.","operationId":"report_incident_api_v1_users__user_id__incidents_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_report_incident_api_v1_users__user_id__incidents_post"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["incidents"],"summary":"A user's reported incidents","description":"Everything this user has reported, newest first.","operationId":"user_incidents_api_v1_users__user_id__incidents_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"User UUID","title":"User Id"},"description":"User UUID"},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/IncidentStatus"},{"type":"null"}],"description":"Only open / only closed","title":"Status"},"description":"Only open / only closed"},{"name":"has_photo","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Only with / only without","title":"Has Photo"},"description":"Only with / only without"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_IncidentRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/incidents":{"get":{"tags":["incidents"],"summary":"The company's incident log","description":"Every incident reported in this company, newest first. Filter by user, site, `status` (`open` / `closed`), `type`, `severity`, who it is assigned to, whether a photo came with it, by date range, and by text - `search` matches the message **and the reference**, so 'INC-0007' finds it. Set `include_sub_companies=true` on a main company to roll its branches into one log. Each row embeds the reporter's name and cell number, and a freshly-signed link to every photo.\n\n`needs_escalation=true` is the control room's query: open, `high` or `critical`, and nobody has pushed it up yet.","operationId":"company_incidents_api_v1_companies__company_id__incidents_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Filter to one reporter","title":"User Id"},"description":"Filter to one reporter"},{"name":"site_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Filter to one site","title":"Site Id"},"description":"Filter to one site"},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/IncidentStatus"},{"type":"null"}],"description":"Only open / only closed","title":"Status"},"description":"Only open / only closed"},{"name":"type","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/IncidentType"},{"type":"null"}],"description":"Filter to one type","title":"Type"},"description":"Filter to one type"},{"name":"severity","in":"query","required":false,"schema":{"anyOf":[{"$ref":"#/components/schemas/IncidentSeverity"},{"type":"null"}],"description":"Filter to one severity","title":"Severity"},"description":"Filter to one severity"},{"name":"needs_escalation","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"true = open, `high` or `critical`, and nobody has pushed it up yet. The query a control room sits on.","title":"Needs Escalation"},"description":"true = open, `high` or `critical`, and nobody has pushed it up yet. The query a control room sits on."},{"name":"assigned_to_user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Filter to whoever is carrying it","title":"Assigned To User Id"},"description":"Filter to whoever is carrying it"},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match text in the message, or the reference","title":"Search"},"description":"Match text in the message, or the reference"},{"name":"has_photo","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Only with / only without","title":"Has Photo"},"description":"Only with / only without"},{"name":"reported_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601, inclusive lower bound","title":"Reported From"},"description":"ISO 8601, inclusive lower bound"},{"name":"reported_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601, inclusive upper bound","title":"Reported To"},"description":"ISO 8601, inclusive upper bound"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Roll up the branches too, for a whole-group view","default":false,"title":"Include Sub Companies"},"description":"Roll up the branches too, for a whole-group view"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_IncidentRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/incidents/statuses":{"get":{"tags":["incidents"],"summary":"Statuses an incident can be in","description":"Every accepted value for `status`, with the one a new report starts in. Values are lowercase and matched exactly.","operationId":"list_statuses_api_v1_incidents_statuses_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/IncidentStatusRead"},"type":"array","title":"Response List Statuses Api V1 Incidents Statuses Get"}}}}}}},"/api/v1/incidents/types":{"get":{"tags":["incidents"],"summary":"Types an incident can be","description":"Every accepted value for `type`. Kept beside the enum so a new type cannot be added without describing it.","operationId":"list_types_api_v1_incidents_types_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/IncidentTypeRead"},"type":"array","title":"Response List Types Api V1 Incidents Types Get"}}}}}}},"/api/v1/incidents/severities":{"get":{"tags":["incidents"],"summary":"Severities an incident can be","description":"Every accepted value for `severity`, and which ones are meant to reach a supervisor rather than a list.","operationId":"list_severities_api_v1_incidents_severities_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/IncidentSeverityRead"},"type":"array","title":"Response List Severities Api V1 Incidents Severities Get"}}}}}}},"/api/v1/incidents/outcomes":{"get":{"tags":["incidents"],"summary":"Outcomes a closed incident can have","description":"Every accepted value for `outcome`, which is only set when a report is closed.","operationId":"list_outcomes_api_v1_incidents_outcomes_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/IncidentOutcomeRead"},"type":"array","title":"Response List Outcomes Api V1 Incidents Outcomes Get"}}}}}}},"/api/v1/companies/{company_id}/incidents/by-reference":{"get":{"tags":["incidents"],"summary":"Look up an incident by its reference","description":"Resolves the short reference people actually quote - `INC-0001` - within this company. Case is ignored. Set `include_sub_companies=true` to search the branches too; where the same reference exists in more than one of them, this company's own report is returned first.","operationId":"incident_by_reference_api_v1_companies__company_id__incidents_by_reference_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"reference","in":"query","required":true,"schema":{"type":"string","description":"e.g. INC-0001","examples":["INC-0001"],"title":"Reference"},"description":"e.g. INC-0001"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Also search this company's sub-companies","default":false,"title":"Include Sub Companies"},"description":"Also search this company's sub-companies"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/incidents/{incident_id}/photos":{"post":{"tags":["incidents"],"summary":"Add a photograph to a report already filed","description":"`multipart/form-data`. Goes to the same company bucket as the first. A report with no photograph at all takes this one on `photo_url`, so a client reading only that field still sees something.","operationId":"add_incident_photo_api_v1_incidents__incident_id__photos_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"incident_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Incident UUID","title":"Incident Id"},"description":"Incident UUID"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_add_incident_photo_api_v1_incidents__incident_id__photos_post"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/incidents/{incident_id}":{"get":{"tags":["incidents"],"summary":"One incident report","operationId":"get_incident_api_v1_incidents__incident_id__get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"incident_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Incident UUID","title":"Incident Id"},"description":"Incident UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["incidents"],"summary":"Update or close an incident","description":"A partial JSON update: send only what changes. `status=closed` closes the report and stamps `closed_at`; `resolution` records what was done and `outcome` how it ended. `status=open` reopens a closed report, clearing `closed_at`, `resolution`, `outcome` and the closer. The original message, photos and reporter are never lost - closing is not deleting. Requires logging in as the reporter's company or its main company.\n\n**Closing records who did it.** Log in with `/auth/user/login` and `closed_by_name` is that person's name and `closed_by_user_id` their id; log in as the company and it is the company's name, as it has always been.\n\nTriage is applied the same way and needs no closing: `type`, `severity`, `assigned_to_user_id` to hand it to somebody, and `escalate=true` to stamp `escalated_at` once.","operationId":"update_incident_api_v1_incidents__incident_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"incident_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Incident UUID","title":"Incident Id"},"description":"Incident UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/site-records":{"get":{"tags":["sites"],"summary":"The company's sites","description":"Every site this company runs, with its pin, its radius and its posts. Unlike `/companies/{id}/sites`, this is not limited to companies one level down: a site is its own record, so a client can hold as many as it likes.\n\n`has_pin=false` is the list worth looking at first - those are the sites where no check-in can be verified, because there is nothing to measure against.","operationId":"list_company_sites_api_v1_companies__company_id__site_records_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"client_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"}},{"name":"region_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Region Id"}},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match the name or address","title":"Search"},"description":"Match the name or address"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},{"name":"has_pin","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"false lists the sites that cannot verify a check-in yet","title":"Has Pin"},"description":"false lists the sites that cannot verify a check-in yet"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Roll up the branches' sites too","default":false,"title":"Include Sub Companies"},"description":"Roll up the branches' sites too"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_SiteRecord_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["sites"],"summary":"Create a site","description":"A site is a place, not an account: it needs no slug and no password. Give it a pin and a radius and every check-in there is measured against them; leave the pin out and check-ins are recorded `no_site_pin` until one is set. The radius defaults to 150 m.\n\nRequires logging in as this company or its main company.","operationId":"create_site_api_v1_companies__company_id__site_records_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteRecord"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/sites/{site_id}":{"get":{"tags":["sites"],"summary":"One site","operationId":"get_site_api_v1_sites__site_id__get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Site UUID","title":"Site Id"},"description":"Site UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteRecord"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["sites"],"summary":"Update a site","description":"Partial: send only what changes. Dropping a pin here is what turns on geofencing for this site - from the next check-in, not retroactively: records already written keep the verdict they were given.","operationId":"update_site_api_v1_sites__site_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Site UUID","title":"Site Id"},"description":"Site UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteRecord"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["sites"],"summary":"Delete a site","description":"Refused while the site stands in for a company - delete the company instead, and the site goes with it. Attendance and incidents recorded here are kept; their `site_id` becomes null rather than the rows disappearing.","operationId":"delete_site_api_v1_sites__site_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Site UUID","title":"Site Id"},"description":"Site UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/sites/{site_id}/posts":{"get":{"tags":["sites"],"summary":"The posts at a site","description":"Main gate, receiving bay - the positions a shift fills.","operationId":"list_posts_api_v1_sites__site_id__posts_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Site UUID","title":"Site Id"},"description":"Site UUID"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PostRead"},"title":"Response List Posts Api V1 Sites  Site Id  Posts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["sites"],"summary":"Create a post","operationId":"create_post_api_v1_sites__site_id__posts_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Site UUID","title":"Site Id"},"description":"Site UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/posts/{post_id}":{"patch":{"tags":["sites"],"summary":"Update a post","operationId":"update_post_api_v1_posts__post_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"post_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Post UUID","title":"Post Id"},"description":"Post UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["sites"],"summary":"Delete a post","operationId":"delete_post_api_v1_posts__post_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"post_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Post UUID","title":"Post Id"},"description":"Post UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/clients":{"get":{"tags":["sites","clients"],"summary":"The company's clients","description":"Who the guarding is done for. One client holds many sites - which is the level the old company tree had no room for.","operationId":"list_clients_api_v1_companies__company_id__clients_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Match the name","title":"Search"},"description":"Match the name"},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_ClientRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["sites","clients"],"summary":"Create a client","operationId":"create_client_api_v1_companies__company_id__clients_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/clients/{client_id}":{"patch":{"tags":["sites","clients"],"summary":"Update a client","operationId":"update_client_api_v1_clients__client_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Client UUID","title":"Client Id"},"description":"Client UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["sites","clients"],"summary":"Delete a client","description":"The client's sites are kept; their `client_id` becomes null, so no attendance or incident history is lost with it.","operationId":"delete_client_api_v1_clients__client_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Client UUID","title":"Client Id"},"description":"Client UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/regions":{"get":{"tags":["sites","clients"],"summary":"The company's regions","description":"An optional level between a client and its sites, so an area supervisor can be given Gauteng South rather than the country.","operationId":"list_regions_api_v1_companies__company_id__regions_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"client_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"}},{"name":"is_active","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RegionRead"},"title":"Response List Regions Api V1 Companies  Company Id  Regions Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["sites","clients"],"summary":"Create a region","operationId":"create_region_api_v1_companies__company_id__regions_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegionCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegionRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/regions/{region_id}":{"patch":{"tags":["sites","clients"],"summary":"Update a region","operationId":"update_region_api_v1_regions__region_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"region_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Region UUID","title":"Region Id"},"description":"Region UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegionUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegionRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["sites","clients"],"summary":"Delete a region","operationId":"delete_region_api_v1_regions__region_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"region_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Region UUID","title":"Region Id"},"description":"Region UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/shifts":{"get":{"tags":["shifts"],"summary":"The company's roster","description":"Rostered shifts, newest first. Filter by site, post, guard and date range. `unfilled=true` lists the shifts with nobody assigned - the holes in the roster.\n\nEach row carries a derived `status`: `scheduled`, `late`, `missed`, `in_progress`, `completed` or `cancelled`. It is worked out from the clock and from whether a check-in landed, so it can never disagree with the attendance table. Only `cancelled` is set by hand.","operationId":"list_shifts_api_v1_companies__company_id__shifts_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"site_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"}},{"name":"post_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"}},{"name":"user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Filter to one guard","title":"User Id"},"description":"Filter to one guard"},{"name":"starts_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601, inclusive lower bound","title":"Starts From"},"description":"ISO 8601, inclusive lower bound"},{"name":"starts_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601, inclusive upper bound","title":"Starts To"},"description":"ISO 8601, inclusive upper bound"},{"name":"unfilled","in":"query","required":false,"schema":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"true = nobody assigned yet","title":"Unfilled"},"description":"true = nobody assigned yet"},{"name":"include_cancelled","in":"query","required":false,"schema":{"type":"boolean","default":true,"title":"Include Cancelled"}},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Roll up the branches' rosters too","default":false,"title":"Include Sub Companies"},"description":"Roll up the branches' rosters too"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_ShiftRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["shifts"],"summary":"Roster a shift","description":"Writes a shift in advance. `user_id` may be omitted for an open shift - one on the roster with nobody assigned yet.\n\nA post marked `requires_armed` is refused for a guard who is not armed, or whose firearm competency expires before the shift starts.","operationId":"create_shift_api_v1_companies__company_id__shifts_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShiftCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShiftRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/shifts/attention":{"get":{"tags":["shifts"],"summary":"Shifts nobody has turned up for","description":"Shifts whose start time has passed with no check-in: `late` while the grace period runs (15 minutes by default, `SHIFT_NO_SHOW_GRACE_MINUTES`), `missed` after it. Limited to the last 24 hours - anything older is history, not something to act on now.\n\nThis is the query behind 'alert supervisors when a post has no check-in 15 minutes after shift start'. There is no background job: poll it, or have a scheduler poll it and send the message.","operationId":"shifts_needing_attention_api_v1_companies__company_id__shifts_attention_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Sub Companies"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"description":"Max rows to return","default":50,"title":"Limit"},"description":"Max rows to return"},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"description":"Rows to skip","default":0,"title":"Offset"},"description":"Rows to skip"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Page_ShiftRead_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/attendance-summary":{"get":{"tags":["shifts"],"summary":"Attendance and on-time figures","description":"The dashboard's headline numbers, computed from the roster rather than invented: how many rostered shifts have begun, how many had somebody check in, how many of those were on time, and the average lateness of the rest.\n\nEvery rate is **null** rather than zero when there is nothing to measure. 'No shifts rostered' and 'nobody was on time' are different answers, and 0% reads as the second - which is what the dashboard was doing with On-Time Rate.","operationId":"attendance_summary_api_v1_companies__company_id__attendance_summary_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"starts_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601. Defaults to 30 days ago.","title":"Starts From"},"description":"ISO 8601. Defaults to 30 days ago."},{"name":"starts_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"ISO 8601","title":"Starts To"},"description":"ISO 8601"},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Sub Companies"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttendanceSummary"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/shifts/bulk":{"post":{"tags":["shifts"],"summary":"Roster many shifts at once","description":"A week of shifts in one transaction: either all of them land or none do, so a half-written roster never has to be unpicked by hand. Every shift is validated before any is written.","operationId":"create_shifts_api_v1_companies__company_id__shifts_bulk_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShiftBulkCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ShiftRead"},"title":"Response Create Shifts Api V1 Companies  Company Id  Shifts Bulk Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/shifts/statuses":{"get":{"tags":["shifts"],"summary":"Statuses a shift can be in","description":"Every value `status` can take, and what each one means. Kept beside the enum so a new one cannot be added without describing it.","operationId":"list_statuses_api_v1_shifts_statuses_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/ShiftStatusRead"},"type":"array","title":"Response List Statuses Api V1 Shifts Statuses Get"}}}}}}},"/api/v1/shifts/{shift_id}":{"get":{"tags":["shifts"],"summary":"One shift","operationId":"get_shift_api_v1_shifts__shift_id__get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"shift_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Shift UUID","title":"Shift Id"},"description":"Shift UUID"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShiftRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["shifts"],"summary":"Update, reassign or cancel a shift","description":"Partial: send only what changes. `cancelled=true` calls it off - the only status anybody sets by hand - and `cancelled=false` reinstates it.","operationId":"update_shift_api_v1_shifts__shift_id__patch","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"shift_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Shift UUID","title":"Shift Id"},"description":"Shift UUID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShiftUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShiftRead"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["shifts"],"summary":"Delete a shift","description":"Removes the roster entry outright. Cancelling it instead - `PATCH {\"cancelled\": true}` - keeps it visible, which is usually what a roster wants.","operationId":"delete_shift_api_v1_shifts__shift_id__delete","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"shift_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Shift UUID","title":"Shift Id"},"description":"Shift UUID"}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/compliance-alerts":{"get":{"tags":["compliance"],"summary":"Guards whose papers have lapsed or are about to","description":"Active guards whose PSiRA registration or firearm competency has expired, or will within `within_days`. The default is the widest warning window configured, 60 days - `COMPLIANCE_WARNING_DAYS` is [60, 30], read as 'warn at 60 and at 30 days'.\n\nEach guard carries a `compliance` block saying exactly what is wrong: how many days are left, whether the registration has already lapsed, and whether an armed guard is standing posts on a competency that has run out. Soonest first.\n\nAn armed guard's firearm competency counts whatever the date on it; an unarmed guard's does not, because nothing is being carried on it.","operationId":"compliance_alerts_api_v1_companies__company_id__compliance_alerts_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"within_days","in":"query","required":false,"schema":{"anyOf":[{"type":"integer","maximum":3650,"minimum":0},{"type":"null"}],"description":"Days ahead to look. 0 lists only what has already lapsed.","title":"Within Days"},"description":"Days ahead to look. 0 lists only what has already lapsed."},{"name":"include_sub_companies","in":"query","required":false,"schema":{"type":"boolean","description":"Roll up the branches too","default":false,"title":"Include Sub Companies"},"description":"Roll up the branches too"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserRead"},"title":"Response Compliance Alerts Api V1 Companies  Company Id  Compliance Alerts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/users/import/preview":{"post":{"tags":["imports"],"summary":"Read a staff list without importing it","description":"Reads a `.xlsx` or `.csv` staff list and registers each row as a guard.\n\n**The file does not have to be tidy.** The header row is found wherever it sits, so\na banner above it is fine; blank rows between sections are skipped; a row holding\none lone word is read as a **site heading** that applies to the rows beneath it;\nand column names are matched loosely, so `SURNAME & NAME`, `CONTACTS` and `ROLES`\nare understood without renaming anything.\n\n**A cell number is how a guard is identified**, so a row without one cannot be\nimported. Numbers written the way people write them - `062 894 0549` - are read\nagainst `IMPORT_DIALLING_CODE` (`+27`), and **every such substitution is\nreported on its row**. Elsewhere in this API a national number is refused, because\nin a single request it is genuinely ambiguous; a spreadsheet is not.\n\n**`job_title` never grants anything.** A staff list saying \"Supervisor\" records a\njob title and nothing else - `role`, which decides what somebody may do here, is\nonly ever set deliberately through `/users`.\n\nA 13-digit ID number that fails its check digit is imported **with a warning**,\nnot refused: it usually means a typed digit, and the person still works there.\n\n**This endpoint writes nothing.** It runs the whole import - every validation, every duplicate check, every site lookup - and then throws the writes away, so the report is what a real import would do. A preview is a separate endpoint rather than a flag, so it cannot become a commit by a typo.\n\nStart here, read the `rows` and the `notes`, then post the same file and the same options to `../import`.","operationId":"preview_import_api_v1_companies__company_id__users_import_preview_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_preview_import_api_v1_companies__company_id__users_import_preview_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportReport"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/users/import":{"post":{"tags":["imports"],"summary":"Import guards from a staff list","description":"Reads a `.xlsx` or `.csv` staff list and registers each row as a guard.\n\n**The file does not have to be tidy.** The header row is found wherever it sits, so\na banner above it is fine; blank rows between sections are skipped; a row holding\none lone word is read as a **site heading** that applies to the rows beneath it;\nand column names are matched loosely, so `SURNAME & NAME`, `CONTACTS` and `ROLES`\nare understood without renaming anything.\n\n**A cell number is how a guard is identified**, so a row without one cannot be\nimported. Numbers written the way people write them - `062 894 0549` - are read\nagainst `IMPORT_DIALLING_CODE` (`+27`), and **every such substitution is\nreported on its row**. Elsewhere in this API a national number is refused, because\nin a single request it is genuinely ambiguous; a spreadsheet is not.\n\n**`job_title` never grants anything.** A staff list saying \"Supervisor\" records a\njob title and nothing else - `role`, which decides what somebody may do here, is\nonly ever set deliberately through `/users`.\n\nA 13-digit ID number that fails its check digit is imported **with a warning**,\nnot refused: it usually means a typed digit, and the person still works there.\n\n**All or nothing.** If any row fails, the whole import is rolled back and `committed` comes back `false` - a staff list half in the system is worse than one not in it, because nobody can tell which half without reading both. Fix the rows the report names and send the file again.\n\nRe-importing is safe: a cell number already registered is **skipped** by default, so a corrected spreadsheet does not overwrite work done in the app since. Send `on_duplicate=update` to fill in what the file carries.","operationId":"import_users_api_v1_companies__company_id__users_import_post","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_import_users_api_v1_companies__company_id__users_import_post"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportReport"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/companies/{company_id}/users/import/template":{"get":{"tags":["imports"],"summary":"A blank staff list with the right headings","description":"`format=csv` (the default) or `format=xlsx` downloads a file with one example row to delete. `format=json` describes the columns instead, which is usually the more useful question: whether your existing file will be read, not what a new one should look like.\n\nOnly `full_name` and `phone` are required, and the headings are matched loosely - an existing staff list very often needs no editing at all.","operationId":"import_template_api_v1_companies__company_id__users_import_template_get","security":[{"OAuth2PasswordBearer":[]}],"parameters":[{"name":"company_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","description":"Company UUID","title":"Company Id"},"description":"Company UUID"},{"name":"format","in":"query","required":false,"schema":{"type":"string","pattern":"^(csv|xlsx|json)$","description":"csv, xlsx or json","default":"csv","title":"Format"},"description":"csv, xlsx or json"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/import/duplicate-policies":{"get":{"tags":["imports"],"summary":"What to do about a number already registered","description":"Every accepted value for `on_duplicate`, and what each one does.","operationId":"list_duplicate_policies_api_v1_users_import_duplicate_policies_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"type":"object"},"type":"array","title":"Response List Duplicate Policies Api V1 Users Import Duplicate Policies Get"}}}}}}}},"components":{"schemas":{"AssignmentRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"user_id":{"type":"string","format":"uuid","title":"User Id"},"change":{"type":"string","title":"Change","examples":["site"]},"from_value":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"From Value","description":"What it was, as it read at the time. Kept as text so the entry survives the site or company being renamed or deleted."},"to_value":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"To Value"},"from_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"From Id"},"to_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"To Id"},"changed_by_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Changed By Name","description":"Who made the change - a person where the login was a person's, the company where it was a company's."},"changed_by_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Changed By User Id"},"changed_by_company_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Changed By Company Id"},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","user_id","change","created_at"],"title":"AssignmentRead","description":"One entry from a guard's posting history."},"AttendanceRecordRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"user_id":{"type":"string","format":"uuid","title":"User Id"},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site this shift was worked at, resolved at check-in. Null on rows written before sites existed."},"site":{"anyOf":[{"$ref":"#/components/schemas/SiteSummary"},{"type":"null"}]},"shift_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Shift Id","description":"The rostered shift this check-in answered, when one matched. Null means the guard checked in without a shift on the roster."},"assigned_check_in_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Assigned Check In At"},"assigned_check_out_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Assigned Check Out At"},"checked_in_at":{"type":"string","format":"date-time","title":"Checked In At"},"check_in_latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Check In Latitude"},"check_in_longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Check In Longitude"},"check_in_note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check In Note"},"check_in_location_source":{"$ref":"#/components/schemas/LocationSource","default":"unknown"},"check_in_location_status":{"anyOf":[{"$ref":"#/components/schemas/LocationStatus"},{"type":"null"}],"description":"The geofence verdict, decided when the row was written and never recomputed - a site's pin can be corrected later, and this record has to go on saying what was true at the time. Null on rows written before the geofence existed."},"check_in_distance_m":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Check In Distance M","description":"Metres from the site's pin.","examples":[48.7]},"post_orders_acknowledged_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Post Orders Acknowledged At"},"check_in_photo_bucket":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check In Photo Bucket"},"check_in_photo_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check In Photo Key"},"check_in_photo_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check In Photo Url","description":"Presigned download link, valid for MINIO_URL_EXPIRY_SECONDS. Regenerated on every read - do not store it."},"checked_out_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Checked Out At"},"check_out_latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Check Out Latitude"},"check_out_longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Check Out Longitude"},"check_out_note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check Out Note"},"check_out_location_source":{"$ref":"#/components/schemas/LocationSource","default":"unknown"},"check_out_location_status":{"anyOf":[{"$ref":"#/components/schemas/LocationStatus"},{"type":"null"}]},"check_out_distance_m":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Check Out Distance M"},"check_out_photo_bucket":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check Out Photo Bucket"},"check_out_photo_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check Out Photo Key"},"check_out_photo_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Check Out Photo Url"},"handover_note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Handover Note","description":"What the guard going off duty left for whoever comes on next - the occurrence book, written at check-out."},"user":{"anyOf":[{"$ref":"#/components/schemas/AttendanceUser"},{"type":"null"}]},"is_open":{"type":"boolean","title":"Is Open","readOnly":true},"duration_seconds":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Duration Seconds","readOnly":true},"check_in_punctuality":{"anyOf":[{"$ref":"#/components/schemas/Punctuality"},{"type":"null"}],"description":"How the check-in compared with the rostered start (`assigned_check_in_at`). Null when no shift start was recorded, so there was nothing to be early or late against.","readOnly":true},"check_out_punctuality":{"anyOf":[{"$ref":"#/components/schemas/Punctuality"},{"type":"null"}],"description":"How the check-out compared with the rostered end (`assigned_check_out_at`). `late` is a guard who stayed on past the end, `early` one who left before it. Null while the shift is still open, or when no shift end was recorded.","readOnly":true},"check_in_verified":{"type":"boolean","title":"Check In Verified","description":"Whether this arrival was actually proved. False for everything that is\nnot a device reading inside the radius, including a row with no verdict.","readOnly":true},"needs_review":{"type":"boolean","title":"Needs Review","description":"Outside the radius, or a location that was typed rather than shared.\nA row with no verdict predates the geofence and is not evidence either way,\nso it is not flagged.","readOnly":true}},"type":"object","required":["id","company_id","user_id","checked_in_at","is_open","duration_seconds","check_in_punctuality","check_out_punctuality","check_in_verified","needs_review"],"title":"AttendanceRecordRead"},"AttendanceSummary":{"properties":{"shifts":{"type":"integer","title":"Shifts","description":"Rostered shifts whose start has passed"},"attended":{"type":"integer","title":"Attended","description":"Of those, how many had a check-in"},"on_time":{"type":"integer","title":"On Time"},"status_counts":{"additionalProperties":{"type":"integer"},"type":"object","title":"Status Counts"},"on_time_rate":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"On Time Rate","description":"on_time / attended, 0-1. Null when none attended."},"attendance_rate":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Attendance Rate","description":"attended / shifts, 0-1. Null when none started."},"average_minutes_late":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Average Minutes Late","description":"Averaged over late arrivals only."}},"type":"object","required":["shifts","attended","on_time","status_counts"],"title":"AttendanceSummary","description":"The dashboard's figures, computed from the roster rather than invented.\n\nEvery rate is null rather than zero when there is nothing to measure: \"no\nshifts rostered\" and \"nobody was on time\" are different answers, and 0% reads\nas the second."},"AttendanceUser":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"phone":{"type":"string","title":"Phone"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"}},"type":"object","required":["id","phone"],"title":"AttendanceUser","description":"Enough of the user to read the company's table without a second request."},"AuthPosture":{"properties":{"require_auth_for_reads":{"type":"boolean","title":"Require Auth For Reads"},"require_auth_for_guard_actions":{"type":"boolean","title":"Require Auth For Guard Actions"},"notes":{"items":{"type":"string"},"type":"array","title":"Notes"}},"type":"object","required":["require_auth_for_reads","require_auth_for_guard_actions","notes"],"title":"AuthPosture","description":"What this deployment currently requires, so a client can tell without\nguessing - and so the open endpoints are visible rather than discovered."},"Body_add_incident_photo_api_v1_incidents__incident_id__photos_post":{"properties":{"photo":{"anyOf":[{"type":"string","format":"binary"},{"type":"null"}],"title":"Photo","description":"Optional photo. JPEG, PNG, GIF, WebP or HEIC."}},"type":"object","title":"Body_add_incident_photo_api_v1_incidents__incident_id__photos_post"},"Body_check_in_api_v1_users__user_id__check_in_post":{"properties":{"latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Latitude","description":"Decimal degrees, -90 to 90"},"longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Longitude","description":"Decimal degrees, -180 to 180"},"note":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Note"},"location_source":{"anyOf":[{"$ref":"#/components/schemas/LocationSource"},{"type":"null"}],"description":"Where the coordinates came from: `device` for a position the phone shared, `manual` for an address somebody typed. Only `device` can be verified - WhatsApp's location request lets the sender type an address instead, and the message looks identical either way. Omitting this gives `unknown`, which is never verified."},"acknowledge_post_orders":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Acknowledge Post Orders","description":"true records that the guard confirmed the post orders."},"assigned_check_in_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Assigned Check In At","description":"Optional. When the guard was rostered to arrive (ISO 8601); naive values are read as UTC."},"assigned_check_out_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Assigned Check Out At","description":"Optional. When the guard was rostered to leave (ISO 8601); use the next day's date for a night shift."},"photo":{"anyOf":[{"type":"string","format":"binary"},{"type":"null"}],"title":"Photo","description":"Optional photo. JPEG, PNG, GIF, WebP or HEIC."}},"type":"object","title":"Body_check_in_api_v1_users__user_id__check_in_post"},"Body_check_out_api_v1_users__user_id__check_out_post":{"properties":{"latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Latitude","description":"Decimal degrees, -90 to 90"},"longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Longitude","description":"Decimal degrees, -180 to 180"},"note":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Note"},"location_source":{"anyOf":[{"$ref":"#/components/schemas/LocationSource"},{"type":"null"}],"description":"Where the coordinates came from: `device` for a position the phone shared, `manual` for an address somebody typed. Only `device` can be verified - WhatsApp's location request lets the sender type an address instead, and the message looks identical either way. Omitting this gives `unknown`, which is never verified."},"handover_note":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Handover Note","description":"What the next guard needs to know - the occurrence book. Shown to whoever checks in at this site next."},"photo":{"anyOf":[{"type":"string","format":"binary"},{"type":"null"}],"title":"Photo","description":"Optional photo. JPEG, PNG, GIF, WebP or HEIC."}},"type":"object","title":"Body_check_out_api_v1_users__user_id__check_out_post"},"Body_import_users_api_v1_companies__company_id__users_import_post":{"properties":{"file":{"type":"string","format":"binary","title":"File","description":"A .xlsx or .csv staff list. The header row does not have to be the first row - a banner above it is fine, and blank rows between sections are skipped."},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site to post everybody to, for rows that do not name one themselves. A row's own `site` column, or a section heading above it, wins over this."},"on_duplicate":{"anyOf":[{"$ref":"#/components/schemas/DuplicatePolicy"},{"type":"null"}],"description":"What to do about a cell number already registered in this company. Defaults to `skip`."},"default_category":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Category","description":"`unarmed`, `armed` or `reaction`, applied to rows with no category of their own. Most staff lists have no such column."},"default_job_title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Job Title","description":"A job title for rows with none, e.g. 'Security Officer'."},"require_site":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Require Site","description":"true refuses any row whose site cannot be resolved, rather than falling back to the default. Worth sending for a file covering several sites, where guessing puts people at the wrong gate."}},"type":"object","required":["file"],"title":"Body_import_users_api_v1_companies__company_id__users_import_post"},"Body_preview_import_api_v1_companies__company_id__users_import_preview_post":{"properties":{"file":{"type":"string","format":"binary","title":"File","description":"A .xlsx or .csv staff list. The header row does not have to be the first row - a banner above it is fine, and blank rows between sections are skipped."},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site to post everybody to, for rows that do not name one themselves. A row's own `site` column, or a section heading above it, wins over this."},"on_duplicate":{"anyOf":[{"$ref":"#/components/schemas/DuplicatePolicy"},{"type":"null"}],"description":"What to do about a cell number already registered in this company. Defaults to `skip`."},"default_category":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Category","description":"`unarmed`, `armed` or `reaction`, applied to rows with no category of their own. Most staff lists have no such column."},"default_job_title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Job Title","description":"A job title for rows with none, e.g. 'Security Officer'."},"require_site":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Require Site","description":"true refuses any row whose site cannot be resolved, rather than falling back to the default. Worth sending for a file covering several sites, where guessing puts people at the wrong gate."}},"type":"object","required":["file"],"title":"Body_preview_import_api_v1_companies__company_id__users_import_preview_post"},"Body_report_incident_api_v1_users__user_id__incidents_post":{"properties":{"message":{"type":"string","maxLength":2000,"minLength":1,"title":"Message","description":"What happened. Required - the photo is the optional half."},"type":{"anyOf":[{"$ref":"#/components/schemas/IncidentType"},{"type":"null"}],"description":"What happened."},"severity":{"anyOf":[{"$ref":"#/components/schemas/IncidentSeverity"},{"type":"null"}],"description":"`high` and `critical` are what a control room sees first."},"latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Latitude","description":"Decimal degrees, -90 to 90"},"longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Longitude","description":"Decimal degrees, -180 to 180"},"location_source":{"anyOf":[{"$ref":"#/components/schemas/LocationSource"},{"type":"null"}],"description":"`device` for a shared position, `manual` for a typed address."},"location_description":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Location Description","description":"The post or area, where coordinates cannot say it."},"police_involved":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Police Involved"},"saps_case_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Saps Case Number","description":"SAPS case number. Needs police_involved=true."},"photo":{"anyOf":[{"type":"string","format":"binary"},{"type":"null"}],"title":"Photo","description":"Optional photo. JPEG, PNG, GIF, WebP or HEIC."},"photos":{"anyOf":[{"items":{"type":"string","format":"binary"},"type":"array"},{"type":"null"}],"title":"Photos","description":"Further photographs, beyond the first. The first stays on `photo_url`, where it has always been."}},"type":"object","required":["message"],"title":"Body_report_incident_api_v1_users__user_id__incidents_post"},"Body_set_user_photo_api_v1_users__user_id__photo_put":{"properties":{"photo":{"anyOf":[{"type":"string","format":"binary"},{"type":"null"}],"title":"Photo","description":"Optional photo. JPEG, PNG, GIF, WebP or HEIC."}},"type":"object","title":"Body_set_user_photo_api_v1_users__user_id__photo_put"},"Body_token_api_v1_auth_token_post":{"properties":{"grant_type":{"anyOf":[{"type":"string","pattern":"password"},{"type":"null"}],"title":"Grant Type"},"username":{"type":"string","title":"Username"},"password":{"type":"string","title":"Password"},"scope":{"type":"string","title":"Scope","default":""},"client_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Id"},"client_secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Secret"}},"type":"object","required":["username","password"],"title":"Body_token_api_v1_auth_token_post"},"CategoryRead":{"properties":{"value":{"$ref":"#/components/schemas/GuardCategory","description":"What to send as `category`"},"description":{"type":"string","title":"Description"},"requires_firearm_competency":{"type":"boolean","title":"Requires Firearm Competency"}},"type":"object","required":["value","description","requires_firearm_competency"],"title":"CategoryRead"},"ClientCreate":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","examples":["Boxer Superstores"]},"contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Name"},"contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Contact Phone"},"contact_email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Contact Email"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"}},"type":"object","required":["name"],"title":"ClientCreate"},"ClientRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"name":{"type":"string","title":"Name"},"contact_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Name"},"contact_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Phone"},"contact_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Email"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"is_active":{"type":"boolean","title":"Is Active"},"site_count":{"type":"integer","title":"Site Count","description":"Sites currently under this client","default":0},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","company_id","name","is_active","created_at","updated_at"],"title":"ClientRead"},"ClientUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Name"},"contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Name"},"contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Contact Phone"},"contact_email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Contact Email"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"ClientUpdate"},"CompanyCreate":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","examples":["Acme Industries"]},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","examples":["hello@acme.example.com"]},"phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Phone","examples":["+27 11 555 0100"]},"website":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Website","examples":["https://acme.example.com"]},"location":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Location","description":"Where the company is - a branch's town or street address. Optional for every company, main or branch.","examples":["12 Main Road, Sandton, Johannesburg"]},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","examples":["Makers of everything."]},"full_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Full Name","description":"The **person** registering - not the company, which is `name`. Required when registering; not asked for when adding a branch.","examples":["Thabo Mokoena"]},"company_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Company Number","description":"The company's own registration number. Optional.","examples":["2019/123456/07"]},"business_registration_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Business Registration Number","description":"PSiRA business registration number. Optional, and worth capturing: a security company must hold one, and tenders ask for proof.","examples":["1234567"]},"terms_and_conditions":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Terms And Conditions","description":"Must be `true` to register. Recorded as the moment of acceptance (`terms_accepted_at`), because a yes with no date is not evidence of anything. Not asked for when adding a branch.","examples":[true]},"slug":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Slug","description":"URL-safe identifier. Derived from the name when omitted.","examples":["acme-industries"]},"password":{"type":"string","maxLength":128,"minLength":8,"title":"Password","description":"The company logs in with its slug and this password.","examples":["c0mpany-secret"]},"parent_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Parent Id","description":"Main company this one sits beneath. Omit for a standalone or main company - which is a registration, and asks for more. Setting it requires being logged in as that main company, and the parent must itself be a main company: the tree is only two levels deep."},"latitude":{"anyOf":[{"type":"number","maximum":90.0,"minimum":-90.0},{"type":"null"}],"title":"Latitude","description":"The site pin a check-in here is measured against. Stored on the site standing in for this company, not on the company itself - see `GET /sites`. Send with `longitude`.","examples":[-26.204103]},"longitude":{"anyOf":[{"type":"number","maximum":180.0,"minimum":-180.0},{"type":"null"}],"title":"Longitude","examples":[28.047305]},"check_in_radius_m":{"anyOf":[{"type":"integer","maximum":50000.0,"exclusiveMinimum":0.0},{"type":"null"}],"title":"Check In Radius M","description":"Metres from the pin a check-in may be and still count as on site. Defaults to DEFAULT_CHECK_IN_RADIUS_M.","examples":[150]}},"type":"object","required":["name","password"],"title":"CompanyCreate","description":"Registering a company, or adding a branch beneath one.\n\n**The two are not the same act, and they do not ask for the same things.**\n\nA *registration* - no `parent_id` - is somebody signing up. It requires the\nperson's `full_name`, the company's `name`, `email` and `phone`, a `password`,\nand `terms_and_conditions`. Those are the fields the sign-up form collects,\nand every one of them is about the account being opened.\n\nA *branch* - `parent_id` set - is a main company adding one of its own places.\nNobody is signing up and nobody is accepting terms on anyone's behalf, so the\nsign-up fields stay optional, exactly as they have always been. Requiring them\nwould mean asking an existing tenant to re-accept terms to add a site.\n\nThe optional registration numbers are the company's own: `company_number` for\nits registration (a CIPC number, in South Africa) and\n`business_registration_number` for its PSiRA business registration."},"CompanyLogin":{"properties":{"slug":{"type":"string","maxLength":255,"minLength":1,"title":"Slug","examples":["acme-industries"]},"password":{"type":"string","maxLength":128,"minLength":1,"title":"Password","examples":["c0mpany-secret"]}},"type":"object","required":["slug","password"],"title":"CompanyLogin"},"CompanyRead":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","examples":["Acme Industries"]},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","examples":["hello@acme.example.com"]},"phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Phone","examples":["+27 11 555 0100"]},"website":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Website","examples":["https://acme.example.com"]},"location":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Location","description":"Where the company is - a branch's town or street address. Optional for every company, main or branch.","examples":["12 Main Road, Sandton, Johannesburg"]},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","examples":["Makers of everything."]},"id":{"type":"string","format":"uuid","title":"Id"},"slug":{"type":"string","title":"Slug"},"is_active":{"type":"boolean","title":"Is Active"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name","description":"The person who registered the company. Null for a branch, and for a company registered before this was asked for."},"company_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Company Number"},"business_registration_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Business Registration Number"},"terms_accepted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Terms Accepted At","description":"When the terms and privacy notice were accepted. Null for a branch, and for a company registered before acceptance was recorded."},"parent_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Parent Id"},"parent":{"anyOf":[{"$ref":"#/components/schemas/CompanySummary"},{"type":"null"}]},"sub_company_count":{"type":"integer","title":"Sub Company Count","description":"Companies directly beneath this one","default":0},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"},"is_main":{"type":"boolean","title":"Is Main","description":"True for a standalone company or the head of a group.","readOnly":true}},"type":"object","required":["name","id","slug","is_active","created_at","updated_at","is_main"],"title":"CompanyRead"},"CompanySummary":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"slug":{"type":"string","title":"Slug"},"parent_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Parent Id"},"is_main":{"type":"boolean","title":"Is Main","readOnly":true}},"type":"object","required":["id","name","slug","is_main"],"title":"CompanySummary","description":"Compact company reference, embedded in other payloads."},"CompanyUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Name"},"full_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Full Name","description":"Correct the registering person's name."},"company_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Company Number"},"business_registration_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Business Registration Number"},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email"},"phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Phone"},"website":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Website"},"location":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Location","description":"Send null or an empty string to clear it."},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"},"password":{"anyOf":[{"type":"string","maxLength":128,"minLength":8},{"type":"null"}],"title":"Password"},"parent_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Parent Id","description":"Send null to detach a branch and make it standalone. Only its main company may do that."},"latitude":{"anyOf":[{"type":"number","maximum":90.0,"minimum":-90.0},{"type":"null"}],"title":"Latitude","description":"The site pin a check-in here is measured against. Stored on the site standing in for this company, not on the company itself - see `GET /sites`. Send with `longitude`.","examples":[-26.204103]},"longitude":{"anyOf":[{"type":"number","maximum":180.0,"minimum":-180.0},{"type":"null"}],"title":"Longitude","examples":[28.047305]},"check_in_radius_m":{"anyOf":[{"type":"integer","maximum":50000.0,"exclusiveMinimum":0.0},{"type":"null"}],"title":"Check In Radius M","description":"Metres from the pin a check-in may be and still count as on site. Defaults to DEFAULT_CHECK_IN_RADIUS_M.","examples":[150]}},"type":"object","title":"CompanyUpdate","description":"A partial update. `terms_and_conditions` is deliberately absent: acceptance\nis something that happened at a moment, not a setting to be toggled later."},"ComplianceRead":{"properties":{"psira_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Psira Expiry"},"psira_expired":{"type":"boolean","title":"Psira Expired","default":false},"psira_days_remaining":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Psira Days Remaining","description":"Negative once it has lapsed. Null when no date is held."},"firearm_competency_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Firearm Competency Expiry"},"firearm_competency_expired":{"type":"boolean","title":"Firearm Competency Expired","default":false},"firearm_days_remaining":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Firearm Days Remaining"},"armed_without_valid_competency":{"type":"boolean","title":"Armed Without Valid Competency","default":false},"is_compliant":{"type":"boolean","title":"Is Compliant","default":true},"warnings":{"items":{"type":"string"},"type":"array","title":"Warnings","default":[]}},"type":"object","title":"ComplianceRead","description":"Whether this guard may stand a post today, and what is about to lapse.\n\nComputed, never stored: an expiry date that was fine yesterday is not fine\ntoday, and a stored flag would still be saying yesterday's answer."},"DuplicatePolicy":{"type":"string","enum":["skip","update","fail"],"title":"DuplicatePolicy","description":"What to do about a cell number already registered in this company."},"GradeRead":{"properties":{"value":{"$ref":"#/components/schemas/PsiraGrade","description":"What to send as `psira_grade`"},"description":{"type":"string","title":"Description"}},"type":"object","required":["value","description"],"title":"GradeRead"},"GuardCategory":{"type":"string","enum":["unarmed","armed","reaction"],"title":"GuardCategory","description":"What kind of duty a guard may be posted to."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"HandoverRead":{"properties":{"site_id":{"type":"string","format":"uuid","title":"Site Id"},"handover_note":{"type":"string","title":"Handover Note"},"written_at":{"type":"string","format":"date-time","title":"Written At"},"written_by_user_id":{"type":"string","format":"uuid","title":"Written By User Id"},"written_by_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Written By Name"}},"type":"object","required":["site_id","handover_note","written_at","written_by_user_id"],"title":"HandoverRead","description":"The last note left at a site, for whoever is coming on duty."},"ImportReport":{"properties":{"committed":{"type":"boolean","title":"Committed","description":"False for a preview, and false for an import that was rolled back because a row failed."},"filename":{"type":"string","title":"Filename"},"header_row":{"type":"integer","title":"Header Row","description":"Which row the column names were found on, 1-based."},"columns":{"additionalProperties":{"type":"integer"},"type":"object","title":"Columns","description":"Field name -> the column it was read from, 0-based."},"ignored_columns":{"items":{"type":"string"},"type":"array","title":"Ignored Columns","description":"Headings in the file that mean nothing here. Listed rather than dropped silently, in case one of them was meant to be a guard's PSiRA number.","default":[]},"total_rows":{"type":"integer","title":"Total Rows"},"created":{"type":"integer","title":"Created"},"updated":{"type":"integer","title":"Updated"},"skipped":{"type":"integer","title":"Skipped"},"failed":{"type":"integer","title":"Failed"},"rows":{"items":{"$ref":"#/components/schemas/ImportedRow"},"type":"array","title":"Rows"},"notes":{"items":{"type":"string"},"type":"array","title":"Notes","description":"Anything about the file as a whole: a number appearing on two rows, a site that could not be resolved, an assumption worth checking before committing.","default":[]}},"type":"object","required":["committed","filename","header_row","columns","total_rows","created","updated","skipped","failed","rows"],"title":"ImportReport","description":"The whole import.\n\n`committed` is the field to read first. On a preview it is false and nothing\nwas written, whatever the outcomes say."},"ImportedRow":{"properties":{"row_number":{"type":"integer","title":"Row Number","description":"The row as the spreadsheet numbers it, so it can be found."},"outcome":{"$ref":"#/components/schemas/RowOutcome"},"user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"User Id","description":"Null on a failed row, and on every row of a preview."},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone","description":"As stored, in E.164 - not as the spreadsheet had it."},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"},"site_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Site Name","description":"The site this row was read as belonging to, whether from a `site` column, a section heading above it, or the default."},"errors":{"items":{"type":"string"},"type":"array","title":"Errors","description":"Why nothing was written. Empty unless `failed`.","default":[]},"warnings":{"items":{"type":"string"},"type":"array","title":"Warnings","description":"What was assumed or could not be read, on a row that was still imported. A national number read as +27 is a warning, not an error.","default":[]}},"type":"object","required":["row_number","outcome"],"title":"ImportedRow","description":"One row of the spreadsheet, and what became of it."},"IncidentOutcome":{"type":"string","enum":["resolved","false_alarm","escalated_to_client","police_case_opened"],"title":"IncidentOutcome","description":"How it ended. Recorded when the report is closed."},"IncidentOutcomeRead":{"properties":{"value":{"$ref":"#/components/schemas/IncidentOutcome"},"description":{"type":"string","title":"Description"}},"type":"object","required":["value","description"],"title":"IncidentOutcomeRead"},"IncidentPhotoRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"bucket":{"type":"string","title":"Bucket"},"key":{"type":"string","title":"Key"},"uploaded_by_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Uploaded By User Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Url","description":"Presigned download link, valid for MINIO_URL_EXPIRY_SECONDS. Regenerated on every read - do not store it."}},"type":"object","required":["id","bucket","key","created_at"],"title":"IncidentPhotoRead"},"IncidentRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"user_id":{"type":"string","format":"uuid","title":"User Id"},"reference":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reference","description":"The short reference people quote - unique within the company. Null only on reports filed before references existed.","examples":["INC-0001"]},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"},"site":{"anyOf":[{"$ref":"#/components/schemas/SiteSummary"},{"type":"null"}]},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"},"reported_at":{"type":"string","format":"date-time","title":"Reported At"},"message":{"type":"string","title":"Message"},"type":{"anyOf":[{"$ref":"#/components/schemas/IncidentType"},{"type":"null"}]},"severity":{"anyOf":[{"$ref":"#/components/schemas/IncidentSeverity"},{"type":"null"}]},"latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Latitude"},"longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Longitude"},"location_source":{"$ref":"#/components/schemas/LocationSource","default":"unknown"},"location_description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Location Description"},"police_involved":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Police Involved"},"saps_case_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Saps Case Number"},"assigned_to_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Assigned To User Id"},"assigned_to":{"anyOf":[{"$ref":"#/components/schemas/IncidentReporter"},{"type":"null"}]},"escalated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Escalated At"},"escalated_to_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Escalated To User Id"},"status":{"$ref":"#/components/schemas/IncidentStatus"},"closed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Closed At"},"resolution":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Resolution"},"outcome":{"anyOf":[{"$ref":"#/components/schemas/IncidentOutcome"},{"type":"null"}]},"closed_by_company_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Closed By Company Id","description":"The company whose login closed it. Null while open, and also null if that company has since been deleted - `closed_by_name` survives that."},"closed_by_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Closed By User Id","description":"The person who closed it, when the login was a person's rather than the company's shared one."},"closed_by_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Closed By Name","description":"The closer's name as it read at the moment of closing, copied onto the row so a later rename cannot rewrite the log. A person's name where a person closed it, the company's where a company login did.","examples":["Thabo Mokoena"]},"photo_bucket":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Photo Bucket"},"photo_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Photo Key"},"photo_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Photo Url","description":"Presigned download link, valid for MINIO_URL_EXPIRY_SECONDS. Regenerated on every read - do not store it."},"photos":{"items":{"$ref":"#/components/schemas/IncidentPhotoRead"},"type":"array","title":"Photos","description":"Photographs after the first. The first stays on `photo_url`, where it has always been.","default":[]},"user":{"anyOf":[{"$ref":"#/components/schemas/IncidentReporter"},{"type":"null"}]},"has_photo":{"type":"boolean","title":"Has Photo","readOnly":true},"photo_count":{"type":"integer","title":"Photo Count","readOnly":true},"needs_escalation":{"type":"boolean","title":"Needs Escalation","description":"Open, serious, and nobody has pushed it up yet.","readOnly":true},"is_open":{"type":"boolean","title":"Is Open","readOnly":true}},"type":"object","required":["id","company_id","user_id","reported_at","message","status","has_photo","photo_count","needs_escalation","is_open"],"title":"IncidentRead"},"IncidentReporter":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"phone":{"type":"string","title":"Phone"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"}},"type":"object","required":["id","phone"],"title":"IncidentReporter","description":"Enough of the user to read the company's incident list without a second request."},"IncidentSeverity":{"type":"string","enum":["low","medium","high","critical"],"title":"IncidentSeverity","description":"How bad it is. HIGH and CRITICAL are what a supervisor is told about."},"IncidentSeverityRead":{"properties":{"value":{"$ref":"#/components/schemas/IncidentSeverity"},"description":{"type":"string","title":"Description"},"escalates":{"type":"boolean","title":"Escalates","description":"Whether a report at this severity is meant to reach a supervisor rather than a list."}},"type":"object","required":["value","description","escalates"],"title":"IncidentSeverityRead"},"IncidentStatus":{"type":"string","enum":["open","closed"],"title":"IncidentStatus"},"IncidentStatusRead":{"properties":{"value":{"$ref":"#/components/schemas/IncidentStatus","description":"What to send as `status`","examples":["closed"]},"description":{"type":"string","title":"Description"},"is_default":{"type":"boolean","title":"Is Default","description":"The status a new report starts in"}},"type":"object","required":["value","description","is_default"],"title":"IncidentStatusRead"},"IncidentType":{"type":"string","enum":["access_breach","theft","vandalism","medical","power_utility","fire","suspicious_person","other"],"title":"IncidentType","description":"What happened. A fixed list, because free text cannot be counted."},"IncidentTypeRead":{"properties":{"value":{"$ref":"#/components/schemas/IncidentType"},"description":{"type":"string","title":"Description"}},"type":"object","required":["value","description"],"title":"IncidentTypeRead"},"IncidentUpdate":{"properties":{"message":{"anyOf":[{"type":"string","maxLength":2000,"minLength":1},{"type":"null"}],"title":"Message","description":"Correct or expand what was reported."},"status":{"anyOf":[{"$ref":"#/components/schemas/IncidentStatus"},{"type":"null"}],"description":"`closed` to close it, `open` to reopen it."},"resolution":{"anyOf":[{"type":"string","maxLength":2000,"minLength":1},{"type":"null"}],"title":"Resolution","description":"What was done about it. Only accepted when the report ends up closed - an open report cannot carry one.","examples":["Glazier replaced the pane on 2 October"]},"outcome":{"anyOf":[{"$ref":"#/components/schemas/IncidentOutcome"},{"type":"null"}],"description":"How it ended. Like `resolution`, only accepted when the report ends up closed. Required alongside a resolution when REQUIRE_INCIDENT_OUTCOME_ON_CLOSE is on.","examples":["resolved"]},"type":{"anyOf":[{"$ref":"#/components/schemas/IncidentType"},{"type":"null"}]},"severity":{"anyOf":[{"$ref":"#/components/schemas/IncidentSeverity"},{"type":"null"}]},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"},"location_description":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Location Description"},"police_involved":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Police Involved"},"saps_case_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Saps Case Number"},"assigned_to_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Assigned To User Id","description":"Hand the report to somebody to carry."},"escalate":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Escalate","description":"true stamps `escalated_at`, once. Escalating an already escalated report does not rewrite when it first went up."},"escalated_to_user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Escalated To User Id"}},"type":"object","title":"IncidentUpdate","description":"A partial update. Only the fields sent are touched.\n\n`status` is what opens and closes a report. Sending `closed` stamps `closed_at`;\nsending `open` on a closed report reopens it, which clears both `closed_at` and\n`resolution` - a reopened report has not been dealt with, so it cannot keep a\nnote saying it was."},"LocationSource":{"type":"string","enum":["device","manual","unknown"],"title":"LocationSource","description":"Where a coordinate pair came from, which decides how much it is worth.\n\nWhatsApp's location request lets the sender type an address instead of sharing\ntheir device's position, and the message that comes back looks the same either\nway. A typed address resolves to the middle of a suburb and proves nothing about\nwhere the sender was standing, so it is recorded as what it is rather than\nquietly treated as a reading."},"LocationStatus":{"type":"string","enum":["verified","outside_radius","unverified_source","no_coordinates","no_site_pin"],"title":"LocationStatus","description":"The verdict on one check-in or check-out.\n\nDecided once, at the moment the event is written, and stored on the row. It is\ndeliberately not computed on read: a site's pin can be corrected or its radius\nwidened next month, and the record has to keep saying what was true when the\nguard was standing there."},"Page_AssignmentRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/AssignmentRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[AssignmentRead]"},"Page_AttendanceRecordRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/AttendanceRecordRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[AttendanceRecordRead]"},"Page_ClientRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/ClientRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[ClientRead]"},"Page_CompanyRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/CompanyRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[CompanyRead]"},"Page_IncidentRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/IncidentRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[IncidentRead]"},"Page_ShiftRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/ShiftRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[ShiftRead]"},"Page_SiteRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/SiteRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[SiteRead]"},"Page_SiteRecord_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/SiteRecord"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[SiteRecord]"},"Page_UserRead_":{"properties":{"items":{"items":{"$ref":"#/components/schemas/UserRead"},"type":"array","title":"Items"},"total":{"type":"integer","title":"Total","description":"Total rows matching the query"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["items","total","limit","offset"],"title":"Page[UserRead]"},"PostCreate":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","examples":["Main gate"]},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"orders":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Orders","description":"Post orders: what the guard standing here is to do. Shown to them at check-in, and acknowledged there."},"requires_armed":{"type":"boolean","title":"Requires Armed","description":"True where only an armed guard may stand this post. Checked against the guard's category and firearm competency when a shift is rostered.","default":false}},"type":"object","required":["name"],"title":"PostCreate"},"PostRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"site_id":{"type":"string","format":"uuid","title":"Site Id"},"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"orders":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Orders"},"requires_armed":{"type":"boolean","title":"Requires Armed"},"is_active":{"type":"boolean","title":"Is Active"}},"type":"object","required":["id","site_id","name","requires_armed","is_active"],"title":"PostRead"},"PostUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"orders":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Orders"},"requires_armed":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Requires Armed"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"PostUpdate"},"PsiraGrade":{"type":"string","enum":["A","B","C","D","E"],"title":"PsiraGrade","description":"PSiRA grades A to E. A is the most senior."},"Punctuality":{"properties":{"status":{"type":"string","enum":["early","on_time","late"],"title":"Status"},"minutes":{"type":"integer","minimum":0.0,"title":"Minutes","description":"Whole minutes in the `status` direction; 0 when on time."}},"type":"object","required":["status","minutes"],"title":"Punctuality","description":"How an actual time compared with the time the guard was due.\n\n`minutes` is always a magnitude (0 or more); `status` carries the direction,\nso there is never a minus sign to interpret. Under a full minute either way is\n`on_time` with `minutes` 0 - a check-in forty seconds late is not worth a red\nmark. The whole-minute magnitude matches `Shift.minutes_late`, so the two\nagree about how late a late arrival was."},"RegionCreate":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","examples":["Gauteng South"]},"client_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id","description":"Narrow the region to one client. Omit for a region that spans the whole company."}},"type":"object","required":["name"],"title":"RegionCreate"},"RegionRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"client_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"},"name":{"type":"string","title":"Name"},"is_active":{"type":"boolean","title":"Is Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","company_id","name","is_active","created_at","updated_at"],"title":"RegionRead"},"RegionUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Name"},"client_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"RegionUpdate"},"RegistrationField":{"properties":{"name":{"type":"string","title":"Name"},"required":{"type":"boolean","title":"Required"},"type":{"type":"string","title":"Type"},"description":{"type":"string","title":"Description"},"example":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Example"}},"type":"object","required":["name","required","type","description"],"title":"RegistrationField"},"RegistrationFields":{"properties":{"registration":{"items":{"$ref":"#/components/schemas/RegistrationField"},"type":"array","title":"Registration"},"branch":{"items":{"$ref":"#/components/schemas/RegistrationField"},"type":"array","title":"Branch"},"notes":{"items":{"type":"string"},"type":"array","title":"Notes"}},"type":"object","required":["registration","branch","notes"],"title":"RegistrationFields","description":"What a registration collects, as data a form can be built from.\n\nThe endpoint takes two different shapes - a registration and a branch - so its\nOpenAPI request body can only mark the fields common to both as required.\n`full_name`, `email`, `phone` and `terms_and_conditions` are required for a\nregistration and not asked for on a branch, which a single `required` array\ncannot say. This endpoint says it instead, rather than leaving a form builder\nto read prose."},"RoleRead":{"properties":{"value":{"$ref":"#/components/schemas/UserRole","description":"What to send as `role`","examples":["admin"]},"description":{"type":"string","title":"Description"},"is_default":{"type":"boolean","title":"Is Default","description":"Used when `role` is omitted"}},"type":"object","required":["value","description","is_default"],"title":"RoleRead"},"RowOutcome":{"type":"string","enum":["created","updated","skipped","failed"],"title":"RowOutcome"},"ServerTime":{"properties":{"timezone":{"type":"string","title":"Timezone","examples":["Africa/Johannesburg"]},"utc_offset":{"type":"string","title":"Utc Offset","description":"The offset in force right now, e.g. '+0200'.","examples":["+0200"]},"utc_now":{"type":"string","format":"date-time","title":"Utc Now","description":"The current instant, in UTC."},"local_now":{"type":"string","format":"date-time","title":"Local Now","description":"The same instant as a wall clock where the company is."},"today":{"type":"string","format":"date","title":"Today","description":"The current date in that timezone. What a date-only field such as `psira_expiry` is compared against."},"notes":{"items":{"type":"string"},"type":"array","title":"Notes"}},"type":"object","required":["timezone","utc_offset","utc_now","local_now","today","notes"],"title":"ServerTime"},"ShiftBulkCreate":{"properties":{"shifts":{"items":{"$ref":"#/components/schemas/ShiftCreate"},"type":"array","maxItems":500,"minItems":1,"title":"Shifts"}},"type":"object","required":["shifts"],"title":"ShiftBulkCreate","description":"A roster written in one go. Either all of it lands or none of it does, so a\nhalf-written week never has to be unpicked by hand."},"ShiftCreate":{"properties":{"site_id":{"type":"string","format":"uuid","title":"Site Id"},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"},"user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"User Id","description":"The guard rostered for it. Omit for an open shift - one that is on the roster with nobody assigned yet."},"starts_at":{"type":"string","format":"date-time","title":"Starts At","description":"When the shift begins. **Send an offset** - `...Z` or `+02:00` - and it is taken as sent. A value with no offset is read as wall-clock time in the deployment's timezone (`GET /api/v1/time`), because that is what a `datetime-local` input produces and what whoever typed it meant.","examples":["2026-11-03T18:00:00Z"]},"ends_at":{"type":"string","format":"date-time","title":"Ends At","description":"Use the next day's date for a night shift - these are instants, not clock faces.","examples":["2026-11-04T06:00:00Z"]},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"}},"type":"object","required":["site_id","starts_at","ends_at"],"title":"ShiftCreate"},"ShiftGuard":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"phone":{"type":"string","title":"Phone"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"guard_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Guard Number"}},"type":"object","required":["id","phone"],"title":"ShiftGuard"},"ShiftRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"site_id":{"type":"string","format":"uuid","title":"Site Id"},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"},"user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"User Id"},"starts_at":{"type":"string","format":"date-time","title":"Starts At"},"ends_at":{"type":"string","format":"date-time","title":"Ends At"},"cancelled_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Cancelled At"},"cancelled_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cancelled Reason"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"},"site":{"anyOf":[{"$ref":"#/components/schemas/SiteSummary"},{"type":"null"}]},"user":{"anyOf":[{"$ref":"#/components/schemas/ShiftGuard"},{"type":"null"}]},"status":{"$ref":"#/components/schemas/ShiftStatus","description":"Derived from the clock and from whether a check-in landed."},"minutes_late":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Minutes Late","description":"How late the guard was, in whole minutes. Null when nobody checked in; 0 - never negative - for a guard who arrived early."},"attendance_record_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Attendance Record Id","description":"The check-in that answered this shift, if one did."}},"type":"object","required":["id","company_id","site_id","starts_at","ends_at","created_at","updated_at","status"],"title":"ShiftRead"},"ShiftStatus":{"type":"string","enum":["scheduled","in_progress","completed","late","missed","cancelled"],"title":"ShiftStatus","description":"What a roster entry is doing now.\n\nOnly CANCELLED is written by a person. The rest are decided by comparing the\nclock to the shift's own times and to whether a check-in landed, so they cannot\ndisagree with the attendance table."},"ShiftStatusRead":{"properties":{"value":{"$ref":"#/components/schemas/ShiftStatus"},"description":{"type":"string","title":"Description"}},"type":"object","required":["value","description"],"title":"ShiftStatusRead"},"ShiftUpdate":{"properties":{"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"},"user_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"User Id","description":"Send a different guard to reassign the shift."},"starts_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Starts At"},"ends_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Ends At"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"cancelled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Cancelled","description":"true calls the shift off; false reinstates it. The only status anybody sets by hand."},"cancelled_reason":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Cancelled Reason"}},"type":"object","title":"ShiftUpdate"},"SiteCreate":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","examples":["Boxer Lesedi"]},"client_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"},"region_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Region Id"},"address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address","examples":["12 Lesedi Drive, Soweto"]},"latitude":{"anyOf":[{"type":"number","maximum":90.0,"minimum":-90.0},{"type":"null"}],"title":"Latitude","examples":[-26.204103]},"longitude":{"anyOf":[{"type":"number","maximum":180.0,"minimum":-180.0},{"type":"null"}],"title":"Longitude","examples":[28.047305]},"check_in_radius_m":{"anyOf":[{"type":"integer","maximum":50000.0,"exclusiveMinimum":0.0},{"type":"null"}],"title":"Check In Radius M","description":"Metres from the pin a check-in may be and still count as on site. Defaults to DEFAULT_CHECK_IN_RADIUS_M when omitted.","examples":[150]},"contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Name"},"contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Contact Phone"}},"type":"object","required":["name"],"title":"SiteCreate"},"SiteRead":{"properties":{"id":{"type":"string","format":"uuid","title":"Id","description":"Also the company id, for every other endpoint"},"name":{"type":"string","title":"Name","examples":["Acme Canal Walk"]},"slug":{"type":"string","title":"Slug","examples":["acme-canal-walk"]},"location":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Location","description":"Free text, as captured on the company. Null when never set - a site with no address, not a site at the origin.","examples":["Shop 4, Canal Walk, Century City"]},"is_active":{"type":"boolean","title":"Is Active","description":"False for a site taken out of service"},"guard_count":{"type":"integer","title":"Guard Count","description":"Active users assigned to this site. Counts people on the books, not people currently on site.","default":0},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site record behind this company, which is where the pin, the radius and the posts live. Use it with `/sites/{site_id}`."},"latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Latitude","examples":[-26.204103]},"longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Longitude","examples":[28.047305]},"check_in_radius_m":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Check In Radius M","description":"Metres from the pin a check-in may be and still count as on site. Null means no radius is set, and every check-in here is recorded unverified.","examples":[150]}},"type":"object","required":["id","name","slug","is_active"],"title":"SiteRead","description":"A place a company guards, as listed by `GET /companies/{id}/sites`.\n\nA site is a branch - a company one level beneath a main company - seen through\nthe lens of \"where is it and who works there\". The same row is available in\nfull as a `CompanyRead`; this is the slim view a site list needs, so the\ncaller is not handed a password-bearing company record to render a map pin."},"SiteRecord":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"client_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"},"region_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Region Id"},"name":{"type":"string","title":"Name"},"address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address"},"latitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Latitude"},"longitude":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Longitude"},"check_in_radius_m":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Check In Radius M"},"contact_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Name"},"contact_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Phone"},"is_active":{"type":"boolean","title":"Is Active"},"legacy_company_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Legacy Company Id","description":"The company row this site stands in for, when it has one. Set for every site that existed as a company before sites did, and for every company registered since - which is what keeps a client that only knows about companies working."},"guard_count":{"type":"integer","title":"Guard Count","description":"Active guards posted here. People on the books, not people currently on site.","default":0},"posts":{"items":{"$ref":"#/components/schemas/PostRead"},"type":"array","title":"Posts","default":[]},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"},"can_verify_check_ins":{"type":"boolean","title":"Can Verify Check Ins","description":"Whether a check-in here can be proved. False until the site has a pin\nand a radius; every check-in until then is recorded `no_site_pin`.","readOnly":true}},"type":"object","required":["id","company_id","name","is_active","created_at","updated_at","can_verify_check_ins"],"title":"SiteRecord","description":"A site in full.\n\nNamed `SiteRecord` rather than `SiteRead` because `SiteRead` is already taken\nby the older, company-shaped view that `GET /companies/{id}/sites` returns, and\nthat view has callers."},"SiteSummary":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address"}},"type":"object","required":["id","name"],"title":"SiteSummary","description":"Enough of a site to label a row that happened at it."},"SiteUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Name"},"client_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Client Id"},"region_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Region Id"},"address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address"},"latitude":{"anyOf":[{"type":"number","maximum":90.0,"minimum":-90.0},{"type":"null"}],"title":"Latitude","examples":[-26.204103]},"longitude":{"anyOf":[{"type":"number","maximum":180.0,"minimum":-180.0},{"type":"null"}],"title":"Longitude","examples":[28.047305]},"check_in_radius_m":{"anyOf":[{"type":"integer","maximum":50000.0,"exclusiveMinimum":0.0},{"type":"null"}],"title":"Check In Radius M"},"contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Name"},"contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Contact Phone"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"SiteUpdate"},"Token":{"properties":{"access_token":{"type":"string","title":"Access Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"},"expires_in":{"type":"integer","title":"Expires In","description":"Seconds until the token expires"},"company":{"$ref":"#/components/schemas/CompanySummary"},"user":{"anyOf":[{"$ref":"#/components/schemas/TokenUser"},{"type":"null"}],"description":"Null for a company login, which is what this endpoint returned before named users existed."}},"type":"object","required":["access_token","expires_in","company"],"title":"Token"},"TokenUser":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"phone":{"type":"string","title":"Phone"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"role":{"$ref":"#/components/schemas/UserRole"},"can_manage_company":{"type":"boolean","title":"Can Manage Company","description":"Whether this person's role lets them administer the company. False for a MEMBER, who is a guard."}},"type":"object","required":["id","phone","role","can_manage_company"],"title":"TokenUser","description":"Who the token belongs to, when it belongs to a person."},"UserCreate":{"properties":{"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site this guard is posted to. Changeable later."},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id","description":"A post within that site, e.g. the main gate."},"guard_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Guard Number","description":"The number on the ID card and the roster. Unique within the company. Short and stable - unlike the cell number, which changes when a phone is lost or swapped.","examples":["BKL-0142"]},"id_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Id Number","description":"SA ID or passport number. Masked on the way out."},"job_title":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Job Title","description":"What the staff list calls them - 'Security Officer', 'Supervisor', 'Security Officer (Reliever)'. Free text, and it grants nothing: `role` is what decides what somebody may do here, and a payroll title must never set it.","examples":["Security Officer"]},"psira_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Psira Number","description":"PSiRA registration number. Unique within the company."},"psira_grade":{"anyOf":[{"$ref":"#/components/schemas/PsiraGrade"},{"type":"null"}],"examples":["C"]},"psira_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Psira Expiry","description":"When the registration lapses. Drives the expiry alerts.","examples":["2027-03-31"]},"category":{"anyOf":[{"$ref":"#/components/schemas/GuardCategory"},{"type":"null"}],"examples":["unarmed"]},"firearm_competency_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Firearm Competency Number"},"firearm_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Firearm Types","description":"What the competency covers. One or more of: handgun, shotgun, rifle, self_loading_rifle.","examples":[["handgun","shotgun"]]},"firearm_competency_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Firearm Competency Expiry"},"emergency_contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Emergency Contact Name"},"emergency_contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Emergency Contact Phone"},"biometric_consent_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Biometric Consent At","description":"When this guard consented to their photograph being taken and kept. A selfie is biometric data under POPIA; send this at onboarding."},"phone":{"type":"string","maxLength":32,"title":"Phone","description":"The guard's **WhatsApp number**, in international format. Required: it is how a guard is identified within their company, and the channel they check in on. Stored normalized to E.164, so '+27 82 123 4567' and '+27821234567' are the same number. The field is called `phone` because it always has been; renaming it would break every existing client.","examples":["+27821234567"]},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","description":"Optional contact address. Not an identifier - not unique.","examples":["ada@acme.example.com"]},"full_name":{"type":"string","maxLength":255,"minLength":1,"title":"Full Name","description":"The guard's full name, as their staff list writes it. Required. Surname-first is fine - it is stored exactly as sent.","examples":["Magqaza Wanda"]},"role":{"$ref":"#/components/schemas/UserRole","default":"member","examples":["member"]},"password":{"anyOf":[{"type":"string","maxLength":128,"minLength":8},{"type":"null"}],"title":"Password","description":"Optional. Users do not log in - their company does - so a guard can be registered without one. Omit it or send null to leave it unset.","examples":["sup3r-secret"]}},"type":"object","required":["phone","full_name"],"title":"UserCreate","description":"Registering a guard.\n\n**Exactly two fields are required: `full_name` and `phone`** - the name, and\nthe WhatsApp number that identifies them. Everything else on this model is\noptional, including the PSiRA details, the category, the site and the\npassword, so a guard can be put on the books from a name and a number and\nfilled in later.\n\n(`REQUIRE_GUARD_COMPLIANCE_FIELDS` is the one setting that adds to that list.\nIt is **off** by default, and turning it on is a deliberate decision to refuse\na guard with no PSiRA registration.)"},"UserLogin":{"properties":{"company_slug":{"type":"string","maxLength":255,"minLength":1,"title":"Company Slug","examples":["acme-industries"]},"phone":{"type":"string","maxLength":32,"title":"Phone","examples":["+27821234567"]},"password":{"type":"string","maxLength":128,"minLength":1,"title":"Password"}},"type":"object","required":["company_slug","phone","password"],"title":"UserLogin","description":"A named person logging in, rather than their company.\n\nThe company is named too, because a cell number identifies a user *within* a\ncompany - the same number may belong to one person working for two employers."},"UserRead":{"properties":{"phone":{"type":"string","maxLength":32,"title":"Phone","description":"The guard's **WhatsApp number**, in international format. Required: it is how a guard is identified within their company, and the channel they check in on. Stored normalized to E.164, so '+27 82 123 4567' and '+27821234567' are the same number. The field is called `phone` because it always has been; renaming it would break every existing client.","examples":["+27821234567"]},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","description":"Optional contact address. Not an identifier - not unique.","examples":["ada@acme.example.com"]},"full_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Full Name","examples":["Ada Lovelace"]},"role":{"$ref":"#/components/schemas/UserRole","default":"member","examples":["member"]},"id":{"type":"string","format":"uuid","title":"Id"},"company_id":{"type":"string","format":"uuid","title":"Company Id"},"company":{"anyOf":[{"$ref":"#/components/schemas/CompanySummary"},{"type":"null"}]},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"},"site":{"anyOf":[{"$ref":"#/components/schemas/SiteSummary"},{"type":"null"}]},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id"},"is_active":{"type":"boolean","title":"Is Active"},"guard_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Guard Number"},"job_title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Job Title"},"id_number_masked":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id Number Masked","description":"The ID number with all but its last four digits hidden. The full value is never returned by a list or a read.","examples":["**********1234"]},"psira_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Psira Number"},"psira_grade":{"anyOf":[{"$ref":"#/components/schemas/PsiraGrade"},{"type":"null"}]},"psira_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Psira Expiry"},"category":{"anyOf":[{"$ref":"#/components/schemas/GuardCategory"},{"type":"null"}]},"firearm_competency_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Firearm Competency Number"},"firearm_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Firearm Types"},"firearm_competency_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Firearm Competency Expiry"},"emergency_contact_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emergency Contact Name"},"emergency_contact_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emergency Contact Phone"},"biometric_consent_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Biometric Consent At"},"compliance":{"anyOf":[{"$ref":"#/components/schemas/ComplianceRead"},{"type":"null"}],"description":"Filled in on every read. Computed from the dates above against today."},"photo_bucket":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Photo Bucket"},"photo_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Photo Key"},"photo_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Photo Url","description":"Presigned link to the account photo, valid for MINIO_URL_EXPIRY_SECONDS. Regenerated on every read - do not store it. Null when the user has no photo."},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["phone","id","company_id","is_active","created_at","updated_at"],"title":"UserRead"},"UserRegister":{"properties":{"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site this guard is posted to. Changeable later."},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id","description":"A post within that site, e.g. the main gate."},"guard_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Guard Number","description":"The number on the ID card and the roster. Unique within the company. Short and stable - unlike the cell number, which changes when a phone is lost or swapped.","examples":["BKL-0142"]},"id_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Id Number","description":"SA ID or passport number. Masked on the way out."},"job_title":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Job Title","description":"What the staff list calls them - 'Security Officer', 'Supervisor', 'Security Officer (Reliever)'. Free text, and it grants nothing: `role` is what decides what somebody may do here, and a payroll title must never set it.","examples":["Security Officer"]},"psira_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Psira Number","description":"PSiRA registration number. Unique within the company."},"psira_grade":{"anyOf":[{"$ref":"#/components/schemas/PsiraGrade"},{"type":"null"}],"examples":["C"]},"psira_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Psira Expiry","description":"When the registration lapses. Drives the expiry alerts.","examples":["2027-03-31"]},"category":{"anyOf":[{"$ref":"#/components/schemas/GuardCategory"},{"type":"null"}],"examples":["unarmed"]},"firearm_competency_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Firearm Competency Number"},"firearm_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Firearm Types","description":"What the competency covers. One or more of: handgun, shotgun, rifle, self_loading_rifle.","examples":[["handgun","shotgun"]]},"firearm_competency_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Firearm Competency Expiry"},"emergency_contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Emergency Contact Name"},"emergency_contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Emergency Contact Phone"},"biometric_consent_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Biometric Consent At","description":"When this guard consented to their photograph being taken and kept. A selfie is biometric data under POPIA; send this at onboarding."},"phone":{"type":"string","maxLength":32,"title":"Phone","description":"The guard's **WhatsApp number**, in international format. Required: it is how a guard is identified within their company, and the channel they check in on. Stored normalized to E.164, so '+27 82 123 4567' and '+27821234567' are the same number. The field is called `phone` because it always has been; renaming it would break every existing client.","examples":["+27821234567"]},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","description":"Optional contact address. Not an identifier - not unique.","examples":["ada@acme.example.com"]},"full_name":{"type":"string","maxLength":255,"minLength":1,"title":"Full Name","description":"The guard's full name, as their staff list writes it. Required. Surname-first is fine - it is stored exactly as sent.","examples":["Magqaza Wanda"]},"role":{"$ref":"#/components/schemas/UserRole","default":"member","examples":["member"]},"password":{"anyOf":[{"type":"string","maxLength":128,"minLength":8},{"type":"null"}],"title":"Password","description":"Optional. Users do not log in - their company does - so a guard can be registered without one. Omit it or send null to leave it unset.","examples":["sup3r-secret"]},"company_id":{"type":"string","format":"uuid","title":"Company Id","description":"Company the user belongs to"}},"type":"object","required":["phone","full_name","company_id"],"title":"UserRegister","description":"Self-service registration: the company is named in the body."},"UserRole":{"type":"string","enum":["owner","admin","member"],"title":"UserRole"},"UserUpdate":{"properties":{"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id","description":"The site this guard is posted to. Changeable later."},"post_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Post Id","description":"A post within that site, e.g. the main gate."},"guard_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Guard Number","description":"The number on the ID card and the roster. Unique within the company. Short and stable - unlike the cell number, which changes when a phone is lost or swapped.","examples":["BKL-0142"]},"id_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Id Number","description":"SA ID or passport number. Masked on the way out."},"job_title":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Job Title","description":"What the staff list calls them - 'Security Officer', 'Supervisor', 'Security Officer (Reliever)'. Free text, and it grants nothing: `role` is what decides what somebody may do here, and a payroll title must never set it.","examples":["Security Officer"]},"psira_number":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Psira Number","description":"PSiRA registration number. Unique within the company."},"psira_grade":{"anyOf":[{"$ref":"#/components/schemas/PsiraGrade"},{"type":"null"}],"examples":["C"]},"psira_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Psira Expiry","description":"When the registration lapses. Drives the expiry alerts.","examples":["2027-03-31"]},"category":{"anyOf":[{"$ref":"#/components/schemas/GuardCategory"},{"type":"null"}],"examples":["unarmed"]},"firearm_competency_number":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Firearm Competency Number"},"firearm_types":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Firearm Types","description":"What the competency covers. One or more of: handgun, shotgun, rifle, self_loading_rifle.","examples":[["handgun","shotgun"]]},"firearm_competency_expiry":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Firearm Competency Expiry"},"emergency_contact_name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Emergency Contact Name"},"emergency_contact_phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Emergency Contact Phone"},"biometric_consent_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Biometric Consent At","description":"When this guard consented to their photograph being taken and kept. A selfie is biometric data under POPIA; send this at onboarding."},"phone":{"anyOf":[{"type":"string","maxLength":32},{"type":"null"}],"title":"Phone"},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email"},"full_name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Full Name","description":"Correct the name. Cannot be set to null - a guard must have one."},"role":{"anyOf":[{"$ref":"#/components/schemas/UserRole"},{"type":"null"}]},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"},"password":{"anyOf":[{"type":"string","maxLength":128,"minLength":8},{"type":"null"}],"title":"Password"},"company_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Company Id","description":"Move the guard to another company. Only a company that may manage both ends can do it."},"assignment_reason":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Assignment Reason","description":"Why they were moved. Recorded against the change, not on the user.","examples":["Covering Lesedi while Sipho is on leave"]}},"type":"object","title":"UserUpdate","description":"A partial update: only the fields sent are touched.\n\n`full_name` and `phone` may be **corrected** but not **cleared** - sending\neither as null is refused, because a guard is required to have both. Every\nother field accepts null to clear it."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/api/v1/auth/token"}}}}},"tags":[{"name":"auth","description":"Log in as a company, or as a named person. A person's token records **who** did what - which is what makes an audit trail say 'closed by Thabo Mokoena' rather than naming the shared company login. `/auth/posture` says what this deployment currently requires."},{"name":"companies","description":"Register and manage companies (tenants)."},{"name":"clients","description":"Who the guarding is done for, and the optional regions their sites are grouped into. One client holds many sites - the level the two-deep company tree had no room for."},{"name":"sites","description":"The places being guarded, and the posts within them. A site carries the pin and radius a check-in is measured against, and needs no login of its own.\n\n`/companies/{id}/sites` is the older, company-shaped view and still answers; `/companies/{id}/site-records` is the full one."},{"name":"shifts","description":"The roster. A shift is written **before** anybody arrives, which is what makes 'nobody turned up' answerable - and what the dashboard's Attendance % and On-Time % are computed from."},{"name":"users","description":"Guards and administrators. A guard is an employment and compliance record: a guard number, a PSiRA registration and grade, a category, and - for armed duty - a dated firearm competency. Their posting can be changed, and every change is kept."},{"name":"attendance","description":"Check-in and check-out, each judged against the site's pin and radius. `needs_review=true` on a company's table lists the arrivals a person should look at."},{"name":"incidents","description":"A guard reports what happened: a message, a type, a severity, a place and any number of photographs. Every report gets a short reference - `INC-0001` - which is what people quote. Closing one records when, by whom, what was done and how it ended."},{"name":"imports","description":"Registering guards from a `.xlsx` or `.csv` staff list - as the operator already keeps it, banner rows and national cell numbers and all. **Preview first**: that endpoint writes nothing and reports what an import would do, row by row."},{"name":"compliance","description":"PSiRA registrations and firearm competencies that have lapsed or are about to."},{"name":"health","description":"Liveness and readiness probes."}]}