{"openapi":"3.0.3","info":{"title":"QEHS Platform API","version":"1.0.0","description":"REST API for the QEHS composable quality, environment, health & safety platform. Authenticate with a Bearer token (API key) in the Authorization header."},"servers":[{"url":"/","description":"Current host"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Bearer token: `Authorization: Bearer qehs_<key>`"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","description":"Machine-readable error code"},"message":{"type":"string","description":"Human-readable error message"}}},"meta":{"type":"object","properties":{"requestId":{"type":"string","format":"uuid"}}}}},"Record":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tenantId":{"type":"string","format":"uuid"},"moduleInstanceId":{"type":"string","format":"uuid"},"definitionVersion":{"type":"integer"},"dataJson":{"type":"object","additionalProperties":true},"workflowState":{"type":"string","nullable":true},"displayCode":{"type":"string","nullable":true},"createdBy":{"type":"string","format":"uuid","nullable":true},"updatedBy":{"type":"string","format":"uuid","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"RecordList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Record"}},"meta":{"type":"object","properties":{"requestId":{"type":"string","format":"uuid"},"total":{"type":"integer"},"limit":{"type":"integer"},"offset":{"type":"integer"}}}}},"RecordResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Record"},"meta":{"type":"object","properties":{"requestId":{"type":"string","format":"uuid"}}}}},"TransitionRequest":{"type":"object","properties":{"state":{"type":"string","description":"Target workflow state"}},"required":["state"]}}},"paths":{"/api/v1/records":{"get":{"summary":"List records","operationId":"listRecords","tags":["Records"],"security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"module","in":"query","required":true,"description":"Module key to filter records by","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum records to return (1-200)","schema":{"type":"integer","default":25,"minimum":1,"maximum":200}},{"name":"offset","in":"query","required":false,"description":"Number of records to skip","schema":{"type":"integer","default":0,"minimum":0}},{"name":"state","in":"query","required":false,"description":"Filter by workflow state","schema":{"type":"string"}}],"responses":{"200":{"description":"Paginated list of records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordList"}}}},"400":{"description":"Bad request — missing required parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized — invalid or missing API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden — API key lacks required permission","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Module not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a record","operationId":"createRecord","tags":["Records"],"security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"module","in":"query","required":true,"description":"Module key to create the record in","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"Created record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"400":{"description":"Bad request — invalid JSON","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/records/{recordId}":{"get":{"summary":"Get a record by ID","operationId":"getRecord","tags":["Records"],"security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"recordId","in":"path","required":true,"description":"Record UUID","schema":{"type":"string"}}],"responses":{"200":{"description":"Record detail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"summary":"Update a record","operationId":"updateRecord","tags":["Records"],"security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"recordId","in":"path","required":true,"description":"Record UUID","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"Updated record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a record","operationId":"deleteRecord","tags":["Records"],"security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"recordId","in":"path","required":true,"description":"Record UUID","schema":{"type":"string"}}],"responses":{"200":{"description":"Record deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/records/{recordId}/transition":{"post":{"summary":"Transition a record to a new workflow state","operationId":"transitionRecord","tags":["Workflow"],"security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"recordId","in":"path","required":true,"description":"Record UUID","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransitionRequest"}}}},"responses":{"200":{"description":"Record after transition","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecordResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Invalid transition","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}