Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Compliance API Reference

Programmatic access to privacy and compliance features


Overview

The Compliance API allows you to programmatically manage data subject requests, consent records, and compliance scanning. Use this API to integrate privacy features into your applications or automate compliance workflows.

Base URL: https://your-server.com/api/compliance


Authentication

All API requests require authentication using a Bearer token:

Authorization: Bearer your-api-key

Get your API key from SettingsAPI KeysCreate New Key with compliance scope.


Endpoints

Data Subject Requests (DSR)

List All Requests

GET /api/compliance/dsr

Query Parameters:

ParameterTypeDescription
statusstringFilter by status: pending, processing, completed, rejected
typestringFilter by type: access, deletion, rectification, portability, objection
fromdateStart date (YYYY-MM-DD)
todateEnd date (YYYY-MM-DD)
limitnumberResults per page (default: 20, max: 100)
offsetnumberPagination offset

Example Request:

GET /api/compliance/dsr?status=pending&limit=10

Example Response:

{
  "total": 7,
  "limit": 10,
  "offset": 0,
  "requests": [
    {
      "id": "DSR-2025-0142",
      "type": "access",
      "status": "pending",
      "userId": "usr_abc123",
      "email": "john.doe@email.com",
      "submittedAt": "2025-05-13T10:30:00Z",
      "dueDate": "2025-05-28T10:30:00Z",
      "assignee": null
    },
    {
      "id": "DSR-2025-0141",
      "type": "deletion",
      "status": "processing",
      "userId": "usr_def456",
      "email": "sarah@company.com",
      "submittedAt": "2025-05-10T14:15:00Z",
      "dueDate": "2025-05-25T14:15:00Z",
      "assignee": "admin@company.com"
    }
  ]
}

Get Single Request

GET /api/compliance/dsr/{id}

Example Response:

{
  "id": "DSR-2025-0142",
  "type": "access",
  "status": "pending",
  "userId": "usr_abc123",
  "email": "john.doe@email.com",
  "name": "John Doe",
  "submittedAt": "2025-05-13T10:30:00Z",
  "dueDate": "2025-05-28T10:30:00Z",
  "assignee": null,
  "message": "I would like a copy of all my data",
  "verifiedAt": "2025-05-13T10:35:00Z",
  "dataFound": {
    "profile": true,
    "conversations": true,
    "consents": true,
    "activityLogs": true
  },
  "history": [
    {
      "action": "created",
      "timestamp": "2025-05-13T10:30:00Z",
      "actor": "system"
    },
    {
      "action": "verified",
      "timestamp": "2025-05-13T10:35:00Z",
      "actor": "system"
    }
  ]
}

Create Request

POST /api/compliance/dsr

Request Body:

FieldTypeRequiredDescription
typestringYesaccess, deletion, rectification, portability, objection
emailstringYesUser’s email address
userIdstringNoUser ID if known
messagestringNoUser’s message/reason
skipVerificationbooleanNoSkip email verification (default: false)

Example Request:

POST /api/compliance/dsr
Content-Type: application/json

{
  "type": "access",
  "email": "john.doe@email.com",
  "message": "Please provide all my personal data"
}

Example Response:

{
  "id": "DSR-2025-0143",
  "type": "access",
  "status": "pending_verification",
  "email": "john.doe@email.com",
  "submittedAt": "2025-05-15T14:00:00Z",
  "dueDate": "2025-05-30T14:00:00Z",
  "verificationSent": true
}

Update Request Status

PATCH /api/compliance/dsr/{id}

Request Body:

FieldTypeDescription
statusstringprocessing, completed, rejected
assigneestringEmail of person handling request
notesstringInternal notes
rejectionReasonstringRequired if status is rejected

Example Request:

PATCH /api/compliance/dsr/DSR-2025-0142
Content-Type: application/json

{
  "status": "processing",
  "assignee": "admin@company.com"
}

Complete Request (with data package)

POST /api/compliance/dsr/{id}/complete

Request Body:

FieldTypeDescription
notifyUserbooleanSend completion email (default: true)
dataPackageUrlstringURL to downloadable data (for access/portability)
expiresAtdatetimeWhen download link expires

Example Request:

POST /api/compliance/dsr/DSR-2025-0142/complete
Content-Type: application/json

{
  "notifyUser": true,
  "dataPackageUrl": "https://secure.company.com/data/abc123.zip",
  "expiresAt": "2025-06-15T00:00:00Z"
}

GET /api/compliance/consent/{userId}

Example Response:

{
  "userId": "usr_abc123",
  "email": "john.doe@email.com",
  "consents": [
    {
      "type": "terms_of_service",
      "status": "given",
      "version": "2.3",
      "timestamp": "2025-01-15T10:32:00Z",
      "method": "web_form",
      "ip": "192.168.1.100"
    },
    {
      "type": "marketing",
      "status": "given",
      "timestamp": "2025-01-15T10:32:00Z",
      "method": "web_form"
    },
    {
      "type": "analytics",
      "status": "withdrawn",
      "timestamp": "2025-03-22T15:15:00Z",
      "method": "preference_center"
    }
  ]
}

POST /api/compliance/consent

Request Body:

FieldTypeRequiredDescription
userIdstringYesUser identifier
emailstringYesUser’s email
typestringYesConsent type (e.g., marketing, analytics)
statusstringYesgiven or withdrawn
methodstringNoHow consent was collected
ipstringNoUser’s IP address
userAgentstringNoUser’s browser

Example Request:

POST /api/compliance/consent
Content-Type: application/json

{
  "userId": "usr_abc123",
  "email": "john.doe@email.com",
  "type": "marketing",
  "status": "given",
  "method": "chatbot",
  "ip": "192.168.1.100"
}

Example Response:

{
  "success": true,
  "consentId": "con_xyz789",
  "userId": "usr_abc123",
  "type": "marketing",
  "status": "given",
  "timestamp": "2025-05-15T14:30:00Z"
}

DELETE /api/compliance/consent/{userId}/{type}

Example Request:

DELETE /api/compliance/consent/usr_abc123/marketing

Example Response:

{
  "success": true,
  "userId": "usr_abc123",
  "type": "marketing",
  "status": "withdrawn",
  "timestamp": "2025-05-15T14:35:00Z"
}

GET /api/compliance/consent-types

Example Response:

{
  "consentTypes": [
    {
      "id": "terms_of_service",
      "name": "Terms of Service",
      "required": true,
      "description": "Agreement to terms and conditions",
      "currentVersion": "2.3"
    },
    {
      "id": "marketing",
      "name": "Marketing Communications",
      "required": false,
      "description": "Receive promotional emails and offers"
    },
    {
      "id": "analytics",
      "name": "Analytics & Improvement",
      "required": false,
      "description": "Help us improve by analyzing usage patterns"
    }
  ]
}

Compliance Scanning

Start a Scan

POST /api/compliance/scan

Request Body:

FieldTypeDescription
typestringquick, full, or custom
targetsarrayFor custom: ["bots", "kb", "users", "logs"]
botIdstringScan specific bot only

Example Request:

POST /api/compliance/scan
Content-Type: application/json

{
  "type": "full",
  "targets": ["bots", "kb", "users", "logs"]
}

Example Response:

{
  "scanId": "scan_20250515_001",
  "status": "running",
  "type": "full",
  "startedAt": "2025-05-15T14:45:00Z",
  "estimatedDuration": "30 minutes"
}

Get Scan Status

GET /api/compliance/scan/{scanId}

Example Response (In Progress):

{
  "scanId": "scan_20250515_001",
  "status": "running",
  "progress": 45,
  "currentStep": "Scanning conversation logs",
  "startedAt": "2025-05-15T14:45:00Z"
}

Example Response (Complete):

{
  "scanId": "scan_20250515_001",
  "status": "completed",
  "progress": 100,
  "startedAt": "2025-05-15T14:45:00Z",
  "completedAt": "2025-05-15T15:12:00Z",
  "summary": {
    "totalChecks": 148,
    "passed": 145,
    "warnings": 2,
    "critical": 1
  },
  "issues": [
    {
      "severity": "critical",
      "type": "unencrypted_pii",
      "description": "Unencrypted PII found in conversation logs",
      "location": "support-bot/logs/2025-05-10",
      "affectedRecords": 23,
      "recommendation": "Enable automatic PII redaction"
    },
    {
      "severity": "warning",
      "type": "consent_expiring",
      "description": "Consent records older than 2 years",
      "affectedUsers": 12,
      "recommendation": "Send consent renewal requests"
    }
  ]
}

Get Latest Scan Results

GET /api/compliance/scan/latest

Returns the most recent completed scan results.


Reports

Generate Compliance Report

POST /api/compliance/report

Request Body:

FieldTypeDescription
typestringsummary, detailed, audit
periodstringlast_30_days, last_90_days, year, custom
fromdateStart date for custom period
todateEnd date for custom period
formatstringjson, pdf, csv

Example Request:

POST /api/compliance/report
Content-Type: application/json

{
  "type": "summary",
  "period": "last_30_days",
  "format": "json"
}

Example Response:

{
  "reportId": "rpt_20250515_001",
  "generatedAt": "2025-05-15T15:00:00Z",
  "period": {
    "from": "2025-04-15",
    "to": "2025-05-15"
  },
  "summary": {
    "overallScore": 92,
    "dsrRequests": {
      "received": 15,
      "completed": 12,
      "pending": 3,
      "averageResponseDays": 8.5
    },
    "consentRate": 94.2,
    "dataBreaches": 0,
    "scansPerformed": 4,
    "issuesFound": 7,
    "issuesResolved": 5
  }
}

Download Report

GET /api/compliance/report/{reportId}/download

Returns the report file in the requested format.


Data Deletion

Delete User Data

DELETE /api/compliance/user/{userId}/data

Query Parameters:

ParameterTypeDescription
scopestringall, conversations, profile, analytics
confirmbooleanMust be true to execute

Example Request:

DELETE /api/compliance/user/usr_abc123/data?scope=all&confirm=true

Example Response:

{
  "success": true,
  "userId": "usr_abc123",
  "deletedAt": "2025-05-15T15:30:00Z",
  "scope": "all",
  "itemsDeleted": {
    "profile": 1,
    "conversations": 45,
    "consents": 3,
    "activityLogs": 234
  },
  "retainedForLegal": {
    "auditLogs": 15
  }
}

Error Responses

All errors follow this format:

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human readable message",
    "details": {}
  }
}

Common Error Codes:

CodeHTTP StatusDescription
UNAUTHORIZED401Invalid or missing API key
FORBIDDEN403API key lacks required scope
NOT_FOUND404Resource not found
VALIDATION_ERROR400Invalid request parameters
RATE_LIMITED429Too many requests
INTERNAL_ERROR500Server error

Rate Limits

EndpointLimit
All endpoints100 requests/minute
Scan endpoints5 requests/hour
Report generation10 requests/hour

Rate limit headers are included in responses:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1621234567

Webhooks

Configure webhooks to receive real-time notifications.

Available Events:

EventDescription
dsr.createdNew DSR submitted
dsr.completedDSR marked complete
dsr.due_soonDSR due within 3 days
consent.changedUser consent updated
scan.completedCompliance scan finished
issue.criticalCritical issue detected

Webhook Payload Example:

POST https://your-server.com/webhook
Content-Type: application/json
X-Signature: sha256=...

{
  "event": "dsr.created",
  "timestamp": "2025-05-15T14:00:00Z",
  "data": {
    "id": "DSR-2025-0143",
    "type": "access",
    "email": "user@example.com"
  }
}

See Also