Ingest Logs

Send log events into Lightning Logs via the ingest endpoint.

POST
/functions/v1/ingest
Ingest log events into the system. Events are queued and processed asynchronously.

Authentication

Requires JWT token (Bearer token) or API key (X-API-Key header or Bearer with ll_ prefix)

Parameters

NameTypeRequiredDescription
logsLogEvent[] | LogEventRequiredArray of log events or a single log event object

Request Body

interface LogEvent {
  ts?: string | number;  // ISO 8601 timestamp or Unix timestamp
  level?: 'debug' | 'info' | 'warn' | 'error';
  msg?: string;
  service?: string;
  env?: string;
  req_id?: string;
  user_id?: string;
  route?: string;
  host?: string;
  attrs?: Record<string, any>;  // Additional attributes as JSON
}
Example
[
  {
    "ts": "2025-01-15T10:30:00Z",
    "level": "info",
    "msg": "User logged in",
    "service": "api",
    "user_id": "user-123",
    "route": "/api/auth/login"
  },
  {
    "ts": "2025-01-15T10:30:05Z",
    "level": "error",
    "msg": "Payment failed",
    "service": "payment",
    "req_id": "req-456",
    "attrs": {
      "amount": 100.00,
      "currency": "USD"
    }
  }
]

Responses

200Successfully queued log events
{
  "success": true,
  "ingested": 2,
  "rejected": 0
}
400Invalid request (invalid JSON, too many records, etc.)
{
  "error": "Too many records: 15000 (max 10000)"
}
401Authentication failed
{
  "error": "Invalid token, API key, or missing tenant_id"
}
413Request body too large
{
  "error": "Request body too large: 600000 bytes (max 512000)"
}

Examples

curl -X POST https://your-project.supabase.co/functions/v1/ingest \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "ts": "2025-01-15T10:30:00Z",
      "level": "info",
      "msg": "User logged in",
      "service": "api"
    }
  ]'

Limits

  • Maximum 10,000 records per request
  • Maximum 500KB request body size
  • Events are queued and processed asynchronously
  • Timestamps are automatically added if missing