API Examples

API Examples #

Basic usage examples.

Authentication Setup #

export UPTIMER_TOKEN="your_jwt_token_here"
Authorization: Bearer YOUR_JWT_TOKEN

Basic Operations #

Create Rule #

curl -X POST https://your-uptimer-instance.com/api/v1/rules \
  -H "Authorization: Bearer $UPTIMER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Website Health Check",
    "interval": 300,
    "workspace_id": "ws_123456",
    "request": {
      "url": "https://example.com",
      "method": "GET"
    },
    "response": {
      "statuses": [200]
    }
  }'
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

List Workspaces #

curl -X GET https://your-uptimer-instance.com/api/v1/workspaces \
  -H "Authorization: Bearer $UPTIMER_TOKEN"
Authorization: Bearer YOUR_JWT_TOKEN

List Rules #

curl -X GET "https://your-uptimer-instance.com/api/v1/rules?workspace_id=ws_123456" \
  -H "Authorization: Bearer $UPTIMER_TOKEN"
Authorization: Bearer YOUR_JWT_TOKEN

Update Rule #

curl -X POST https://your-uptimer-instance.com/api/v1/rules/rule_123456 \
  -H "Authorization: Bearer $UPTIMER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Rule",
    "interval": 120,
    "request": {
      "url": "https://example.com",
      "method": "GET"
    },
    "response": {
      "statuses": [200]
    }
  }'
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

Delete Rule #

curl -X DELETE https://your-uptimer-instance.com/api/v1/rules/rule_123456 \
  -H "Authorization: Bearer $UPTIMER_TOKEN"
Authorization: Bearer YOUR_JWT_TOKEN

Get Regions #

curl -X GET https://your-uptimer-instance.com/api/v1/regions \
  -H "Authorization: Bearer $UPTIMER_TOKEN"
Authorization: Bearer YOUR_JWT_TOKEN

Error Handling #

Validation Error #

{
  "result": null,
  "error": {
    "code": 2001,
    "error_type": "validation_error",
    "message": "Validation failed",
    "details": "Field 'name' is required"
  },
  "meta": null
}

Access Denied #

{
  "result": null,
  "error": {
    "code": 2005,
    "error_type": "access_denied",
    "message": "Access denied",
    "details": "User does not have access to this workspace"
  },
  "meta": null
}