Skip to content

Audit Logs API

The Audit Logs API provides access to the complete audit trail of all actions in Cohera. Every create, update, delete, and access event is recorded for compliance with 21 CFR Part 11 and EU GMP Annex 11 requirements.

{
"id": "log_abc123def456",
"timestamp": "2024-01-20T14:30:45.123Z",
"action": "update",
"entity_type": "supplier",
"entity_id": "ent_supplier_789",
"entity_name": "Acme Chemicals GmbH",
"user": {
"id": "user_xyz123",
"email": "j.smith@company.com",
"name": "John Smith",
"role": "quality_manager"
},
"client": {
"ip_address": "192.168.1.100",
"user_agent": "Mozilla/5.0...",
"api_key_id": "key_abc123"
},
"changes": {
"attributes.qualification_status": {
"from": "pending",
"to": "qualified"
},
"attributes.qualification_date": {
"from": null,
"to": "2024-01-20"
}
},
"metadata": {
"reason": "Completed qualification audit",
"workflow_state": "qualified",
"request_id": "req_xyz789"
},
"signature": {
"required": true,
"signed": true,
"signature_id": "sig_abc123",
"meaning": "I approve this qualification status change"
}
}
ActionDescription
createEntity created
readEntity accessed (configurable)
updateEntity modified
deleteEntity deleted
restoreEntity restored from deletion
transitionWorkflow state transition
approveApproval submitted
rejectApproval rejected
signElectronic signature applied
loginUser login
logoutUser logout
exportData exported
GET /v1/audit-logs
ParameterTypeDescription
entity_typestringFilter by entity type
entity_idstringFilter by specific entity
actionstringFilter by action type
user_idstringFilter by user
fromdatetimeStart of time range
todatetimeEnd of time range
has_signaturebooleanOnly signed actions
pageintegerPage number
per_pageintegerItems per page (max 100)
Terminal window
curl -X GET "https://api.cohera.io/v1/audit-logs?entity_type=supplier&action=update&from=2024-01-01T00:00:00Z&to=2024-01-31T23:59:59Z" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": [
{
"id": "log_abc123",
"timestamp": "2024-01-20T14:30:45.123Z",
"action": "update",
"entity_type": "supplier",
"entity_id": "ent_supplier_789",
"entity_name": "Acme Chemicals GmbH",
"user": {
"id": "user_xyz123",
"name": "John Smith"
},
"changes": {
"attributes.qualification_status": {
"from": "pending",
"to": "qualified"
}
}
}
],
"meta": {
"total": 156,
"page": 1,
"per_page": 50
}
}

Get the complete audit history for a specific entity.

GET /v1/audit-logs/entity/{entity_id}
Terminal window
curl -X GET "https://api.cohera.io/v1/audit-logs/entity/ent_supplier_789" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": {
"entity_id": "ent_supplier_789",
"entity_type": "supplier",
"entity_name": "Acme Chemicals GmbH",
"created_at": "2024-01-10T09:00:00Z",
"created_by": "user_intake_001",
"current_version": 5,
"history": [
{
"version": 5,
"timestamp": "2024-01-20T14:30:45Z",
"action": "update",
"user": {"id": "user_xyz123", "name": "John Smith"},
"changes": {
"attributes.qualification_status": {"from": "pending", "to": "qualified"}
},
"signature": {"signed": true, "signature_id": "sig_abc123"}
},
{
"version": 4,
"timestamp": "2024-01-18T11:00:00Z",
"action": "update",
"user": {"id": "user_abc456", "name": "Jane Doe"},
"changes": {
"attributes.risk_level": {"from": "high", "to": "medium"}
}
}
]
}
}

Get all actions performed by a specific user.

GET /v1/audit-logs/user/{user_id}
ParameterTypeDescription
fromdatetimeStart of time range
todatetimeEnd of time range
actionstringFilter by action type
GET /v1/audit-logs/retention
{
"data": {
"policy_id": "ret_default",
"name": "Default Retention Policy",
"retention_period_years": 15,
"applies_to": ["all"],
"archive_after_years": 2,
"archive_storage": "s3_glacier",
"deletion_policy": "manual_with_approval",
"exceptions": [
{
"entity_types": ["certificate", "quality_event"],
"retention_period_years": 25,
"reason": "Regulatory requirement for batch records"
}
]
}
}

Export audit logs for regulatory submissions or external archival.

POST /v1/audit-logs/export
FieldTypeRequiredDescription
formatstringYesExport format: csv, json, pdf
fromdatetimeYesStart of time range
todatetimeYesEnd of time range
entity_typesarrayNoFilter by entity types
actionsarrayNoFilter by action types
include_signaturesbooleanNoInclude signature details
include_raw_databooleanNoInclude before/after data snapshots
Terminal window
curl -X POST "https://api.cohera.io/v1/audit-logs/export" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"format": "pdf",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-31T23:59:59Z",
"entity_types": ["supplier", "certificate"],
"include_signatures": true
}'
{
"data": {
"job_id": "export_abc123",
"status": "processing",
"format": "pdf",
"parameters": {
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-31T23:59:59Z",
"entity_types": ["supplier", "certificate"]
},
"estimated_records": 1250,
"created_at": "2024-02-01T10:00:00Z",
"download_url": null
}
}
GET /v1/audit-logs/export/{job_id}
{
"data": {
"job_id": "export_abc123",
"status": "completed",
"format": "pdf",
"records_exported": 1247,
"file_size_bytes": 5242880,
"created_at": "2024-02-01T10:00:00Z",
"completed_at": "2024-02-01T10:05:30Z",
"download_url": "https://api.cohera.io/v1/audit-logs/export/export_abc123/download",
"expires_at": "2024-02-08T10:05:30Z"
}
}
GET /v1/audit-logs/export/{job_id}/download

Returns the export file with appropriate content headers.

POST /v1/audit-logs/reports/21cfr11
{
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-31T23:59:59Z",
"include_sections": [
"electronic_signatures",
"audit_trail_completeness",
"access_controls",
"system_validations"
]
}
{
"data": {
"report_id": "rpt_compliance_abc123",
"report_type": "21cfr11",
"period": {
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-31T23:59:59Z"
},
"summary": {
"overall_compliance": "compliant",
"findings": 0,
"observations": 2
},
"sections": {
"electronic_signatures": {
"status": "compliant",
"total_signatures": 145,
"valid_signatures": 145,
"details": "All electronic signatures contain required elements"
},
"audit_trail_completeness": {
"status": "compliant",
"total_records": 12500,
"complete_records": 12500,
"details": "All records contain timestamp, user, and change details"
},
"access_controls": {
"status": "compliant",
"observations": [
"2 users have not completed annual security training"
]
}
},
"generated_at": "2024-02-01T10:30:00Z",
"download_url": "https://api.cohera.io/v1/audit-logs/reports/rpt_compliance_abc123/download"
}
}

For real-time monitoring, subscribe to the audit log stream via webhooks.

POST /v1/webhooks
{
"url": "https://your-server.com/webhooks/audit",
"events": ["audit.create", "audit.signature"],
"filters": {
"entity_types": ["certificate", "quality_event"],
"actions": ["create", "update", "delete", "sign"]
}
}
{
"event": "audit.create",
"timestamp": "2024-01-20T14:30:45.123Z",
"data": {
"id": "log_abc123",
"action": "update",
"entity_type": "certificate",
"entity_id": "cert_xyz789",
"user": {
"id": "user_abc123",
"name": "John Smith"
},
"changes": {
"status": {"from": "pending", "to": "valid"}
}
}
}