API Documentation

Integrate PagePatrol's monitoring capabilities into your applications.

Authentication

All API requests require authentication using an API key. You can create an API key from your API keys page.

curl -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.pagepatrol.net/v1/platforms

Rate Limiting

API requests are limited to 30 requests per minute per API key. Rate limit information is included in the response headers:

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: 1639516800

Error Responses

PagePatrol uses conventional HTTP response codes to indicate the success or failure of an API request:

2xx - Success

200 OK - Request succeeded

201 Created - Resource was successfully created

4xx - Client Errors

401 Unauthorized - Invalid or missing API key

422 Unprocessable Entity - Validation errors

429 Too Many Requests - Rate limit exceeded

Error Response Format

{
  "error": "Validation failed",
  "details": {
    "uri": ["must be a valid URL"]
  }
}

Platforms API

List All Platforms

Retrieve all platforms for your company.

GET https://api.pagepatrol.net/v1/platforms
{
  "data": [{
    "id": 1,
    "name": "My Website",
    "uri": "https://example.com",
    "frequency_in_minutes": 5,
    "current_status": "up",
    "status_code": 200,
    "check_ssl": true,
    "uptime_24h": 100,
    "uptime_7d": 99.9,
    "uptime_30d": 99.8,
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z",
    "last_checked_at": "2024-01-01T00:00:00Z"
  }]
}

Create Platform

Add a new platform to monitor.

POST https://api.pagepatrol.net/v1/platforms

{
  "platform": {
    "name": "My Website",
    "uri": "https://example.com",
    "frequency_in_minutes": 5,
    "status_code": 200,
    "check_ssl": true
  }
}

Update Platform

Update an existing platform's configuration.

PATCH https://api.pagepatrol.net/v1/platforms/:id

{
  "platform": {
    "name": "Updated Website Name",
    "uri": "https://example.com",
    "frequency_in_minutes": 10,
    "status_code": 200,
    "check_ssl": true
  }
}
{
  "id": 1,
  "name": "Updated Website Name",
  "uri": "https://example.com",
  "frequency_in_minutes": 10,
  "current_status": "up",
  "status_code": 200,
  "check_ssl": true,
  "uptime_24h": 100,
  "uptime_7d": 99.9,
  "uptime_30d": 99.8,
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z",
  "last_checked_at": "2024-01-01T00:00:00Z"
}

Get Platform Status

Retrieve the current status of a platform.

GET https://api.pagepatrol.net/v1/platforms/:id/status
{
  "current_status": "up",
  "last_checked_at": "2024-01-01T00:00:00Z"
}

Get Platform Logs

Retrieve recent access logs for a platform.

GET https://api.pagepatrol.net/v1/platforms/:id/logs
{
  "data": [{
    "id": 1,
    "succeed": true,
    "response_time": 245,
    "status_code": 200,
    "content_matched": true,
    "error_message": null,
    "created_at": "2024-01-01T00:00:00Z"
  }]
}

Alert Rules API

List Platform Alert Rules

Retrieve all alert rules for a platform.

GET https://api.pagepatrol.net/v1/platforms/:platform_id/alert_rules
{
  "data": [{
    "id": 1,
    "name": "High Response Time",
    "channel": "email",
    "destination": "[email protected]",
    "severity": "warning",
    "threshold_count": 2,
    "cooldown_minutes": 10,
    "timezone": "UTC",
    "active": true,
    "active_days": ["mon", "tue", "wed", "thu", "fri"],
    "active_hours_start": "09:00",
    "active_hours_end": "17:00",
    "conditions": {
      "response_time": {
        "operator": ">",
        "value": "1000"
      }
    },
    "templates": {
      "email": {
        "subject": "High Response Time Alert",
        "body": "Response time exceeded threshold"
      }
    }
  }]
}

Create Alert Rule

Create a new alert rule for a platform.

POST https://api.pagepatrol.net/v1/platforms/:platform_id/alert_rules

{
  "alert_rule": {
    "name": "High Response Time",
    "channel": "email",
    "destination": "[email protected]",
    "severity": "warning",
    "threshold_count": 2,
    "cooldown_minutes": 10,
    "timezone": "UTC",
    "active_days": ["mon", "tue", "wed", "thu", "fri"],
    "active_hours_start": "09:00",
    "active_hours_end": "17:00",
    "conditions": {
      "response_time": {
        "operator": ">",
        "value": "1000"
      }
    }
  }
}

Update Alert Rule

Update an existing alert rule's configuration.

PATCH https://api.pagepatrol.net/v1/platforms/:platform_id/alert_rules/:id

{
  "alert_rule": {
    "name": "Updated Alert Rule",
    "channel": "slack",
    "destination": "https://hooks.slack.com/...",
    "severity": "critical",
    "threshold_count": 3,
    "cooldown_minutes": 15,
    "timezone": "UTC",
    "active_days": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"],
    "active_hours_start": "00:00",
    "active_hours_end": "23:59",
    "conditions": {
      "status_code": {
        "pattern": "5\\d\\d"
      }
    },
    "templates": {
      "slack": {
        "text": "🔴 {{platform.name}} is experiencing issues!"
      }
    }
  }
}
{
  "id": 1,
  "name": "Updated Alert Rule",
  "channel": "slack",
  "destination": "https://hooks.slack.com/...",
  "severity": "critical",
  "threshold_count": 3,
  "cooldown_minutes": 15,
  "timezone": "UTC",
  "active": true,
  "active_days": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"],
  "active_hours_start": "00:00",
  "active_hours_end": "23:59",
  "conditions": {
    "status_code": {
      "pattern": "5\\d\\d"
    }
  },
  "templates": {
    "slack": {
      "text": "🔴 {{platform.name}} is experiencing issues!"
    }
  },
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z"
}

Schema Definitions

Platform Object

{
  "id": "integer",
  "name": "string",
  "uri": "string (URL)",
  "frequency_in_minutes": "integer",
  "current_status": "string (up|down|paused)",
  "status_code": "integer",
  "check_ssl": "boolean",
  "uptime_24h": "float",
  "uptime_7d": "float",
  "uptime_30d": "float",
  "created_at": "datetime",
  "updated_at": "datetime",
  "last_checked_at": "datetime"
}

Alert Rule Object

{
  "id": "integer",
  "name": "string",
  "channel": "string (email|slack|discord|webhook|sms)",
  "destination": "string",
  "severity": "string (critical|warning|info)",
  "threshold_count": "integer",
  "cooldown_minutes": "integer",
  "timezone": "string",
  "active": "boolean",
  "active_days": "array",
  "active_hours_start": "time",
  "active_hours_end": "time",
  "conditions": "object",
  "templates": "object"
}