PiperPrivacy exposes a REST API for managing privacy collections, thresholds, and impact assessments. All endpoints are accessible via the WordPress REST API with the namespace piper-privacy/v1.
The API uses WordPress authentication methods:
- Application Passwords (recommended)
- JWT Authentication (if configured)
- Cookie Authentication (for admin interface)
# Using Application Password
curl -X GET \
https://your-site.com/wp-json/piper-privacy/v1/collections \
-H 'Authorization: Basic base64_encoded_credentials'GET /wp-json/piper-privacy/v1/collectionsParameters:
page(int): Page numberper_page(int): Items per pagestatus(string): Collection statusdepartment(int): Department ID
Response:
{
"collections": [
{
"id": 123,
"title": "Customer Data Collection",
"status": "active",
"department": "Sales",
"created_at": "2025-01-19T00:00:00Z",
"updated_at": "2025-01-19T00:00:00Z"
}
],
"total": 50,
"pages": 5
}GET /wp-json/piper-privacy/v1/collections/{id}Response:
{
"id": 123,
"title": "Customer Data Collection",
"description": "Collection of customer data for CRM",
"status": "active",
"department": "Sales",
"data_categories": ["personal", "contact"],
"retention_period": "12 months",
"legal_basis": "consent",
"created_at": "2025-01-19T00:00:00Z",
"updated_at": "2025-01-19T00:00:00Z"
}POST /wp-json/piper-privacy/v1/collectionsRequest Body:
{
"title": "New Data Collection",
"description": "Description of collection",
"department": "Marketing",
"data_categories": ["email", "preferences"],
"retention_period": "24 months",
"legal_basis": "legitimate_interest"
}POST /wp-json/piper-privacy/v1/collectionsRequest body:
{
"title": "Customer Survey Data",
"description": "Collection of customer feedback data",
"dataTypes": ["personal", "contact"],
"retention": {
"period": 12,
"unit": "months"
}
}PUT /wp-json/piper-privacy/v1/collections/{id}DELETE /wp-json/piper-privacy/v1/collections/{id}GET /wp-json/piper-privacy/v1/thresholdsParameters:
collection_id(int): Related collection IDstatus(string): Assessment statusrisk_level(string): Risk level
POST /wp-json/piper-privacy/v1/thresholdsRequest Body:
{
"collection_id": 123,
"assessment_type": "initial",
"risk_factors": {
"data_volume": "high",
"sensitivity": "medium",
"processing_type": "automated"
}
}POST /wp-json/piper-privacy/v1/incidentsRequest body:
{
"type": "data_breach",
"severity": "high",
"description": "Unauthorized access detected",
"affectedData": ["customer_records"],
"detectionTime": "2025-02-05T20:30:00Z"
}PUT /wp-json/piper-privacy/v1/incidents/{id}GET /wp-json/piper-privacy/v1/incidents/{id}/statusPOST /wp-json/piper-privacy/v1/reviewsRequest body:
{
"type": "periodic",
"target": "data_collection",
"targetId": "123",
"scheduledDate": "2025-03-01T00:00:00Z",
"assignee": "privacy_officer"
}GET /wp-json/piper-privacy/v1/reviews/{id}GET /wp-json/piper-privacy/v1/impact-assessmentsPOST /wp-json/piper-privacy/v1/impact-assessmentsRequest Body:
{
"threshold_id": 456,
"collection_id": 123,
"assessment_details": {
"risks": [],
"mitigations": [],
"recommendations": []
}
}collection.createdcollection.updatedcollection.deletedthreshold.completedimpact.requiredimpact.completed
{
"event": "collection.created",
"timestamp": "2025-01-19T00:00:00Z",
"data": {
"id": 123,
"type": "collection",
"attributes": {}
}
}{
"code": "error_code",
"message": "Human readable message",
"data": {
"status": 400,
"details": {}
}
}invalid_request: Malformed requestunauthorized: Authentication requiredforbidden: Insufficient permissionsnot_found: Resource not foundvalidation_failed: Invalid data
- Default: 50 requests per minute
- Authenticated: 100 requests per minute
- Response Headers:
X-RateLimit-LimitX-RateLimit-RemainingX-RateLimit-Reset
The API uses semantic versioning (v1, v2, etc.). Breaking changes will result in a new version number.
https://your-site.com/wp-json/piper-privacy-sandbox/v1/# Test Application Password
Username: test_api_user
Password: test_api_password- Report issues on GitHub
- API status: Status Page
- Contact: api-support@your-domain.com
// Get collection data
pp_get_collection($id);
pp_get_collections($args);
pp_create_collection($data);
pp_update_collection($id, $data);
pp_delete_collection($id);
// Validate collection
pp_validate_collection($data);// Manage assessments
pp_get_assessment($id);
pp_get_assessments($args);
pp_create_assessment($data);
pp_update_assessment($id, $data);
pp_delete_assessment($id);
// Validate assessment
pp_validate_assessment($data);// Manage consent
pp_get_consent($id);
pp_get_consents($args);
pp_create_consent($data);
pp_update_consent($id, $data);
pp_delete_consent($id);
// Validate consent
pp_validate_consent($data);// Manage breaches
pp_get_breach($id);
pp_get_breaches($args);
pp_create_breach($data);
pp_update_breach($id, $data);
pp_delete_breach($id);
// Validate breach
pp_validate_breach($data);// Track compliance
pp_get_compliance($id);
pp_get_compliance_records($args);
pp_create_compliance_record($data);
pp_update_compliance_record($id, $data);
pp_delete_compliance_record($id);
// Validate compliance
pp_validate_compliance($data);// Collection lifecycle
do_action('pp_before_collection_save', $data);
do_action('pp_after_collection_save', $id, $data);
do_action('pp_before_collection_delete', $id);
do_action('pp_after_collection_delete', $id);
// Impact assessment
do_action('pp_before_assessment_save', $data);
do_action('pp_after_assessment_save', $id, $data);
do_action('pp_before_assessment_delete', $id);
do_action('pp_after_assessment_delete', $id);
// Consent management
do_action('pp_before_consent_save', $data);
do_action('pp_after_consent_save', $id, $data);
do_action('pp_before_consent_delete', $id);
do_action('pp_after_consent_delete', $id);
// Breach notification
do_action('pp_before_breach_save', $data);
do_action('pp_after_breach_save', $id, $data);
do_action('pp_before_breach_delete', $id);
do_action('pp_after_breach_delete', $id);
// Compliance tracking
do_action('pp_before_compliance_save', $data);
do_action('pp_after_compliance_save', $id, $data);
do_action('pp_before_compliance_delete', $id);
do_action('pp_after_compliance_delete', $id);// Collection management
apply_filters('pp_collection_data', $data, $id);
apply_filters('pp_collection_fields', $fields);
apply_filters('pp_collection_validation_rules', $rules);
// Impact assessment
apply_filters('pp_assessment_data', $data, $id);
apply_filters('pp_assessment_fields', $fields);
apply_filters('pp_assessment_validation_rules', $rules);
// Consent management
apply_filters('pp_consent_data', $data, $id);
apply_filters('pp_consent_fields', $fields);
apply_filters('pp_consent_validation_rules', $rules);
// Breach notification
apply_filters('pp_breach_data', $data, $id);
apply_filters('pp_breach_fields', $fields);
apply_filters('pp_breach_validation_rules', $rules);
// Compliance tracking
apply_filters('pp_compliance_data', $data, $id);
apply_filters('pp_compliance_fields', $fields);
apply_filters('pp_compliance_validation_rules', $rules);curl -X POST \
https://your-site.com/wp-json/piper-privacy/v1/collections \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"title": "Marketing Data",
"description": "Customer marketing preferences",
"dataTypes": ["contact", "preferences"]
}'curl -X POST \
https://your-site.com/wp-json/piper-privacy/v1/incidents \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"type": "unauthorized_access",
"severity": "medium",
"description": "Suspicious login attempts detected"
}'-
Authentication Errors
- Verify API key/token
- Check permissions
- Validate request headers
- Confirm user role
-
Rate Limiting
- Check current limits
- Monitor usage
- Handle 429 responses
- Implement backoff
-
Data Validation
- Review request format
- Check required fields
- Validate data types
- Handle validation errors
{
"code": "error_code",
"message": "Human readable message",
"data": {
"status": 400,
"details": "Additional error information"
}
}