Skip to content

API Examples

This page provides copy-and-paste code samples for the most common API operations. Each example is shown in curl, JavaScript (using fetch), and Python (using requests).

Replace https://your-instance.overwatch.com with the base URL of your Overwatch deployment throughout.


Obtain an access token by sending the user’s email and password to the login endpoint. The response includes an access_token (valid for 1 hour) and a refresh_token (valid for 7 days).

Terminal window
curl -X POST "https://your-instance.overwatch.com/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "engineer@example.com",
"password": "your-password"
}'

Response:

{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"refresh_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "bearer",
"expires_in": 3600,
"user": {
"id": "user-uuid",
"email": "engineer@example.com",
"name": "Jane Doe",
"role": "engineer"
}
}

Store the access_token and use it in subsequent requests:

Terminal window
export TOKEN="eyJhbGciOiJIUzI1NiIs..."

Retrieve a paginated list of incidents. You can filter by status, severity, and search terms. Results are sorted by creation date (newest first) by default.

Terminal window
# List active high-severity incidents (first 25)
curl -X GET "https://your-instance.overwatch.com/api/v1/incidents?status=active&severity=high&limit=25" \
-H "Authorization: Bearer $TOKEN"

Response:

{
"data": [
{
"id": "inc-uuid-001",
"title": "Payment service latency spike",
"severity": "high",
"status": "active",
"created_at": "2026-02-23T08:15:00Z",
"assignee": "Jane Doe"
},
{
"id": "inc-uuid-002",
"title": "Database connection pool exhaustion",
"severity": "high",
"status": "active",
"created_at": "2026-02-23T07:42:00Z",
"assignee": null
}
],
"meta": {
"total": 2,
"limit": 25,
"offset": 0
}
}

Create a new incident by providing a title, severity, and description. The API returns the newly created incident with its generated ID and timestamps.

Terminal window
curl -X POST "https://your-instance.overwatch.com/api/v1/incidents" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Redis cluster failover in us-east-1",
"severity": "critical",
"description": "Primary Redis node became unreachable at 14:32 UTC. Sentinel promoted a replica, but several services experienced cache misses and elevated latency during the failover window."
}'

Response:

{
"id": "inc-uuid-003",
"title": "Redis cluster failover in us-east-1",
"severity": "critical",
"status": "active",
"description": "Primary Redis node became unreachable at 14:32 UTC...",
"created_at": "2026-02-23T14:35:00Z",
"created_by": "user-uuid"
}

Use the semantic search endpoint to find incidents by meaning, not just keywords. The search engine converts your query into a vector embedding and returns ranked results based on conceptual similarity.

Terminal window
curl -X POST "https://your-instance.overwatch.com/api/v1/search/query" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "database connection pool exhaustion causing timeouts",
"limit": 10
}'

Response:

{
"results": [
{
"id": "inc-uuid-002",
"title": "Database connection pool exhaustion",
"type": "incident",
"score": 0.94,
"snippet": "PostgreSQL max_connections limit reached, causing new connection requests to time out..."
},
{
"id": "inc-uuid-017",
"title": "Aurora read replica connection saturation",
"type": "incident",
"score": 0.87,
"snippet": "Read replica hit 500 connection ceiling during traffic spike..."
},
{
"id": "proc-uuid-005",
"title": "Restart connection pooler (PgBouncer)",
"type": "procedure",
"score": 0.82,
"snippet": "Steps to safely restart PgBouncer without dropping active queries..."
}
],
"meta": {
"total": 3,
"query_time_ms": 142
}
}

Tip: Semantic search returns results across multiple entity types — incidents, procedures, and knowledge base articles. Use the type field in each result to distinguish between them.


If you are building a service integration or automation script, use an API key instead of JWT tokens. The X-API-Key header replaces the Authorization header.

Terminal window
curl -X GET "https://your-instance.overwatch.com/api/v1/incidents?status=active" \
-H "X-API-Key: overwatch_ak_1a2b3c4d5e6f7890"

Note: API keys are long-lived and do not expire automatically (unless you set an expires_at during creation). See the Authentication guide for details on creating and managing API keys.


All API errors return a JSON body with a detail field. Here is a pattern for consistent error handling across your application.

class OverwatchAPIError extends Error {
constructor(statusCode, detail) {
super(detail);
this.statusCode = statusCode;
this.name = "OverwatchAPIError";
}
}
async function apiRequest(method, path, { token, body } = {}) {
const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};
const response = await fetch(`${BASE_URL}${path}`, {
method,
headers,
body: body ? JSON.stringify(body) : undefined,
});
if (!response.ok) {
const error = await response.json().catch(() => ({}));
if (response.status === 401) {
// Token expired — trigger refresh or redirect to login
console.warn("Token expired, refreshing...");
}
throw new OverwatchAPIError(
response.status,
error.detail || `Request failed with status ${response.status}`
);
}
return response.json();
}