Monitoring API

Monitor AI token usage, detect anomalies, track model drift, analyze sentiment, and manage scheduled reports. Includes both team-scoped endpoints and admin-level rate-limit monitoring.

Team Monitoring Endpoints

These endpoints are available to team members and provide visibility into AI usage and alert management.

Get Monitoring Config

GET
/api/monitoring/teams/:teamId/config

Get the monitoring configuration for a team

200 OK
{
  "anomalyDetectionEnabled": true,
  "driftAlertEnabled": true,
  "sentimentTrackingEnabled": false,
  "alertThresholds": {
    "tokenUsageSpike": 2.0,
    "errorRateThreshold": 0.15,
    "latencyThreshold": 5000
  },
  "notificationChannels": ["email", "slack"]
}

Update Monitoring Config

PUT
/api/monitoring/teams/:teamId/config

Update the monitoring configuration

Accepts the same fields as the GET response. Only provided fields are updated.

Get Token Usage

GET
/api/monitoring/teams/:teamId/token-usage

Get aggregated token usage for a team

ParameterTypeRequiredDescription
fromISO 8601NoStart date (default: 30 days ago)
toISO 8601NoEnd date (default: now)
200 OK
{
  "totalInputTokens": 1250000,
  "totalOutputTokens": 890000,
  "totalCost": 12.45,
  "period": {
    "from": "2026-01-17T00:00:00.000Z",
    "to": "2026-02-17T00:00:00.000Z"
  }
}

Get Daily Usage

GET
/api/monitoring/teams/:teamId/token-usage/daily

Get daily token usage breakdown

200 OK
{
  "days": [
    {
      "date": "2026-02-17",
      "inputTokens": 45000,
      "outputTokens": 32000,
      "cost": 0.42,
      "executionCount": 128
    }
  ]
}

Get Usage by Model

GET
/api/monitoring/teams/:teamId/token-usage/by-model

Get token usage broken down by AI model

200 OK
{
  "models": [
    {
      "model": "gpt-4o",
      "inputTokens": 800000,
      "outputTokens": 600000,
      "cost": 8.40,
      "executionCount": 320
    },
    {
      "model": "claude-sonnet-4-20250514",
      "inputTokens": 450000,
      "outputTokens": 290000,
      "cost": 4.05,
      "executionCount": 180
    }
  ]
}

Bulk Acknowledge Alerts

POST
/api/monitoring/teams/:teamId/alerts/bulk-acknowledge

Acknowledge multiple anomaly, drift, or sentiment alerts at once

FieldTypeRequiredDescription
alertIdsUUID[]YesArray of alert IDs to acknowledge
typestringYesAlert type: ANOMALY, DRIFT, or SENTIMENT
Request
{
  "alertIds": ["uuid-1", "uuid-2", "uuid-3"],
  "type": "ANOMALY"
}
200 OK
{
  "acknowledged": 3,
  "message": "Alerts acknowledged successfully"
}

Export Monitoring Data

GET
/api/monitoring/teams/:teamId/export

Export monitoring data as CSV or JSON

ParameterTypeRequiredDescription
formatstringNoExport format: csv or json (default: json)
fromISO 8601NoStart date
toISO 8601NoEnd date

Scheduled Reports

GET
/api/monitoring/teams/:teamId/scheduled-reports

List all scheduled monitoring reports

POST
/api/monitoring/teams/:teamId/scheduled-reports

Create a new scheduled report

PUT
/api/monitoring/teams/:teamId/scheduled-reports/:id

Update a scheduled report

DELETE
/api/monitoring/teams/:teamId/scheduled-reports/:id

Delete a scheduled report

FieldTypeRequiredDescription
namestringYesReport name
schedulestringYesCron expression (5-field Unix format)
recipientsstring[]YesEmail addresses to send the report to
metricsstring[]YesMetrics to include (token_usage, anomalies, drift, sentiment)
Request
{
  "name": "Weekly AI Usage Report",
  "schedule": "0 9 * * 1",
  "recipients": ["team@example.com"],
  "metrics": ["token_usage", "anomalies"]
}

Error Codes

StatusMeaning
400Invalid query parameters or date range
403Insufficient permissions (team or admin access required)
404Team or report not found