Drift Watch API Pro+
Drift Watch provides continuous monitoring for infrastructure drift. Create watches that periodically scan for changes and alert when drift is detected.
Endpoints Summary
| Method | Endpoint | Description |
|---|---|---|
GET | /api/drift-watch | List all drift watches |
POST | /api/drift-watch | Create a new watch |
GET | /api/drift-watch/:id | Get watch details |
PATCH | /api/drift-watch/:id | Update a watch |
DELETE | /api/drift-watch/:id | Delete a watch |
POST | /api/drift-watch/:id/accept | Accept detected drift |
POST | /api/drift-watch/:id/snooze | Snooze a watch |
POST | /api/drift-watch/:id/unsnooze | Unsnooze a watch |
PATCH | /api/drift-watch/bulk-update | Bulk update watches |
GET | /api/drift-watch/events | List watch events |
GET | /api/drift-watch/events/summary | Event summary statistics |
GET | /api/drift-watch/analytics | Watch analytics |
GET | /api/drift-watch/templates | List watch templates |
POST | /api/drift-watch/templates | Create a template |
DELETE | /api/drift-watch/templates/:id | Delete a template |
POST | /api/drift-watch/templates/:id/run | Run a template |
Authentication
All endpoints require a Bearer token in the Authorization header.
Authorization: Bearer <your-api-token>List Drift Watches
GET /api/drift-watchReturns all drift watches for the current organization.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by status: active, paused, snoozed |
repositoryId | string | Filter by repository |
page | number | Page number (default: 1) |
limit | number | Items per page (default: 20) |
Example:
curl -X GET "https://api.controlinfra.com/api/drift-watch?status=active&limit=10" \
-H "Authorization: Bearer YOUR_TOKEN"Response:
{
"watches": [
{
"_id": "664a1b2c3d4e5f6a7b8c9d0e",
"name": "Production VPC Monitor",
"repositoryId": "663f...",
"workspace": "production",
"status": "active",
"interval": "6h",
"lastRun": "2025-01-15T10:30:00Z",
"driftCount": 2,
"createdAt": "2025-01-01T00:00:00Z"
}
],
"total": 15,
"page": 1,
"pages": 2
}Create a Drift Watch
POST /api/drift-watchRequest Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the watch |
repositoryId | string | Yes | Repository to monitor |
workspace | string | No | Terraform workspace (default: "default") |
interval | string | Yes | Check interval: 1h, 6h, 12h, 24h |
notifyOn | string | No | When to notify: drift, all, none |
filters | object | No | Resource filters |
Example:
curl -X POST "https://api.controlinfra.com/api/drift-watch" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Production VPC Monitor",
"repositoryId": "663f1a2b3c4d5e6f7a8b9c0d",
"workspace": "production",
"interval": "6h",
"notifyOn": "drift"
}'Response: 201 Created
{
"_id": "664a1b2c3d4e5f6a7b8c9d0e",
"name": "Production VPC Monitor",
"status": "active",
"interval": "6h",
"createdAt": "2025-01-15T10:00:00Z"
}Get Watch Details
GET /api/drift-watch/:idExample:
curl -X GET "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e" \
-H "Authorization: Bearer YOUR_TOKEN"Update a Watch
PATCH /api/drift-watch/:idRequest Body: Any fields from the create endpoint. Only provided fields are updated.
Example:
curl -X PATCH "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"interval": "12h",
"notifyOn": "all"
}'Delete a Watch
DELETE /api/drift-watch/:idExample:
curl -X DELETE "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e" \
-H "Authorization: Bearer YOUR_TOKEN"Response: 204 No Content
Accept Drift
POST /api/drift-watch/:id/acceptMark detected drift as accepted (acknowledged). This clears the drift alert without resolving the underlying change.
Example:
curl -X POST "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e/accept" \
-H "Authorization: Bearer YOUR_TOKEN"Snooze a Watch
POST /api/drift-watch/:id/snoozeTemporarily pause monitoring for a watch.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
duration | string | Yes | Snooze duration: 1h, 6h, 24h, 7d, 30d |
reason | string | No | Reason for snoozing |
Example:
curl -X POST "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e/snooze" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"duration": "24h",
"reason": "Planned maintenance window"
}'Unsnooze a Watch
POST /api/drift-watch/:id/unsnoozeResume monitoring for a snoozed watch.
Example:
curl -X POST "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e/unsnooze" \
-H "Authorization: Bearer YOUR_TOKEN"Bulk Update Watches
PATCH /api/drift-watch/bulk-updateUpdate multiple watches at once.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
ids | string[] | Yes | Array of watch IDs |
updates | object | Yes | Fields to update |
Example:
curl -X PATCH "https://api.controlinfra.com/api/drift-watch/bulk-update" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ids": ["664a1b...", "664a1c..."],
"updates": {
"interval": "24h"
}
}'List Watch Events
GET /api/drift-watch/eventsReturns the event log for drift watch evaluations.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
watchId | string | Filter by watch ID |
type | string | Event type: drift_detected, drift_resolved, check_passed |
from | string | Start date (ISO 8601) |
to | string | End date (ISO 8601) |
page | number | Page number |
limit | number | Items per page |
Example:
curl -X GET "https://api.controlinfra.com/api/drift-watch/events?type=drift_detected&limit=20" \
-H "Authorization: Bearer YOUR_TOKEN"Event Summary
GET /api/drift-watch/events/summaryReturns aggregated statistics for watch events.
Example:
curl -X GET "https://api.controlinfra.com/api/drift-watch/events/summary" \
-H "Authorization: Bearer YOUR_TOKEN"Response:
{
"totalEvents": 450,
"driftDetected": 23,
"driftResolved": 18,
"checksPassed": 409,
"activeWatches": 12,
"snoozedWatches": 2
}Watch Analytics
GET /api/drift-watch/analyticsReturns analytics and trend data for drift watches.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
period | string | Time period: 7d, 30d, 90d |
Example:
curl -X GET "https://api.controlinfra.com/api/drift-watch/analytics?period=30d" \
-H "Authorization: Bearer YOUR_TOKEN"List Templates
GET /api/drift-watch/templatesReturns available drift watch templates.
Example:
curl -X GET "https://api.controlinfra.com/api/drift-watch/templates" \
-H "Authorization: Bearer YOUR_TOKEN"Create Template
POST /api/drift-watch/templatesSave the current watch configuration as a reusable template.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
description | string | No | Template description |
config | object | Yes | Watch configuration to save |
Example:
curl -X POST "https://api.controlinfra.com/api/drift-watch/templates" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Monitor",
"description": "Standard monitoring for production workspaces",
"config": {
"interval": "6h",
"notifyOn": "drift",
"workspace": "production"
}
}'Delete Template
DELETE /api/drift-watch/templates/:idExample:
curl -X DELETE "https://api.controlinfra.com/api/drift-watch/templates/664b2c3d..." \
-H "Authorization: Bearer YOUR_TOKEN"Run Template
POST /api/drift-watch/templates/:id/runCreate a new drift watch from a template.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name for the new watch |
repositoryId | string | Yes | Target repository |
overrides | object | No | Override template config values |
Example:
curl -X POST "https://api.controlinfra.com/api/drift-watch/templates/664b2c3d.../run" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Staging VPC Watch",
"repositoryId": "663f1a2b...",
"overrides": {
"workspace": "staging"
}
}'Response: 201 Created — Returns the newly created watch.