Skip to content

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

MethodEndpointDescription
GET/api/drift-watchList all drift watches
POST/api/drift-watchCreate a new watch
GET/api/drift-watch/:idGet watch details
PATCH/api/drift-watch/:idUpdate a watch
DELETE/api/drift-watch/:idDelete a watch
POST/api/drift-watch/:id/acceptAccept detected drift
POST/api/drift-watch/:id/snoozeSnooze a watch
POST/api/drift-watch/:id/unsnoozeUnsnooze a watch
PATCH/api/drift-watch/bulk-updateBulk update watches
GET/api/drift-watch/eventsList watch events
GET/api/drift-watch/events/summaryEvent summary statistics
GET/api/drift-watch/analyticsWatch analytics
GET/api/drift-watch/templatesList watch templates
POST/api/drift-watch/templatesCreate a template
DELETE/api/drift-watch/templates/:idDelete a template
POST/api/drift-watch/templates/:id/runRun a template

Authentication

All endpoints require a Bearer token in the Authorization header.

Authorization: Bearer <your-api-token>

List Drift Watches

GET /api/drift-watch

Returns all drift watches for the current organization.

Query Parameters:

ParameterTypeDescription
statusstringFilter by status: active, paused, snoozed
repositoryIdstringFilter by repository
pagenumberPage number (default: 1)
limitnumberItems per page (default: 20)

Example:

bash
curl -X GET "https://api.controlinfra.com/api/drift-watch?status=active&limit=10" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "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-watch

Request Body:

FieldTypeRequiredDescription
namestringYesDisplay name for the watch
repositoryIdstringYesRepository to monitor
workspacestringNoTerraform workspace (default: "default")
intervalstringYesCheck interval: 1h, 6h, 12h, 24h
notifyOnstringNoWhen to notify: drift, all, none
filtersobjectNoResource filters

Example:

bash
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

json
{
  "_id": "664a1b2c3d4e5f6a7b8c9d0e",
  "name": "Production VPC Monitor",
  "status": "active",
  "interval": "6h",
  "createdAt": "2025-01-15T10:00:00Z"
}

Get Watch Details

GET /api/drift-watch/:id

Example:

bash
curl -X GET "https://api.controlinfra.com/api/drift-watch/664a1b2c3d4e5f6a7b8c9d0e" \
  -H "Authorization: Bearer YOUR_TOKEN"

Update a Watch

PATCH /api/drift-watch/:id

Request Body: Any fields from the create endpoint. Only provided fields are updated.

Example:

bash
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/:id

Example:

bash
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/accept

Mark detected drift as accepted (acknowledged). This clears the drift alert without resolving the underlying change.

Example:

bash
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/snooze

Temporarily pause monitoring for a watch.

Request Body:

FieldTypeRequiredDescription
durationstringYesSnooze duration: 1h, 6h, 24h, 7d, 30d
reasonstringNoReason for snoozing

Example:

bash
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/unsnooze

Resume monitoring for a snoozed watch.

Example:

bash
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-update

Update multiple watches at once.

Request Body:

FieldTypeRequiredDescription
idsstring[]YesArray of watch IDs
updatesobjectYesFields to update

Example:

bash
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/events

Returns the event log for drift watch evaluations.

Query Parameters:

ParameterTypeDescription
watchIdstringFilter by watch ID
typestringEvent type: drift_detected, drift_resolved, check_passed
fromstringStart date (ISO 8601)
tostringEnd date (ISO 8601)
pagenumberPage number
limitnumberItems per page

Example:

bash
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/summary

Returns aggregated statistics for watch events.

Example:

bash
curl -X GET "https://api.controlinfra.com/api/drift-watch/events/summary" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "totalEvents": 450,
  "driftDetected": 23,
  "driftResolved": 18,
  "checksPassed": 409,
  "activeWatches": 12,
  "snoozedWatches": 2
}

Watch Analytics

GET /api/drift-watch/analytics

Returns analytics and trend data for drift watches.

Query Parameters:

ParameterTypeDescription
periodstringTime period: 7d, 30d, 90d

Example:

bash
curl -X GET "https://api.controlinfra.com/api/drift-watch/analytics?period=30d" \
  -H "Authorization: Bearer YOUR_TOKEN"

List Templates

GET /api/drift-watch/templates

Returns available drift watch templates.

Example:

bash
curl -X GET "https://api.controlinfra.com/api/drift-watch/templates" \
  -H "Authorization: Bearer YOUR_TOKEN"

Create Template

POST /api/drift-watch/templates

Save the current watch configuration as a reusable template.

Request Body:

FieldTypeRequiredDescription
namestringYesTemplate name
descriptionstringNoTemplate description
configobjectYesWatch configuration to save

Example:

bash
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/:id

Example:

bash
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/run

Create a new drift watch from a template.

Request Body:

FieldTypeRequiredDescription
namestringYesName for the new watch
repositoryIdstringYesTarget repository
overridesobjectNoOverride template config values

Example:

bash
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.