Drifts
Query, analyze, and remediate infrastructure drifts detected by scans.
Base path: /api/drifts
Authentication: Bearer token required on all routes
List All Drifts
GET /api/drifts/
Scope: drifts:read
List all drifts across all repositories for the authenticated user.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number (default: 1) |
limit | number | No | Items per page (default: 20) |
status | string | No | Filter by status (detected, acknowledged, resolved, ignored) |
severity | string | No | Filter by severity (critical, high, medium, low) |
Response
{
"success": true,
"data": [
{
"_id": "drift1",
"resourceType": "aws_security_group",
"resourceAddress": "module.vpc.aws_security_group.main",
"severity": "high",
"status": "detected",
"changeType": "changed",
"scan": "scan123",
"repositoryConfig": "abc123",
"detectedAt": "2025-06-15T10:32:00.000Z"
}
]
}Example
curl -H "Authorization: Bearer TOKEN" \
"https://api.controlinfra.com/api/drifts/?status=detected&severity=high"Advanced Query
GET /api/drifts/query
Scope: drifts:read
Advanced drift search with filters, facets, and full-text search.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | No | Free-text search query |
status | string | No | Drift status filter |
severity | string | No | Severity filter |
resourceType | string | No | Terraform resource type filter |
repositoryConfigId | string | No | Repository config filter |
page | number | No | Page number |
limit | number | No | Items per page |
sort | string | No | Sort field (e.g., -detectedAt) |
Example
curl -H "Authorization: Bearer TOKEN" \
"https://api.controlinfra.com/api/drifts/query?q=security_group&severity=high&sort=-detectedAt"Get Aggregations
GET /api/drifts/aggregations
Scope: drifts:read
Get drift aggregations for dashboard charts (by severity, resource type, trend over time).
Response
{
"success": true,
"data": {
"bySeverity": {
"critical": 2,
"high": 15,
"medium": 45,
"low": 12
},
"byResourceType": {
"aws_security_group": 8,
"aws_iam_role": 5
},
"trend": [...]
}
}Export CSV
GET /api/drifts/export
Scope: drifts:read
Export drifts as a CSV file.
Query Parameters
Same filters as Advanced Query.
Response
Returns text/csv content with drift data.
Example
curl -H "Authorization: Bearer TOKEN" \
"https://api.controlinfra.com/api/drifts/export?status=detected" \
-o drifts.csvGet Query Suggestions
GET /api/drifts/suggestions
Scope: drifts:read
Get autocomplete suggestions for the drift search query input.
Get Field Autocomplete
GET /api/drifts/autocomplete
Scope: drifts:read
Get field-specific autocomplete values from actual drift data.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
field | string | Yes | Field name to autocomplete |
prefix | string | No | Prefix to filter by |
List Drifts by Scan
GET /api/drifts/scan/:scanId
Scope: drifts:read
List all drifts detected in a specific scan.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
scanId | string | Scan ID |
List Drifts by Repository
GET /api/drifts/repository/:repositoryConfigId
Scope: drifts:read
List drifts for a specific repository configuration.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
repositoryConfigId | string | Repository config ID |
Get Drift Statistics
GET /api/drifts/repository/:repositoryConfigId/statistics
Scope: drifts:read
Get drift statistics for a repository (counts by severity, resolution rates, etc.).
Path Parameters
| Parameter | Type | Description |
|---|---|---|
repositoryConfigId | string | Repository config ID |
Get Drift
GET /api/drifts/:driftId
Scope: drifts:read
Get full details for a specific drift including the diff and AI analysis.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Response
{
"success": true,
"data": {
"_id": "drift1",
"resourceType": "aws_security_group",
"resourceAddress": "module.vpc.aws_security_group.main",
"severity": "high",
"status": "detected",
"diff": "...",
"aiAnalysis": {
"summary": "Security group ingress rule was modified...",
"riskLevel": "high",
"recommendation": "Review and revert unauthorized changes"
}
}
}Re-Analyze Drift
POST /api/drifts/:driftId/reanalyze
Scope: drifts:write
Re-run AI analysis on a drift.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Update Drift Status
PATCH /api/drifts/:driftId/status
Scope: drifts:write
Update the status of a drift (e.g., acknowledge, resolve, ignore).
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | New status (acknowledged, resolved, ignored) |
Example
curl -X PATCH https://api.controlinfra.com/api/drifts/drift1/status \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "acknowledged"}'Generate Fix
POST /api/drifts/:driftId/generate-fix
Scope: drifts:write
Generate AI-powered Terraform code to fix a drift.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Response
{
"success": true,
"data": {
"fixCode": "resource \"aws_security_group\" \"main\" {\n ...\n}",
"explanation": "This fix reverts the security group to its declared state..."
}
}Create Pull Request
POST /api/drifts/:driftId/create-pr
Scope: drifts:write
Create a GitHub pull request with the generated fix code.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Response
{
"success": true,
"data": {
"prUrl": "https://github.com/org/repo/pull/42",
"prNumber": 42,
"branch": "controlinfra/fix-drift-abc123"
}
}Approve Fix
POST /api/drifts/:driftId/approve-fix
Scope: drifts:write
Approve a generated fix in the approval workflow.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Submit Feedback
POST /api/drifts/:driftId/feedback
Scope: drifts:write
Submit feedback on the AI analysis quality for a drift.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
driftId | string | Drift ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
rating | number | Yes | Rating (1-5) |
comment | string | No | Optional feedback comment |