LogstackLogstack

Logs API

Ingest and query logs via the REST API.

Logs API

Endpoints for ingesting and querying logs.

POST /logs

Ingest logs for a project. Supports batch ingestion.

This endpoint uses API key authentication via Authorization: Bearer, not JWT tokens.

Request

curl -X POST https://api.logstack.tech/v1/logs \
  -H "Authorization: Bearer ls_live_abc123xyz789" \
  -H "Content-Type: application/json" \
  -d '{
    "logs": [
      {
        "level": "info",
        "message": "User logged in successfully",
        "source": "auth-service",
        "metadata": {
          "userId": "user_123",
          "ip": "192.168.1.1"
        }
      },
      {
        "level": "error",
        "message": "Database connection failed",
        "source": "db-service",
        "metadata": {
          "error": "Connection timeout",
          "host": "db.example.com"
        }
      }
    ]
  }'

Request Body

FieldTypeRequiredDescription
logsarrayArray of log entries (max 1000)
logs[].levelstringinfo, warn, error, or critical
logs[].messagestringLog message (max 10KB)
logs[].sourcestringService/component identifier
logs[].metadataobjectStructured metadata (max 100KB)
logs[].timestampstringISO 8601 timestamp (auto-generated if omitted)

Response (202 Accepted)

{
  "accepted": 2,
  "rejected": 0
}

Rate Limits

PlanLogs per minuteBatch size
Free1,000100
Starter10,000500
Pro100,0001,000
EnterpriseUnlimited1,000

GET /logs

Query logs with filters.

Request

curl "https://api.logstack.tech/v1/logs?projectId=proj_123&level=error&offset=0&limit=50" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."

Query Parameters

ParameterTypeDefaultDescription
projectIdstringrequiredProject ID
levelstringallFilter by level: info, warn, error, critical
searchstringFull-text search in message
startTimestring24h agoISO 8601 start time
endTimestringnowISO 8601 end time
offsetnumber0Number of results to skip
limitnumber50Results per request (max 1000)

Response (200 OK)

{
  "data": [
    {
      "id": "log_abc123",
      "projectId": "proj_123",
      "level": "error",
      "message": "Database connection failed",
      "source": "db-service",
      "metadata": {
        "error": "Connection timeout",
        "host": "db.example.com"
      },
      "timestamp": "2024-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "offset": 0,
    "limit": 50,
    "total": 1234
  }
}

GET /logs/:id

Get a single log entry by ID.

Request

curl https://api.logstack.tech/v1/logs/log_abc123 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."

Response (200 OK)

{
  "id": "log_abc123",
  "projectId": "proj_123",
  "level": "error",
  "message": "Database connection failed",
  "source": "db-service",
  "metadata": {
    "error": "Connection timeout",
    "host": "db.example.com",
    "stack": "Error: Connection timeout\n    at ..."
  },
  "timestamp": "2024-01-15T10:30:00Z"
}

SDK vs Direct API

The SDK handles batching, retries, and error handling automatically:

import { createLogStack } from "logstack-js";
 
const logstack = createLogStack({
  apiKey: "ls_live_abc123xyz789",
});
 
logstack.error("Database connection failed", {
  error: "Connection timeout",
  host: "db.example.com",
});

Best Practices

  1. Batch logs — Send multiple logs per request to reduce overhead
  2. Use structured metadata — Makes searching and filtering easier
  3. Include timestamps — For accurate time ordering across services
  4. Add source tags — Identify which service generated each log

On this page