Logs API

Endpoints for log ingestion, querying, filtering, and analysis.

Create Log Entry

POST
/api/v1/:projectId/logs

Ingest a log entry (API Key auth)

This is the primary ingestion endpoint used by the SDK. Requires API key authentication via the X-API-Key header.

Bash
curl -X POST https://apperioserver.onrender.com/api/v1/PROJECT_ID/logs \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "timestamp": "2026-03-07T10:30:00.000Z",
    "level": "error",
    "message": "Database connection timeout",
    "service": "api-gateway",
    "environment": "production",
    "error": {
      "name": "MongoTimeoutError",
      "message": "Connection timed out after 30000ms",
      "stack": "MongoTimeoutError: Connection timed out..."
    },
    "data": {
      "host": "db.example.com",
      "port": 27017,
      "retryCount": 3
    }
  }'
JSON
// Response(201 Created)
{
  "status": "success",
  "message": "Log created successfully",
  "data": {
    "id": "log_abc123",
    "projectId": "PROJECT_ID",
    "timestamp": "2026-03-07T10:30:00.000Z",
    "level": "error",
    "message": "Database connection timeout"
  }
}

Query Logs

GET
/api/v1/:projectId/logs

Query logs with filters and pagination (JWT auth)

Retrieve logs with full filtering, search, and pagination support.

ParameterTypeDescription
pagenumberPage number (default: 1)
limitnumberResults per page (default: 50, max: 100)
levelstringFilter by level (trace, debug, info, warn, error, fatal)
searchstringFull-text search on message field
startDatestringISO date for range start
endDatestringISO date for range end
eventTypestringFilter by event type
servicestringFilter by service name
environmentstringFilter by environment
sortBystringSort field (default: timestamp)
sortOrderstringasc or desc (default: desc)
Bash
# Get recent error logs
curl "https://apperioserver.onrender.com/api/v1/PROJECT_ID/logs?level=error&limit=20" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Search logs with date range
curl "https://apperioserver.onrender.com/api/v1/PROJECT_ID/logs?search=timeout&startDate=2026-03-01&endDate=2026-03-07" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
JSON
// Response(200 OK)
{
  "status": "success",
  "data": [
    {
      "id": "log_abc123",
      "timestamp": "2026-03-07T10:30:00Z",
      "level": "error",
      "message": "Database connection timeout",
      "service": "api-gateway",
      "environment": "production"
    }
  ],
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 156,
    "totalRecords": 156
  }
}

Get Single Log

GET
/api/v1/:projectId/logs/:logId

Get a specific log entry by ID (JWT auth)

Bash
curl "https://apperioserver.onrender.com/api/v1/PROJECT_ID/logs/LOG_ID" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Log Summary

GET
/api/v1/:projectId/logs/summary

Get aggregated log statistics (JWT auth)

Returns counts grouped by level, event type, and time period:

JSON
// Response
{
  "status": "success",
  "data": {
    "totalLogs": 15420,
    "byLevel": {
      "trace": 1200,
      "debug": 3400,
      "info": 8500,
      "warn": 1800,
      "error": 490,
      "fatal": 30
    },
    "byEventType": {
      "error": 520,
      "performance": 2100,
      "network": 8400,
      "console": 1200,
      "pageview": 3200
    }
  }
}
GET
/api/v1/:projectId/logs/trends

Get log volume trends over time (JWT auth)

ParameterTypeDescription
timeRangestringTime range: "1h", "24h", "7d", "30d"
granularitystring"minute", "hour", "day"

Unique Errors

GET
/api/v1/:projectId/logs/unique-errors

Get unique error messages with counts (JWT auth)

Returns deduplicated error messages grouped by frequency, useful for identifying the most impactful issues.

Delete Logs

DELETE
/api/v1/:projectId/logs

Delete logs matching filters (JWT auth)

Danger

This is a destructive operation. Deleted logs cannot be recovered. Use filters to target specific logs for deletion.
Bash
# Delete all debug logs older than 7 days
curl -X DELETE "https://apperioserver.onrender.com/api/v1/PROJECT_ID/logs?level=debug&endDate=2026-02-28" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Log Entry Schema

Complete schema for a log entry:

TypeScript
interface LogEntry {
  projectId: string;
  timestamp: string;              class="syntax-comment">// ISO class="syntax-number">8601 format
  level: class="syntax-string">"trace" | class="syntax-string">"debug" | class="syntax-string">"info" | class="syntax-string">"warn" | class="syntax-string">"error" | class="syntax-string">"fatal";
  message: string;
  data?: Record<string, any>;     class="syntax-comment">// Arbitrary structured data
  error?: {
    name: string;
    message: string;
    stack?: string;
    url?: string;
    lineNumber?: number;
    columnNumber?: number;
  };
  service?: string;               class="syntax-comment">// Service name tag
  environment?: string;           class="syntax-comment">// e.g., class="syntax-string">"production", class="syntax-string">"staging"
  context?: Record<string, any>;  class="syntax-comment">// Request/session context
  metadata?: any;                 class="syntax-comment">// SDK metadata(sanitization info, etc.)
  eventType?: class="syntax-string">"error" | class="syntax-string">"performance" | class="syntax-string">"interaction"
             | class="syntax-string">"network" | class="syntax-string">"console" | class="syntax-string">"pageview";
  userAgent?: string;
  url?: string;                   class="syntax-comment">// Page URL
  referrer?: string;
  responseTime?: number;          class="syntax-comment">// For network events(ms)
}