API Reference

The TeamSentry REST API lets you programmatically access security data, manage incidents, and integrate with AI agents. Every response includes a machine-readable summary field optimized for LLM consumption.

Authentication

All API requests require a valid API key sent as a Bearer token in the Authorization header. API keys are scoped to an organization and can be created from the TeamSentry dashboard under Settings > Agent API.

Creating an API Key

API keys follow the format tsk_live_xxxxxxxxxxxx for production keys and tsk_test_xxxxxxxxxxxx for test keys.

Using Your API Key

HTTP Header
Authorization: Bearer tsk_live_your_api_key_here
curl example
curl https://api.teamsentry.ai/v1/overview \
  -H "Authorization: Bearer tsk_live_your_api_key_here" \
  -H "Content-Type: application/json"

Security: Never expose API keys in client-side code, public repositories, or logs. Rotate keys immediately if compromised.

Base URL

All API endpoints are relative to:

Base URL
https://api.teamsentry.ai/v1

Response Format

All responses are JSON. Every successful response includes a top-level summary field containing a natural-language description of the data, optimized for AI agent consumption.

Standard Response Shape
{
  "summary": "Human-readable summary of the response data.",
  "data": { ... },
  "meta": {
    "request_id": "req_abc123",
    "timestamp": "2025-01-15T10:30:00Z"
  }
}

Overview

GET /v1/overview

Returns a high-level security summary for your organization, including risk distribution, active incidents, and AI usage stats.

ParameterTypeDescription
include_ai_usagebooleanoptionalInclude AI tool usage statistics
include_incidentsbooleanoptionalInclude open incident summary
Response
{
  "summary": "142 monitored users. 3 high-risk users. 2 open incidents.",
  "organization": {
    "total_users": 142,
    "monitored_users": 142
  },
  "risk_distribution": {
    "critical": 1,
    "high": 2,
    "medium": 8,
    "low": 47,
    "minimal": 84
  },
  "open_incidents": 2
}

Users

GET /v1/users

List all monitored users in the organization with basic risk info.

ParameterTypeDescription
limitintegeroptionalMax results (default: 50, max: 200)
offsetintegeroptionalPagination offset
risk_levelstringoptionalFilter: critical, high, medium, low, minimal
GET /v1/users/:email/risk

Get detailed risk profile for a specific user including active rules, behavioral anomalies, and MITRE ATT&CK mappings.

ParameterTypeDescription
include_timelinebooleanoptionalInclude risk score timeline (7d)
Response
{
  "summary": "[email protected] has HIGH risk (82). 4 active rules.",
  "user": {
    "email": "[email protected]",
    "name": "John Smith",
    "risk_score": 82,
    "risk_level": "high"
  },
  "active_rules": [
    {
      "rule_id": "impossible_travel",
      "severity": "high",
      "mitre_tactic": "TA0001",
      "triggered_at": "2025-01-15T08:22:00Z"
    }
  ]
}
GET /v1/users/high-risk

List users above a specified risk threshold, sorted by risk score descending.

ParameterTypeDescription
min_risk_scoreintegeroptionalMinimum risk score (default: 70)
limitintegeroptionalMax results (default: 20)
GET /v1/users/search

Search users by name, email, or department.

ParameterTypeDescription
querystringrequiredSearch term
risk_levelstringoptionalFilter by risk level
limitintegeroptionalMax results (default: 20)

Incidents

GET /v1/incidents

List security incidents with filtering by status, severity, and date range.

ParameterTypeDescription
statusstringoptionalopen, closed, or all (default: open)
severitystringoptionalcritical, high, medium, low
limitintegeroptionalMax results (default: 20)
GET /v1/incidents/:id

Get full incident details including timeline, affected users, triggered rules, and recommended actions.

PUT /v1/incidents/:id/status

Update incident status. Allows programmatic triage and closure.

ParameterTypeDescription
statusstringrequiredNew status: investigating, resolved, false_positive
notesstringoptionalResolution notes

AI Usage

GET /v1/ai-usage

Get AI tool usage analytics across the organization. Tracks Gemini, ChatGPT, Claude, and other AI tools.

ParameterTypeDescription
daysintegeroptionalLookback period in days (default: 7)
group_bystringoptionalGroup by: user, tool, or day

Apps

GET /v1/apps

List all third-party apps connected to the workspace with risk assessments and OAuth scopes.

ParameterTypeDescription
statusstringoptionalFilter: trusted, untrusted, or all

Agent-Specific

These endpoints are specifically designed for AI agent consumption with enriched summaries and structured context.

GET /v1/agent/summary

Returns a comprehensive, LLM-optimized security summary with actionable insights and recommended next steps.

POST /v1/agent/query

Execute a natural language security query. The API interprets the query and returns relevant security data.

ParameterTypeDescription
querystringrequiredNatural language query (e.g., "Who has the highest risk?")
GET /v1/agent/tools

Lists all available MCP tools with their schemas, parameter definitions, and example invocations.

Error Codes

The API uses standard HTTP status codes. Error responses include a structured JSON body with error details.

Error Response Format
{
  "error": {
    "code": "invalid_api_key",
    "message": "The API key provided is invalid or expired.",
    "status": 401
  },
  "request_id": "req_abc123"
}
StatusCodeDescription
400bad_requestInvalid request parameters or body
401invalid_api_keyMissing, invalid, or expired API key
403forbiddenAPI key lacks required permissions
404not_foundRequested resource does not exist
409conflictResource state conflict (e.g., incident already resolved)
429rate_limitedToo many requests, retry after specified delay
500internal_errorUnexpected server error

Rate Limits

API requests are rate limited to ensure fair usage and platform stability.

TierLimitWindow
Standard1,000 requestsPer minute, per API key
Enterprise10,000 requestsPer minute, per API key

Rate limit headers are included in every response:

Rate Limit Headers
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 997
X-RateLimit-Reset: 1705312800

When rate limited, the API returns a 429 status with a Retry-After header indicating the number of seconds to wait before retrying.

Webhooks

Webhooks deliver real-time event notifications to your endpoint via HTTP POST. Configure webhook endpoints in your dashboard under Settings > Webhooks.

Event Format

All webhook payloads follow a standard envelope format:

Webhook Payload
{
  "id": "evt_abc123",
  "event": "incident.created",
  "timestamp": "2025-01-15T10:30:00Z",
  "data": {
    "incident_id": "inc_8f3k2j",
    "severity": "high",
    "title": "Possible account takeover detected",
    "affected_user": "[email protected]"
  }
}

HMAC Verification

Every webhook request includes an X-TeamSentry-Signature header containing an HMAC-SHA256 signature of the raw request body, using your webhook secret as the key.

Python - Verify Signature
import hmac
import hashlib

def verify_signature(payload_body, signature, secret):
    expected = hmac.new(
        secret.encode("utf-8"),
        payload_body,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(
        f"sha256={expected}",
        signature
    )

Retry Policy

If your endpoint does not respond with a 2xx status within 10 seconds, TeamSentry retries delivery with exponential backoff:

After 5 failed retries, the event is marked as failed and logged in your dashboard. You can manually replay failed events from the webhook settings page.