Adding a Monitor via API

Monitor API

The Monitor API allows you to programmatically create, configure, and manage monitoring for your websites, APIs, and services.

Creating a Website Monitor

To create a new website monitor, send a POST request:

curl -X POST "https://api.uptimekeeper.com/v1/monitors" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "http",
    "name": "Company Website",
    "url": "https://example.com",
    "check_frequency": 60,
    "timeout": 30,
    "regions": ["us-east", "eu-west", "asia-east"],
    "validation": {
      "status_code": 200,
      "content_check": "Welcome to our site"
    }
  }'

API Parameters for Website Monitors

ParameterTypeDescription
typestringMonitor type (http, https, tcp, etc.)
namestringDisplay name for the monitor
urlstringURL to monitor
check_frequencyintegerSeconds between checks
timeoutintegerSeconds to wait before timing out
regionsarrayGeographic regions to check from
validationobjectCriteria for successful check

Creating an API Monitor

For API endpoint monitoring:

curl -X POST "https://api.uptimekeeper.com/v1/monitors" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "api",
    "name": "Payment API",
    "url": "https://api.example.com/health",
    "method": "POST",
    "headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer token123"
    },
    "body": "{\"test\": true}",
    "validation": {
      "status_code": 200,
      "json_path": "$.status",
      "json_value": "healthy"
    }
  }'

Creating Other Monitor Types

The API supports various monitor types including TCP, DNS, SSL, and Ping:

# Example of an SSL certificate monitor
curl -X POST "https://api.uptimekeeper.com/v1/monitors" \
  -H "X-API-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "ssl",
    "name": "Website SSL",
    "hostname": "example.com",
    "alert_days_before_expiry": 14
  }'