LogFlow API

API Endpoints

Quick Start

Install with curl:

curl -X POST https://api.logflow.io/v1/install

Authentication

All API requests require authentication using an API key. Include your key in the Authorization header.

GET /v1/auth/verify

Verify your API key is valid.

Example Request

curl -X GET https://api.logflow.io/v1/auth/verify \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "valid": true,
  "expires_at": "2023-12-31T23:59:59Z"
}

Log Management

POST /v1/logs

Ingest new log entries into the system.

Request Body

{
  "source": "web-server-1",
  "level": "error",
  "message": "Database connection failed",
  "timestamp": "2023-06-15T14:30:00Z",
  "metadata": {
    "service": "auth-service",
    "ip": "192.168.1.1"
  }
}

Example Request

curl -X POST https://api.logflow.io/v1/logs \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"source":"web-server-1","level":"error","message":"Database connection failed"}'

Response

{
  "id": "log_123456789",
  "status": "processed"
}
GET /v1/logs

Query logs with filters and pagination.

Query Parameters

level string

Filter by log level (error, warning, info)

source string

Filter by source identifier

limit integer

Number of results per page (default: 50)

page integer

Page number (default: 1)

Example Request

curl -X GET "https://api.logflow.io/v1/logs?level=error&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "data": [
    {
      "id": "log_123456789",
      "source": "web-server-1",
      "level": "error",
      "message": "Database connection failed",
      "timestamp": "2023-06-15T14:30:00Z",
      "metadata": {
        "service": "auth-service"
      }
    }
  ],
  "total": 1245,
  "page": 1,
  "pages": 125
}

Log Sources

GET /v1/sources

List all configured log sources.

Example Request

curl -X GET https://api.logflow.io/v1/sources \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "sources": [
    {
      "id": "src_123456789",
      "name": "web-server-1",
      "type": "file",
      "path": "/var/log/nginx/access.log",
      "status": "active",
      "last_activity": "2023-06-15T14:32:00Z"
    }
  ]
}

Alerts

POST /v1/alerts

Create a new alert rule.

Request Body

{
  "name": "High Error Rate",
  "condition": "error_count > 10",
  "time_window": "5m",
  "actions": [
    {
      "type": "webhook",
      "target": "https://hooks.slack.com/services/..."
    }
  ]
}

Example Request

curl -X POST https://api.logflow.io/v1/alerts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"High Error Rate","condition":"error_count > 10"}'

Response

{
  "id": "alert_123456789",
  "status": "active"
}

Statistics

GET /v1/stats

Get system statistics.

Example Request

curl -X GET https://api.logflow.io/v1/stats \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "logs": {
    "total": 24568,
    "errors": 1245,
    "warnings": 876,
    "info": 22447
  },
  "sources": {
    "active": 19,
    "inactive": 2
  },
  "storage": {
    "used": "45GB",
    "available": "155GB"
  }
}