Skip to content

Authentication

Complete guide to authenticating with the Overwatch API using JWT tokens, API keys, and SSO.

JWT Tokens

Best for: User sessions, interactive applications

  • Short-lived access tokens (1 hour)
  • Refresh tokens for renewal
  • User-scoped permissions
  • SSO integration support

API Keys

Best for: Service integrations, automation

  • Long-lived credentials
  • Configurable permissions
  • IP whitelist support
  • Usage monitoring

Request:

Terminal window
curl -X POST "https://your-org.overwatch.com/api/v1/auth/login" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=user@company.com&password=your-password"

Response:

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"expires_in": 3600
}

Include the access token in the Authorization header:

Terminal window
curl -X GET "https://your-org.overwatch.com/api/v1/incidents" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Refresh the access token before it expires:

Terminal window
curl -X POST "https://your-org.overwatch.com/api/v1/auth/refresh" \
-H "Content-Type: application/json" \
-d '{"refresh_token": "your-refresh-token"}'

Response:

{
"access_token": "new-access-token",
"token_type": "bearer",
"expires_in": 3600
}

Invalidate current session and tokens:

Terminal window
curl -X POST "https://your-org.overwatch.com/api/v1/auth/logout" \
-H "Authorization: Bearer your-token"

Create an API key via dashboard or API:

Terminal window
curl -X POST "https://your-org.overwatch.com/api/v1/api-keys" \
-H "Authorization: Bearer your-jwt-token" \
-H "Content-Type: application/json" \
-d '{
"name": "CI/CD Integration",
"permissions": [
"incidents:read",
"incidents:create",
"procedures:execute"
],
"ip_whitelist": ["10.0.0.0/8"],
"expires_at": "2026-12-31T23:59:59Z"
}'

Response:

{
"id": "key-uuid",
"name": "CI/CD Integration",
"api_key": "overwatch_ak_1234567890abcdef",
"permissions": ["incidents:read", "incidents:create", "procedures:execute"],
"created_at": "2025-10-15T10:30:00Z",
"expires_at": "2026-12-31T23:59:59Z"
}

Include the API key in the X-API-Key header:

Terminal window
curl -X GET "https://your-org.overwatch.com/api/v1/incidents" \
-H "X-API-Key: overwatch_ak_1234567890abcdef"

View all API keys for your organization:

Terminal window
curl -X GET "https://your-org.overwatch.com/api/v1/api-keys" \
-H "Authorization: Bearer your-token"

Revoke an API key immediately:

Terminal window
curl -X DELETE "https://your-org.overwatch.com/api/v1/api-keys/{key_id}" \
-H "Authorization: Bearer your-token"
  • Azure Active Directory (Azure AD)
  • Okta
  • Google Workspace
  • OneLogin
  • SAML 2.0 (generic)
  1. Initiate SSO

    Terminal window
    curl -X GET "https://your-org.overwatch.com/api/v1/auth/sso/initiate?provider=azure"
  2. User Authenticates

    • User redirected to SSO provider
    • User logs in with SSO credentials
    • SSO provider redirects back with auth code
  3. Handle Callback

    Terminal window
    curl -X POST "https://your-org.overwatch.com/api/v1/auth/sso/callback" \
    -H "Content-Type: application/json" \
    -d '{"code": "auth-code", "state": "state-value"}'
  4. Receive JWT Token

    • API returns JWT access and refresh tokens
    • Use tokens for subsequent requests

Format: resource:action

PermissionDescription
incidents:readView incidents
incidents:createCreate new incidents
incidents:updateUpdate incident details
incidents:deleteDelete incidents
incidents:assignAssign incidents to users

Permission Restrictions:

{
"name": "DevOps API Key",
"permissions": [
"incidents:*", // All incident operations
"procedures:read", // Read procedures only
"procedures:execute" // Execute procedures
],
"ip_whitelist": [
"10.0.0.0/8", // Corporate network
"172.16.0.0/12" // VPN network
],
"rate_limit": 10000, // Custom rate limit
"expires_at": "2026-12-31T23:59:59Z"
}

Retrieve current user profile and permissions:

Terminal window
curl -X GET "https://your-org.overwatch.com/api/v1/auth/me" \
-H "Authorization: Bearer your-token"

Response:

{
"id": "user-uuid",
"email": "user@company.com",
"name": "John Doe",
"role": "engineer",
"organization": {
"id": "org-uuid",
"name": "Acme Corporation"
},
"permissions": [
"incidents:read",
"incidents:create",
"procedures:read",
"procedures:execute"
],
"last_login": "2025-10-15T10:30:00Z"
}
  1. Store Securely: Use environment variables or secrets manager
  2. Rotate Regularly: Rotate API keys every 90 days
  3. Limit Scope: Grant minimum necessary permissions
  4. Monitor Usage: Review API key usage regularly
  5. Revoke Unused: Remove API keys no longer in use
  1. Short Expiration: Access tokens expire in 1 hour
  2. Refresh Tokens: Use refresh tokens to obtain new access tokens
  3. Secure Storage: Store tokens in secure, httpOnly cookies or memory
  4. Logout on Exit: Invalidate tokens when user logs out
  5. Handle Expiration: Implement token refresh logic
  1. IP Whitelisting: Restrict API keys to known IP ranges
  2. Separate Keys: Use different keys for different services
  3. Monitor Alerts: Set up alerts for unusual usage patterns
  4. Audit Logs: Review API key usage in audit logs
  5. Emergency Revocation: Have process to quickly revoke compromised keys

401 Unauthorized - Invalid Token:

{
"error": {
"code": "INVALID_TOKEN",
"message": "JWT token has expired",
"details": {
"expired_at": "2025-10-15T09:30:00Z"
}
}
}

401 Unauthorized - Invalid API Key:

{
"error": {
"code": "INVALID_API_KEY",
"message": "API key not found or revoked"
}
}

403 Forbidden - Insufficient Permissions:

{
"error": {
"code": "INSUFFICIENT_PERMISSIONS",
"message": "User does not have permission to perform this action",
"details": {
"required_permission": "incidents:delete",
"user_permissions": ["incidents:read", "incidents:create"]
}
}
}
const { OverwatchClient } = require('@overwatch/api-client');
// Using JWT
const client = new OverwatchClient({
baseURL: 'https://your-org.overwatch.com',
username: 'user@company.com',
password: 'your-password'
});
await client.login();
// Using API Key
const clientWithKey = new OverwatchClient({
baseURL: 'https://your-org.overwatch.com',
apiKey: 'overwatch_ak_1234567890abcdef'
});
// Automatic token refresh
client.on('token.expired', async () => {
await client.refresh();
});

For authentication issues, contact support@overwatch-observability.com.


Related Documentation: