Overview
Initiates a compliance scan by executing policy rules against uploaded financial data. The scan runs synchronously and processes up to 50,000 records, identifying violations and calculating a compliance score.
Request Body
The ID of the compliance policy containing the rules to execute
The ID of the uploaded data file to scan. Must reference a valid upload from /api/upload
The ID of the column mapping configuration. Must be confirmed via /api/mapping/confirm before scanning
Optional audit identifier for grouping related scans
Optional human-readable name for the audit
Response
Unique identifier for the created scan. Use this to poll scan status via /api/scan/{id}
Initial scan status. Always returns "running" even though the scan completes synchronously
Example Request
{
"policy_id": "550e8400-e29b-41d4-a716-446655440000",
"upload_id": "123e4567-e89b-12d3-a456-426614174000",
"mapping_id": "789e0123-e45b-67c8-d901-234567890123",
"audit_name": "Q1 2024 Compliance Audit"
}
Example Response
{
"scan_id": "abc12345-def6-7890-ghij-klmnopqrstuv",
"status": "running"
}
Error Responses
400 Bad Request
{
"error": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": [
{
"path": ["policy_id"],
"message": "Required"
}
]
}
404 Not Found - Missing Mapping
{
"error": "NOT_FOUND",
"message": "Mapping not found. Confirm mapping first."
}
404 Not Found - Missing Upload
{
"error": "NOT_FOUND",
"message": "Upload not found. Upload data first."
}
404 Not Found - No Rules
{
"error": "NOT_FOUND",
"message": "No rules found for this policy."
}
Scan Process
The endpoint performs the following operations:
- Validates Request - Ensures all required parameters are present and valid
- Retrieves Resources - Fetches mapping configuration, uploaded data, and active policy rules
- Creates Scan Record - Initializes a scan record in the database with
status: "running"
- Executes Rules - Runs all active rules against the data using the RuleExecutor engine
- Calculates Score - Computes compliance score based on violations and severity
- Persists Violations - Saves detected violations in batches (2,500 per batch, 5 concurrent batches)
- Updates Status - Marks scan as
completed with final metrics
- Links PII Findings - Associates any PII findings from the upload with this scan
- Processes up to 50,000 records per scan
- Typical execution time: < 5 seconds for large datasets
- Uses concurrent batching for violation persistence (5 parallel batches)