Skip to content

Latest commit

 

History

History
314 lines (279 loc) · 5.17 KB

API.md

File metadata and controls

314 lines (279 loc) · 5.17 KB

API Documentation

Authentication

All API endpoints are protected using Laravel Sanctum authentication. You need to include a Bearer token in the Authorization header:

Authorization: Bearer <your-token>

To obtain a token, use the /api/app/token endpoint.

Endpoints

Authentication

Generate API Token

POST /api/app/token

Returns a new API token for authentication.

Profile

Get User Profile

GET /api/profile

Returns the authenticated user's profile information.

Monitors

List Monitors

GET /api/monitors

Returns a list of all monitors belonging to the authenticated user.

Response:

[
  {
    "id": "string",
    "address": "string",
    "type": "enum",
    "is_enabled": "boolean",
    "status": "enum",
    "last_checked_at": "datetime",
    "consecutive_threshold": "integer",
    "created_at": "datetime",
    "updated_at": "datetime",
    "last_check": {
      "id": "string",
      "status": "enum",
      "checked_at": "datetime",
      "response_time": "integer",
      // ... other check details
    },
    "anomalies": [
      // Only includes active anomalies (not ended)
      {
        "id": "string",
        "started_at": "datetime",
        "ended_at": null,
        // ... other anomaly details
      }
    ]
  }
]

Get Monitor Details

GET /api/monitors/{monitor}

Returns detailed information about a specific monitor.

Response:

{
  "id": "string",
  "address": "string",
  "type": "enum",
  "is_enabled": "boolean",
  "status": "enum",
  "last_checked_at": "datetime",
  "consecutive_threshold": "integer",
  "created_at": "datetime",
  "updated_at": "datetime",
  "last_check": {
    "id": "string",
    "status": "enum",
    "checked_at": "datetime",
    "response_time": "integer"
  },
  "anomalies": [
    // Only includes active anomalies
  ],
  "checks": [
    // Latest 10 checks
    {
      "id": "string",
      "status": "enum",
      "checked_at": "datetime",
      "response_time": "integer"
    }
  ]
}

List Monitor Anomalies

GET /api/monitors/{monitor}/anomalies

Returns a paginated list of anomalies for a specific monitor.

Response:

{
  "data": [
    {
      "id": "string",
      "started_at": "datetime",
      "ended_at": "datetime|null",
      "checks": [
        {
          "id": "string",
          "status": "enum",
          "checked_at": "datetime",
          "response_time": "integer"
        }
      ]
    }
  ],
  "links": {
    "first": "string",
    "last": "string",
    "prev": "string|null",
    "next": "string|null"
  },
  "meta": {
    "current_page": "integer",
    "last_page": "integer",
    "per_page": 15,
    "total": "integer"
  }
}

Get Monitor Anomaly Details

GET /api/monitors/{monitor}/anomalies/{anomaly}

Returns detailed information about a specific anomaly for a monitor.

Response:

{
  "id": "string",
  "started_at": "datetime",
  "ended_at": "datetime|null",
  "checks": [
    {
      "id": "string",
      "status": "enum",
      "checked_at": "datetime",
      "response_time": "integer"
    }
  ],
  "triggers": [
    {
      "id": "string",
      "alert": {
        "id": "string",
        "name": "string",
        // ... alert details
      }
    }
  ]
}

Account-wide Anomalies

List All Anomalies

GET /api/anomalies

Returns a paginated list of all anomalies across all monitors.

Response:

{
  "data": [
    {
      "id": "string",
      "started_at": "datetime",
      "ended_at": "datetime|null",
      "monitor": {
        "id": "string",
        "address": "string",
        // ... monitor details
      },
      "checks": [
        {
          "id": "string",
          "status": "enum",
          "checked_at": "datetime",
          "response_time": "integer"
        }
      ]
    }
  ],
  "links": {
    "first": "string",
    "last": "string",
    "prev": "string|null",
    "next": "string|null"
  },
  "meta": {
    "current_page": "integer",
    "last_page": "integer",
    "per_page": 15,
    "total": "integer"
  }
}

Get Anomaly Details

GET /api/anomalies/{anomaly}

Returns detailed information about any anomaly.

Response:

{
  "id": "string",
  "started_at": "datetime",
  "ended_at": "datetime|null",
  "monitor": {
    "id": "string",
    "address": "string",
    // ... monitor details
  },
  "checks": [
    {
      "id": "string",
      "status": "enum",
      "checked_at": "datetime",
      "response_time": "integer"
    }
  ],
  "triggers": [
    {
      "id": "string",
      "alert": {
        "id": "string",
        "name": "string",
        // ... alert details
      }
    }
  ]
}

Error Responses

All endpoints may return the following error responses:

401 Unauthorized

{
  "message": "Unauthenticated."
}

403 Forbidden

{
  "message": "This action is unauthorized."
}

404 Not Found

{
  "message": "Resource not found."
}

422 Validation Error

{
  "message": "The given data was invalid.",
  "errors": {
    "field_name": [
      "Error message"
    ]
  }
}

500 Server Error

{
  "message": "Server error message"
}