Skip to main content
Version: 1.2

API Keys

Overview​

API keys are used to authenticate requests to ToBeAlert's API. Each key has specific permissions and can be configured with an expiration date for enhanced security.

Creating API Keys​

Via Web UI​

  1. Log in to ToBeAlert
  2. Navigate to Access Control → API Keys
  3. Click Create key
  4. Fill in the required information:
    • Owner: The user who will own the key
    • Expiration date: When the key expires (optional but recommended)
    • Permissions: Select the permissions needed
    • Description: Optional description of the key's purpose
  5. Click Save

Via API​

curl -X POST "http://your-tobealert.com:9000/api/key" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_ADMIN_KEY" \
-d '{
"user": "api-user",
"scopes": [
"read:alerts",
"write:alerts"
],
"text": "Key for monitoring system",
"expireTime": "2025-12-31T23:59:59Z"
}'

Required fields:

  • user: The user who will own the key
  • scopes: Array of permission scopes (e.g., ["read:alerts", "write:alerts"])
  • text: Description of the key's purpose

Optional fields:

  • expireTime: ISO 8601 datetime when key expires

Using API Keys​

Include the API key in the Authorization header:

Authorization: Key YOUR_API_KEY_HERE

Example Request​

Send a test alert to verify API key works

curl -X POST "http://your-tobealert.com:9000/api/alert" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_API_KEY" \
-d '{
"resource": "server-01",
"event": "service_down",
"environment": "Production",
"severity": "critical",
"text": "Database service is down on server-01"
}'

API Key Permissions​

Permission Categories​

CategoryPermissionsDescription
Alertsread:alerts, write:alerts, delete:alerts, admin:alertsAlert management
Webhooksread:webhooks, write:webhooksManage custom webhooks
Servicesread:services, write:services, delete:services, admin:servicesService management
Historyread:history, write:history, admin:historyAlert history
Heartbeatsread:heartbeats, write:heartbeats, admin:heartbeatsHeartbeat monitoring
Maintenanceread:maintenance_windows, write:maintenance_windows, admin:maintenance_windowsMaintenance windows
Userswrite:users, admin:usersManage user accounts
Groupsread:groups, admin:groupsManage user groups
Rolesread:roles, admin:rolesManage user roles
Keysread:keys, write:keys, admin:keysAPI key management
Managementread:management, admin:managementSystem management
User Inforead:userinfoView user information
Policiesread:policies, write:policies, admin:policiesAlert policies
Workflowsread:workflow, write:workflow, admin:workflowWorkflow management
Service Topologiesread:service_topologies, write:service_topologies, admin:service_topologiesService topology management
Service Historyread:service_history, write:service_history, admin:service_historyService history management
Alert Sourcesread:alert_sources, write:alert_sources, admin:alert_sourcesAlert source management
Access Controlread:accesscontrol, write:accesscontrolAccess control management
Instructionswrite:instructionsSystem instructions
Notifications - Templatesread:notification-templates, write:notification-templatesNotification template management
Notifications - Groupsread:notification-groups, write:notification-groupsNotification group management
Notifications - Rulesread:notification-rules, write:notification-rulesNotification rule management
Notifications - Methodsread:notification-methods, write:notification-methodsNotification method management
Toolsread:tool, write:tool, admin:toolCustom tools
Metricsread:metrics, write:metrics, admin:metricsMetrics management
KPIsread:kpis, write:kpis, admin:kpisKPI management
OEmbedread:oembedOEmbed support

Permission Matrix​

ActionRequired Permission
Send alertswrite:alerts
View alertsread:alerts
Create webhookswrite:webhooks
View webhooksread:webhooks
Manage API keysadmin:keys
View audit logread:audit
Delete alertsdelete:alerts
Admin alertsadmin:alerts
View user inforead:userinfo
Read keysread:keys
Write keyswrite:keys
Admin keysadmin:keys
Delete servicesdelete:services
Admin servicesadmin:services
Admin historyadmin:history
Admin heartbeatsadmin:heartbeats
Admin maintenance windowsadmin:maintenance_windows
Admin usersadmin:users
Admin groupsadmin:groups
Admin rolesadmin:roles
Admin managementadmin:management
Admin policiesadmin:policies
Admin workflowsadmin:workflow
Admin service topologiesadmin:service_topologies
Admin service historyadmin:service_history
Admin alert sourcesadmin:alert_sources
Write access controlwrite:accesscontrol
Write instructionswrite:instructions
Write notification templateswrite:notification-templates
Write notification groupswrite:notification-groups
Write notification ruleswrite:notification-rules
Write notification methodswrite:notification-methods
Admin toolsadmin:tool
Write metricswrite:metrics
Admin metricsadmin:metrics
Write KPIswrite:kpis
Admin KPIsadmin:kpis

Best Practices​

  1. Use minimal permissions - Grant only the permissions needed
  2. Set expiration dates - Avoid permanent keys
  3. Rotate keys regularly - Replace keys periodically
  4. Use descriptive names - Identify the purpose of each key
  5. Monitor usage - Track which keys are being used
  6. Secure storage - Keep keys safe, never commit to code repositories

Revoking API Keys​

Via Web UI​

  1. Navigate to Access Control → API Keys
  2. Find the key you want to revoke
  3. Click Delete
  4. Confirm the deletion

Via API​

Delete an API key (requires admin:keys permission)

curl -X DELETE "http://your-tobealert.com:9000/api/key/YOUR_KEY_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_ADMIN_KEY"

Troubleshooting​

Common Issues​

  1. 401 Unauthorized - Check the key is valid and not expired
  2. 403 Forbidden - Verify the key has required permissions or license issues
  3. 400 Bad Request - Missing required fields or invalid data

Testing API Keys​

warning

This endpoint requires a key with read:keys permission.

Get information about a specific API key

curl -X GET "http://your-tobealert.com:9000/api/keys/YOUR_KEY_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_API_KEY"