Policies API Reference

Complete API reference for managing policy versions and documents.

Create Policy Version

POST /api/v1/policies

Request Body

Requestjson
{
  "policyType": "privacy_policy",
  "version": "1.0.0",
  "title": "Privacy Policy",
  "content": "Your complete policy content here...",
  "effectiveDate": "2024-01-01T00:00:00.000Z"
}

Policy Types

privacy_policy

Privacy and data protection policies

terms_of_service

Terms and conditions of service

cookie_policy

Cookie usage and consent policies

marketing_consent

Marketing and communication preferences

data_processing

Data processing agreements

custom

Custom policy types

Response

Response (201 Created)json
{
  "success": true,
  "data": {
    "id": "pol_abc123def456",
    "policyType": "privacy_policy",
    "version": "1.0.0",
    "title": "Privacy Policy",
    "content": "Your complete policy content here...",
    "contentHash": "a1b2c3d4e5f6...",
    "effectiveDate": "2024-01-01T00:00:00Z",
    "isActive": true,
    "createdAt": "2024-01-15T10:30:00Z"
  }
}

List Policies

GET /api/v1/policies

Query Parameters

ParameterTypeDescription
policyTypestringFilter by policy type
isActivebooleanFilter by active status
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20)
Response (200 OK)json
{
  "success": true,
  "data": [
    {
      "id": "pol_abc123def456",
      "policyType": "privacy_policy",
      "version": "1.0.0",
      "title": "Privacy Policy",
      "contentHash": "a1b2c3d4e5f6...",
      "effectiveDate": "2024-01-01T00:00:00Z",
      "isActive": true,
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 1,
    "pages": 1
  }
}

Get Policy by ID

GET /api/v1/policies/:id

Response (200 OK)json
{
  "success": true,
  "data": {
    "id": "pol_abc123def456",
    "policyType": "privacy_policy",
    "version": "1.0.0",
    "title": "Privacy Policy",
    "content": "Complete policy content...",
    "contentHash": "a1b2c3d4e5f6...",
    "effectiveDate": "2024-01-01T00:00:00Z",
    "isActive": true,
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:30:00Z"
  }
}

Get Active Policy by Type

GET /api/v1/policies/active/:policyType

Retrieves the currently active policy version for a specific policy type.

Examplebash
curl https://api.consentproof.com/api/v1/policies/active/privacy_policy \
  -H "X-API-Key: your_api_key"
Response (200 OK)json
{
  "success": true,
  "data": {
    "id": "pol_abc123def456",
    "policyType": "privacy_policy",
    "version": "2.0.0",
    "title": "Privacy Policy",
    "content": "Complete policy content...",
    "contentHash": "a1b2c3d4e5f6...",
    "effectiveDate": "2024-06-01T00:00:00Z",
    "isActive": true,
    "createdAt": "2024-06-01T10:30:00Z"
  }
}

Update Policy

PUT /api/v1/policies/:id

Version Management

To update policy content, create a new version instead. The PATCH endpoint is for updating metadata (e.g., marking as inactive).

Requestjson
{
  "isActive": false
}

Delete Policy

DELETE /api/v1/policies/:id

Important Warning

Deleting a policy that has associated consent records is not recommended. Consider marking it as inactive instead.

Response (200 OK)json
{
  "success": true,
  "data": {
    "message": "Policy deleted successfully"
  }
}

Related Documentation