Docs
Logs

Send backend logs

Backend logs are server-side log lines you POST to Nevision with your server API key. Useful for capturing exceptions, failed background jobs, webhook errors, slow queries, or any structured event you want searchable in the dashboard. All five log levels are accepted (debug, info, warn, error, fatal) — your server controls what's emitted.

Endpoint

POST https://api.nevision.app/v1/logs
Content-Type: application/json
Authorization: Bearer sk_YOUR_SERVER_KEY

Server calls authenticate via the Authorization: Bearer sk_* header. The server API key is shown on Sites → Install (it starts with sk_). Keep this key server-side only — never embed it in browser code or commit it to a public repo. If you need to log from the browser, use the frontend logs endpoint, which authenticates by domain allowlist.

Payload

{
  "entries": [
    {
      "level": "error",
      "message": "DB connection refused",
      "fields": {
        "service": "api",
        "route": "/api/orders",
        "stack": "Error: ECONNREFUSED ...",
        "durationMs": 5230
      },
      "timestamp": "2026-04-27T12:34:56Z",
      "sessionId": "optional-frontend-session-id"
    }
  ]
}

level and message are required; everything else is optional. fields is a free-form object you can search and filter on. timestamp is ISO-8601 (server fills it in if absent). sessionId lets you link a backend log to the frontend session that triggered the request — set it from a request header your recorder injects. Up to 1000 entries per request, max 64 KB per message.

Code examples

curl -X POST https://api.nevision.app/v1/logs \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_YOUR_SERVER_KEY" \
  -d '{
    "entries": [{
      "level": "error",
      "message": "Stripe webhook signature invalid",
      "fields": { "service": "api", "route": "/webhooks/stripe" },
      "timestamp": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"
    }]
  }'

Response

{ "accepted": 1, "rejected": 0, "bytesIngested": 187, "limitReached": false }

Returns 200 on success, 402 if the monthly logs quota is exhausted (free plans hard-block; paid plans accept overage and bill it). 401 means the Authorization header is missing, malformed, or doesn't start with sk_; 404 means the key doesn't map to an active site.

Tips

  • Use structured fields. Search by level:error AND fields.service:api is far faster than grepping the message string.
  • Fire-and-forget. Don't block your request path on ingestion — short timeout (5s) or a background queue.
  • Batch when you can. Up to 1000 entries per request — useful in workers, crons, and bulk import flows.
  • Link to sessions. If your frontend recorder injects an x-nevision-session header on outgoing fetch/XHR, read it on the server and set sessionId on every log line. Then any log can jump to the matching session replay in the dashboard.