{"openapi":"3.0.3","info":{"title":"PolicyTrak API","version":"1.0.0","description":"REST API for PolicyTrak — a compliance management platform for managing policies, SOPs, locations, employees, acknowledgments, and regulatory law tracking.\n\n## Authentication\n\n**Session (cookie)** — Most endpoints require a valid session obtained via `POST /api/auth/login` or `POST /api/auth/verify`. The session cookie is set automatically.\n\n**HMAC-SHA256 (External API)** — The `/api/v1/external/*` endpoints use HMAC-SHA256 request signing. Include `X-API-Key`, `X-Timestamp` (Unix ms), and `X-Signature` headers.\n\n**API Key (SmartShifts polling)** — The SmartShifts polling endpoints (`/api/smartshifts/employees`) use `X-API-Key` header.","contact":{"name":"PolicyTrak Support"}},"servers":[{"url":"/","description":"Current environment"}],"tags":[{"name":"Authentication","description":"Login, logout, password reset, signup"},{"name":"Session","description":"Current user and tenant session"},{"name":"Organizations","description":"Tenant (organization) management"},{"name":"Policies","description":"Policy creation, editing, publishing, and assignment"},{"name":"SOPs","description":"Standard Operating Procedure management"},{"name":"Locations","description":"Location management and compliance fields"},{"name":"Members","description":"Tenant members, teams, and roles"},{"name":"Portal Employees","description":"Employee portal access and acknowledgments"},{"name":"Acknowledgments","description":"Document acknowledgment tracking"},{"name":"Resources","description":"Resource library (links, videos, documents)"},{"name":"Law Events","description":"Regulatory law event tracking"},{"name":"Compliance","description":"Compliance checks and monitoring"},{"name":"Audit Logs","description":"Immutable audit trail"},{"name":"Reports","description":"Compliance reports and summaries"},{"name":"Search","description":"Full-text search across the platform"},{"name":"Notifications","description":"In-app and push notifications"},{"name":"Webhooks","description":"Outbound webhook configuration"},{"name":"External Apps","description":"Third-party integration management"},{"name":"SmartShifts","description":"SmartShifts workforce integration — polling and webhook endpoints"},{"name":"External API v1","description":"Machine-to-machine API using HMAC-SHA256 signing"}],"components":{"securitySchemes":{"sessionCookie":{"type":"apiKey","in":"cookie","name":"sid","description":"Session cookie obtained after login"},"hmacAuth":{"type":"apiKey","in":"header","name":"X-Signature","description":"HMAC-SHA256 signature for External API v1. Also requires X-API-Key and X-Timestamp headers."},"apiKey":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API key for SmartShifts polling endpoints"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"Tenant":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"businessType":{"type":"string","nullable":true},"industry":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"}}},"User":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string","nullable":true},"role":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"Policy":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"content":{"type":"string","nullable":true},"isPublished":{"type":"boolean"},"category":{"type":"string","nullable":true},"version":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Sop":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"content":{"type":"string","nullable":true},"isPublished":{"type":"boolean"},"category":{"type":"string","nullable":true},"version":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Location":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"address":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"state":{"type":"string","nullable":true},"country":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"}}},"Member":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"email":{"type":"string"},"name":{"type":"string","nullable":true},"role":{"type":"string","enum":["OWNER","ADMIN","MANAGER","MEMBER"]},"joinedAt":{"type":"string","format":"date-time"}}},"PortalEmployee":{"type":"object","properties":{"id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"isActive":{"type":"boolean"},"locationIds":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"}}},"AcknowledgmentRequest":{"type":"object","properties":{"id":{"type":"string"},"documentType":{"type":"string","enum":["policy","sop"]},"documentId":{"type":"string"},"documentTitle":{"type":"string"},"status":{"type":"string","enum":["pending","acknowledged","declined"]},"acknowledgedAt":{"type":"string","format":"date-time","nullable":true},"createdAt":{"type":"string","format":"date-time"}}},"Resource":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string","nullable":true},"type":{"type":"string","enum":["video_link","document","external_link"]},"url":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"},"nullable":true},"createdAt":{"type":"string","format":"date-time"}}},"LawEvent":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string","nullable":true},"jurisdiction":{"type":"string","nullable":true},"effectiveDate":{"type":"string","format":"date","nullable":true},"status":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"AuditLog":{"type":"object","properties":{"id":{"type":"string"},"action":{"type":"string"},"resourceType":{"type":"string"},"resourceId":{"type":"string","nullable":true},"userId":{"type":"string","nullable":true},"tenantId":{"type":"string"},"metadata":{"type":"object","nullable":true},"createdAt":{"type":"string","format":"date-time"}}},"ExternalEmployee":{"type":"object","properties":{"id":{"type":"string"},"externalId":{"type":"string"},"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"role":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"isActive":{"type":"boolean"},"matched":{"type":"boolean","description":"Whether this external employee matches a portal employee by email"},"pendingAcks":{"type":"integer"},"completedAcks":{"type":"integer"}}}}},"paths":{"/api/auth/login":{"post":{"tags":["Authentication"],"summary":"Log in with email and password","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","format":"password"}}}}}},"responses":{"200":{"description":"Login successful — session cookie is set"},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited"}}}},"/api/auth/logout":{"post":{"tags":["Authentication"],"summary":"Log out and clear session","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Logged out successfully"}}}},"/api/auth/start":{"post":{"tags":["Authentication"],"summary":"Start OTP-based login (send verification code to email)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"}}}}}},"responses":{"200":{"description":"Verification code sent"},"429":{"description":"Rate limited"}}}},"/api/auth/verify":{"post":{"tags":["Authentication"],"summary":"Verify OTP code and complete login","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","code"],"properties":{"email":{"type":"string","format":"email"},"code":{"type":"string"}}}}}},"responses":{"200":{"description":"Login successful — session cookie is set"},"401":{"description":"Invalid or expired code"}}}},"/api/auth/register":{"post":{"tags":["Authentication"],"summary":"Register a new account with email and password","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password","name"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","minLength":8},"name":{"type":"string"}}}}}},"responses":{"201":{"description":"Account created"},"409":{"description":"Email already in use"}}}},"/api/auth/forgot-password":{"post":{"tags":["Authentication"],"summary":"Request a password reset email","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"}}}}}},"responses":{"200":{"description":"Reset email sent (if account exists)"}}}},"/api/auth/reset-password":{"post":{"tags":["Authentication"],"summary":"Reset password using a verified reset code","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","code","password"],"properties":{"email":{"type":"string"},"code":{"type":"string"},"password":{"type":"string","minLength":8}}}}}},"responses":{"200":{"description":"Password updated"},"400":{"description":"Invalid or expired code"}}}},"/api/me":{"get":{"tags":["Session"],"summary":"Get the current authenticated user","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Current user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"description":"Not authenticated"}}}},"/api/tenants":{"get":{"tags":["Organizations"],"summary":"List organizations the current user belongs to","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"List of tenants","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Tenant"}}}}}}},"post":{"tags":["Organizations"],"summary":"Create a new organization","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"businessType":{"type":"string"},"industry":{"type":"string"}}}}}},"responses":{"201":{"description":"Organization created"}}}},"/api/tenants/current":{"get":{"tags":["Organizations"],"summary":"Get the active organization for the current session","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Current organization","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tenant"}}}}}}},"/api/tenants/settings":{"patch":{"tags":["Organizations"],"summary":"Update organization settings (Admin only)","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"timezone":{"type":"string"},"businessType":{"type":"string"},"industry":{"type":"string"}}}}}},"responses":{"200":{"description":"Settings updated"},"403":{"description":"Insufficient permissions"}}}},"/api/tenants/{id}/switch":{"post":{"tags":["Organizations"],"summary":"Switch the active organization","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Switched successfully"}}}},"/api/policies":{"get":{"tags":["Policies"],"summary":"List all policies for the active organization","security":[{"sessionCookie":[]}],"parameters":[{"name":"search","in":"query","schema":{"type":"string"},"description":"Full-text search"},{"name":"category","in":"query","schema":{"type":"string"}},{"name":"isPublished","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Policies list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Policy"}}}}}}},"post":{"tags":["Policies"],"summary":"Create a new policy (Admin/Manager)","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"content":{"type":"string"},"category":{"type":"string"}}}}}},"responses":{"201":{"description":"Policy created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Policy"}}}}}}},"/api/policies/{id}":{"get":{"tags":["Policies"],"summary":"Get a policy by ID","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Policy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Policy"}}}},"404":{"description":"Not found"}}},"patch":{"tags":["Policies"],"summary":"Update a policy","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string"},"content":{"type":"string"},"category":{"type":"string"},"isPublished":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Policy updated"},"404":{"description":"Not found"}}},"delete":{"tags":["Policies"],"summary":"Delete a policy","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"},"404":{"description":"Not found"}}}},"/api/sop":{"get":{"tags":["SOPs"],"summary":"List all SOPs for the active organization","security":[{"sessionCookie":[]}],"parameters":[{"name":"search","in":"query","schema":{"type":"string"}},{"name":"category","in":"query","schema":{"type":"string"}},{"name":"isPublished","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"SOPs list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Sop"}}}}}}},"post":{"tags":["SOPs"],"summary":"Create a new SOP","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"content":{"type":"string"},"category":{"type":"string"}}}}}},"responses":{"201":{"description":"SOP created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Sop"}}}}}}},"/api/sop/{id}":{"get":{"tags":["SOPs"],"summary":"Get a SOP by ID","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"SOP","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Sop"}}}},"404":{"description":"Not found"}}},"patch":{"tags":["SOPs"],"summary":"Update a SOP","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string"},"content":{"type":"string"},"category":{"type":"string"},"isPublished":{"type":"boolean"}}}}}},"responses":{"200":{"description":"SOP updated"}}},"delete":{"tags":["SOPs"],"summary":"Delete a SOP","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}},"/api/locations":{"get":{"tags":["Locations"],"summary":"List all locations","security":[{"sessionCookie":[]}],"parameters":[{"name":"search","in":"query","schema":{"type":"string"}},{"name":"state","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Locations list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Location"}}}}}}},"post":{"tags":["Locations"],"summary":"Create a new location","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"address":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string"}}}}}},"responses":{"201":{"description":"Location created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Location"}}}}}}},"/api/locations/{id}":{"get":{"tags":["Locations"],"summary":"Get a location by ID","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Location","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Location"}}}},"404":{"description":"Not found"}}},"patch":{"tags":["Locations"],"summary":"Update a location","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"address":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Locations"],"summary":"Delete a location","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}},"/api/locations/{id}/resources":{"get":{"tags":["Locations"],"summary":"List resources assigned to a location","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Resources","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Resource"}}}}}}}},"/api/locations/{id}/acknowledgment-summary":{"get":{"tags":["Locations"],"summary":"Get acknowledgment summary for a location","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Summary with policy and SOP completion percentages"}}}},"/api/members":{"get":{"tags":["Members"],"summary":"List all members of the active organization","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Members list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Member"}}}}}}}},"/api/portal-employees":{"get":{"tags":["Portal Employees"],"summary":"List portal employees (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"search","in":"query","schema":{"type":"string"}},{"name":"locationId","in":"query","schema":{"type":"string"}},{"name":"isActive","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Portal employees","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PortalEmployee"}}}}}}},"post":{"tags":["Portal Employees"],"summary":"Create a portal employee (Admin only)","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["firstName","lastName","email"],"properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"locationIds":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"201":{"description":"Employee created"}}}},"/api/portal-employees/{id}":{"get":{"tags":["Portal Employees"],"summary":"Get a portal employee by ID","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Employee","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PortalEmployee"}}}},"404":{"description":"Not found"}}},"patch":{"tags":["Portal Employees"],"summary":"Update a portal employee","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"locationIds":{"type":"array","items":{"type":"string"}},"isActive":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Portal Employees"],"summary":"Delete a portal employee","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}},"/api/acknowledgments":{"post":{"tags":["Acknowledgments"],"summary":"Record an acknowledgment","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["documentType","documentId"],"properties":{"documentType":{"type":"string","enum":["policy","sop"]},"documentId":{"type":"string"},"signature":{"type":"string","nullable":true}}}}}},"responses":{"200":{"description":"Acknowledged"}}}},"/api/acknowledgments/{documentType}/{documentId}":{"get":{"tags":["Acknowledgments"],"summary":"List acknowledgments for a specific policy or SOP","security":[{"sessionCookie":[]}],"parameters":[{"name":"documentType","in":"path","required":true,"schema":{"type":"string","enum":["policy","sop"]}},{"name":"documentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Acknowledgment list"}}}},"/api/acknowledgments/my":{"get":{"tags":["Acknowledgments"],"summary":"Get the current user's acknowledgment history","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"My acknowledgments"}}}},"/api/acknowledgments/matrix":{"get":{"tags":["Acknowledgments"],"summary":"Get acknowledgment compliance matrix","security":[{"sessionCookie":[]}],"parameters":[{"name":"locationId","in":"query","schema":{"type":"string"}},{"name":"documentType","in":"query","schema":{"type":"string","enum":["policy","sop"]}}],"responses":{"200":{"description":"Compliance matrix"}}}},"/api/acknowledgments/token/{token}":{"get":{"tags":["Acknowledgments"],"summary":"View a document via acknowledgment token (public)","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Document details for acknowledgment"},"404":{"description":"Token not found or expired"}}},"post":{"tags":["Acknowledgments"],"summary":"Submit acknowledgment via token (public)","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"signature":{"type":"string"}}}}}},"responses":{"200":{"description":"Acknowledged"},"410":{"description":"Token already used"}}}},"/api/resources":{"get":{"tags":["Resources"],"summary":"List resources in the resource library","security":[{"sessionCookie":[]}],"parameters":[{"name":"type","in":"query","schema":{"type":"string","enum":["video_link","document","external_link"]}},{"name":"search","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Resources","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Resource"}}}}}}},"post":{"tags":["Resources"],"summary":"Create a resource (Admin only)","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title","type"],"properties":{"title":{"type":"string"},"type":{"type":"string","enum":["video_link","document","external_link"]},"url":{"type":"string"},"description":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"201":{"description":"Resource created"}}}},"/api/resources/{id}":{"get":{"tags":["Resources"],"summary":"Get a resource by ID","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Resource"}}}},"404":{"description":"Not found"}}},"patch":{"tags":["Resources"],"summary":"Update a resource (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string"},"url":{"type":"string"},"description":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Resources"],"summary":"Delete a resource (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}},"/api/resources/{id}/assign":{"post":{"tags":["Resources"],"summary":"Assign a resource to a location (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["locationId"],"properties":{"locationId":{"type":"string"}}}}}},"responses":{"200":{"description":"Assigned"}}}},"/api/law-events":{"post":{"tags":["Law Events"],"summary":"Create a law event","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"jurisdiction":{"type":"string"},"effectiveDate":{"type":"string","format":"date"}}}}}},"responses":{"201":{"description":"Law event created"}}}},"/api/law-events/{id}/locations":{"get":{"tags":["Law Events"],"summary":"Get locations associated with a law event","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Associated locations"}}}},"/api/law-events/{id}/associate-locations":{"post":{"tags":["Law Events"],"summary":"Associate locations with a law event","security":[{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"locationIds":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Locations associated"}}}},"/api/compliance-checks":{"get":{"tags":["Compliance"],"summary":"List compliance checks","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Compliance checks"}}}},"/api/monitors":{"get":{"tags":["Compliance"],"summary":"List compliance monitors","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Monitors"}}}},"/api/audit-logs":{"get":{"tags":["Audit Logs"],"summary":"List audit log entries (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","schema":{"type":"integer","default":50,"maximum":200}},{"name":"resourceType","in":"query","schema":{"type":"string"}},{"name":"userId","in":"query","schema":{"type":"string"}},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Audit logs","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AuditLog"}},"total":{"type":"integer"},"page":{"type":"integer"}}}}}}}}},"/api/reports":{"get":{"tags":["Reports"],"summary":"List saved reports","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Reports list"}}}},"/api/dashboard":{"get":{"tags":["Reports"],"summary":"Get dashboard overview metrics","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Dashboard data"}}}},"/api/search":{"get":{"tags":["Search"],"summary":"Full-text search across policies, SOPs, locations, and more","security":[{"sessionCookie":[]}],"parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string"},"description":"Search query"},{"name":"type","in":"query","schema":{"type":"string","enum":["policy","sop","location","employee"]}}],"responses":{"200":{"description":"Search results"}}}},"/api/notifications":{"get":{"tags":["Notifications"],"summary":"List notifications for the active organization","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Notifications"}}}},"/api/user-notifications":{"get":{"tags":["Notifications"],"summary":"List the current user's personal notifications","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"User notifications"}}}},"/api/webhooks":{"get":{"tags":["Webhooks"],"summary":"List configured outbound webhooks (Admin only)","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Webhook configurations"}}},"post":{"tags":["Webhooks"],"summary":"Create an outbound webhook (Admin only)","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url","events"],"properties":{"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string"}},"description":{"type":"string"}}}}}},"responses":{"201":{"description":"Webhook created"}}}},"/api/external-apps/integrations":{"get":{"tags":["External Apps"],"summary":"List all third-party integrations","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Integrations","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"appType":{"type":"string"},"isActive":{"type":"boolean"},"lastSyncedAt":{"type":"string","format":"date-time","nullable":true}}}}}}}}}},"/api/smartshifts/admin/configure":{"post":{"tags":["SmartShifts"],"summary":"Create or update SmartShifts integration settings (Admin only)","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"integrationId":{"type":"string","description":"Omit to create; provide to update"},"name":{"type":"string"},"apiKey":{"type":"string","description":"SmartShifts API key (write-only)"},"apiSecret":{"type":"string","description":"SmartShifts API secret (write-only)"},"webhookSecret":{"type":"string","description":"Signing secret for inbound webhooks (write-only)"},"locationId":{"type":"string","description":"Filter employees by SmartShifts location ID"}}}}}},"responses":{"200":{"description":"Integration saved","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"rawApiKey":{"type":"string","description":"Returned only on creation — save it, it cannot be recovered"}}}}}}}}},"/api/smartshifts/admin/sync":{"post":{"tags":["SmartShifts"],"summary":"Manually sync employees from SmartShifts (Admin only). Also available as POST /api/smartshifts/sync.","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["integrationId"],"properties":{"integrationId":{"type":"string"}}}}}},"responses":{"200":{"description":"Sync result","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"added":{"type":"integer"},"updated":{"type":"integer"},"deactivated":{"type":"integer"}}}}}}}}},"/api/smartshifts/admin/employees":{"get":{"tags":["SmartShifts"],"summary":"List synced employees with ack counts (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"integrationId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Employees","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ExternalEmployee"}}}}}}}}}},"/api/smartshifts/admin/send-acknowledgements":{"post":{"tags":["SmartShifts"],"summary":"Generate token-based e-sign requests for all active SmartShifts employees (Admin only). Also available as POST /api/smartshifts/send-acknowledgements.","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["integrationId","documentType","documentId"],"properties":{"integrationId":{"type":"string"},"documentType":{"type":"string","enum":["policy","sop"]},"documentId":{"type":"string"}}}}}},"responses":{"200":{"description":"Created acknowledgment requests","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"documentTitle":{"type":"string"},"created":{"type":"array","items":{"type":"object","properties":{"employeeId":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"portalUrl":{"type":"string"}}}}}}}}}}}},"/api/smartshifts/admin/activity/{integrationId}":{"get":{"tags":["SmartShifts"],"summary":"Get activity log for a SmartShifts integration (Admin only)","security":[{"sessionCookie":[]}],"parameters":[{"name":"integrationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Activity log entries","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["sync","webhook","send"]},"status":{"type":"string","enum":["success","error"]},"message":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}}}}}}}}}}},"/api/smartshifts/webhooks/{integrationId}":{"post":{"tags":["SmartShifts"],"summary":"Receive inbound webhook from SmartShifts. Also available as POST /api/smartshifts/webhooks (integrationId in body or X-Integration-Id header).","parameters":[{"name":"integrationId","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-SmartShifts-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"HMAC-SHA256 signature over the raw request body"},{"name":"X-SmartShifts-Timestamp","in":"header","schema":{"type":"integer"},"description":"Unix epoch seconds — must be within ±5 minutes of server time"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"event":{"type":"string","description":"e.g. employee.created, employee.updated"},"employee":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"position":{"type":"string"},"department":{"type":"string"},"locationId":{"type":"string"},"status":{"type":"string"}}}}}}}},"responses":{"200":{"description":"Accepted"},"401":{"description":"Invalid signature, missing secret, or timestamp out of range"}}}},"/api/smartshifts/employees":{"get":{"tags":["SmartShifts"],"summary":"SmartShifts polling — list synced employees with match status","security":[{"apiKey":[]}],"responses":{"200":{"description":"Employee list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ExternalEmployee"}}}}}}},"401":{"description":"Invalid or missing API key"}}}},"/api/smartshifts/employees/{externalId}/pending":{"get":{"tags":["SmartShifts"],"summary":"SmartShifts polling — list pending acknowledgment requests for an employee","security":[{"apiKey":[]}],"parameters":[{"name":"externalId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Pending requests","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"requestId":{"type":"string"},"type":{"type":"string","enum":["policy","sop"]},"title":{"type":"string"},"portalUrl":{"type":"string"},"requestedAt":{"type":"string","format":"date-time"}}}}}}}}}}}},"/api/smartshifts/employees/{externalId}/resources":{"get":{"tags":["SmartShifts"],"summary":"SmartShifts polling — list policies, SOPs, and resources available to an employee","security":[{"apiKey":[]}],"parameters":[{"name":"externalId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Resources","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["policy","sop","link","file"]},"title":{"type":"string"},"url":{"type":"string","nullable":true},"updatedAt":{"type":"string","format":"date-time","nullable":true}}}}}}}}}}}},"/api/smartshifts/acknowledge/{token}":{"get":{"tags":["SmartShifts"],"summary":"View document for e-signing via deep-link token (public)","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Document details"},"404":{"description":"Token not found"},"410":{"description":"Token already used or document already acknowledged"}}},"post":{"tags":["SmartShifts"],"summary":"Submit e-signature via deep-link token (public)","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"signature":{"type":"string"}}}}}},"responses":{"200":{"description":"Acknowledged"},"410":{"description":"Token already used (race-safe)"}}}},"/api/v1/external/locations":{"get":{"tags":["External API v1"],"summary":"List locations (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"parameters":[{"name":"X-API-Key","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-Timestamp","in":"header","required":true,"schema":{"type":"integer"},"description":"Unix epoch milliseconds"},{"name":"X-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"HMAC-SHA256(apiSecret, 'GET\\n/path\\n<timestamp>\\n')"}],"responses":{"200":{"description":"Locations","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Location"}}}}},"401":{"description":"Unauthorized"}}},"post":{"tags":["External API v1"],"summary":"Create a location (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"address":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string"}}}}}},"responses":{"201":{"description":"Location created"}}}},"/api/v1/external/locations/{locationId}":{"get":{"tags":["External API v1"],"summary":"Get a location by ID (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"parameters":[{"name":"locationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Location"}}},"patch":{"tags":["External API v1"],"summary":"Update a location (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"parameters":[{"name":"locationId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["External API v1"],"summary":"Delete a location (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"parameters":[{"name":"locationId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}},"/api/v1/external/policies":{"get":{"tags":["External API v1"],"summary":"List policies (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"responses":{"200":{"description":"Policies"}}},"post":{"tags":["External API v1"],"summary":"Create a policy (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"content":{"type":"string"}}}}}},"responses":{"201":{"description":"Policy created"}}}},"/api/v1/external/sops":{"get":{"tags":["External API v1"],"summary":"List SOPs (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"responses":{"200":{"description":"SOPs"}}},"post":{"tags":["External API v1"],"summary":"Create a SOP (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"content":{"type":"string"}}}}}},"responses":{"201":{"description":"SOP created"}}}},"/api/v1/external/employees":{"get":{"tags":["External API v1"],"summary":"List portal employees (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"responses":{"200":{"description":"Employees"}}}},"/api/v1/external/modules":{"get":{"tags":["External API v1"],"summary":"List field modules / tabs (HMAC-SHA256 auth)","security":[{"hmacAuth":[]}],"responses":{"200":{"description":"Modules"}}}}}}