Skip to main content

Create an Audit Log

Manually records an audit event. While most audit logs are created automatically by the system, this endpoint allows you to record custom events for compliance or integration purposes.
POST /v1/audit/logs

Request Body

ParameterTypeRequiredDescription
dockIdstringRequiredThe dock this event belongs to
entityTypestringRequiredThe type of entity (e.g., artifact, recipient, policy, group)
entityIdstringRequiredThe entity ID this event relates to
actionstringRequiredThe action performed: create, update, or delete
actorstringOptionalThe user or system that performed the action
changesobjectOptionalObject with before and after fields describing what changed
metadataobjectOptionalAdditional context for the event
ipAddressstringOptionalIP address of the actor
userAgentstringOptionalUser agent string of the actor

Example Request

curl -X POST https://api.docyard.io/v1/audit/logs \
  -H "Authorization: Bearer dk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "dockId": "dock_01HQ3K...",
    "entityType": "artifact",
    "entityId": "art_01HQ3M...",
    "action": "update",
    "actor": "integration-service",
    "changes": {
      "before": { "metadata": { "status": "pending" } },
      "after": { "metadata": { "status": "reviewed" } }
    },
    "metadata": {
      "source": "external-review-system",
      "reviewId": "rev-4821"
    },
    "ipAddress": "10.0.1.50",
    "userAgent": "ReviewBot/2.0"
  }'

Response

{
  "id": "aud_01HQ6C...",
  "dockId": "dock_01HQ3K...",
  "entityType": "artifact",
  "entityId": "art_01HQ3M...",
  "action": "update",
  "actor": "integration-service",
  "changes": {
    "before": { "metadata": { "status": "pending" } },
    "after": { "metadata": { "status": "reviewed" } }
  },
  "metadata": {
    "source": "external-review-system",
    "reviewId": "rev-4821"
  },
  "ipAddress": "10.0.1.50",
  "userAgent": "ReviewBot/2.0",
  "createdAt": "2025-01-22T14:30:00.000Z"
}

Error Handling

StatusCondition
400Required fields (dockId, entityType, entityId, action) are missing
400action is not one of create, update, or delete
401Missing or invalid API key
404Dock not found
Custom audit logs are stored alongside system-generated logs and appear in all audit queries. Use the metadata field to distinguish custom events from automatic ones.