Docs/Reference/Error ingest API

Error ingest API

5 min read
On this page

Reference for the Dokwe error-ingest API. Applications push runtime errors to a project-scoped HTTP endpoint; the dashboard groups events by fingerprint and surfaces them under the project's Errors tab.

1. Conventions#

Base URL#

code
https://<your-dokwe-host>/api

For the hosted version that's https://dokwe.com/api. For self-hosted Dokwe deployments, use whatever you set as app.baseDomain.

Two auth surfaces#

The endpoints below split cleanly into two groups:

PrefixAuthWho calls it
/ingest/errors/…Authorization: Bearer dke_<hex> (project-scoped ingest token)Application SDKs / curl
/projects/:id/errors/…Authorization: Bearer <dokwe-platform-jwt> (same JWT used by the dashboard)Operators, dashboards

The two surfaces never share a token. An ingest token can only POST events into its own project — presenting it against a different :projectId returns 401. Presenting a platform JWT to the ingest endpoint also returns 401.

Project ID#

The :projectId is the project's UUID, visible in the dashboard URL (/projects/:id) and returned by GET /projects.

Errors#

Errors follow Nest's default HttpException shape:

json
{
  "statusCode": 401,
  "message": "Invalid or revoked token",
  "error": "Unauthorized"
}

2. Ingest — POST an error event#

POST /ingest/errors/:projectId#

Push a single error event.

Headers

HeaderValue
AuthorizationBearer dke_<hex> — project ingest token
Content-Typeapplication/json

Body

FieldTypeRequiredDescription
messagestring (≤ 4 000 chars)yesFirst line becomes the group summary. Line breaks are preserved for display but only the first line is stored on the searchable column.
level"fatal" | "error" | "warning" | "info" | "debug"noDefaults to "error". Unknown values are coerced to "error".
platformstring (≤ 40 chars)noFree-form; e.g. "nodejs", "python", "php-laravel", "browser". Grouped alongside fingerprint so the same exception on two runtimes doesn't merge visually.
runtimestring (≤ 60 chars)noe.g. "node-20.11.0".
environmentstring (≤ 60 chars)noe.g. "production", "staging".
releasestring (≤ 80 chars)noVersion/commit-sha of the deployed build.
stackarraynoOrdered top-frame first: [{ function, file, line, col, inApp? }]. Only the top frame is read for fingerprinting; the rest is stored as-is.
contextobjectnoFree-form request / user / tag / breadcrumb data. Whole object stored as JSONB.
context.fingerprint_overridestringnoWhen set, becomes the deterministic grouping key instead of the derived one. Useful for events that should merge regardless of stack (e.g. "5xx-from-upstream-Y").
occurredAtISO 8601 stringnoClient-provided timestamp. Falls back to server now() if missing or unparsable.

Response — 202 Accepted

json
{ "id": "8a3f…", "fingerprint": "c1e4…" }

Failure modes

StatusCause
400Body failed DTO validation (e.g. missing message, oversize message, invalid level type)
401Missing / malformed Authorization, unknown / revoked token, or token belongs to a different project
429Rate limit exceeded (see §6). Response includes Retry-After header.

Curl

bash
curl -X POST https://dokwe.com/api/ingest/errors/8a3f1e04-… \
  -H "Authorization: Bearer dke_abcd1234…" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "TypeError: cannot read property x of undefined",
    "level": "error",
    "platform": "nodejs",
    "runtime": "node-20.11.0",
    "environment": "production",
    "release": "v1.2.3",
    "stack": [
      { "function": "handleRequest", "file": "/app/src/api.js", "line": 42, "col": 12 },
      { "function": "processQueue",  "file": "/app/src/queue.js", "line": 88 }
    ],
    "context": {
      "request": { "url": "/api/foo", "method": "POST" },
      "user":    { "id": "42" },
      "tags":    { "region": "us-east-1" }
    }
  }'

fetch (Node/browser)

js
await fetch(`${BASE}/api/ingest/errors/${PROJECT_ID}`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${INGEST_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ message: err.message, stack: parseStack(err), level: 'error' }),
  keepalive: true,  // survives page unload for browser use
});

3. Grouped errors — list#

GET /projects/:projectId/errors#

Returns error groups (deduplicated by (fingerprint, platform)) ordered by lastSeenAt descending. Up to 500 groups.

Auth: platform JWT.

Query

ParameterDefaultMaxDescription
sinceHours168 (7 days)720 (30 days)Time window.

Response

json
[
  {
    "fingerprint":  "c1e4…",
    "message":      "TypeError: cannot read property x of undefined",
    "level":        "error",
    "platform":     "nodejs",
    "environments": ["production", "staging"],
    "count":        142,
    "firstSeenAt":  "2026-08-10T12:04:11Z",
    "lastSeenAt":   "2026-08-15T09:22:47Z"
  }
]

4. Occurrences — per-fingerprint detail#

GET /projects/:projectId/errors/:fingerprint/occurrences#

Returns the most recent raw event rows for a group. Ordered by receivedAt descending.

Auth: platform JWT.

Query

ParameterDefaultRangeDescription
limit1001 – 500Occurrence count.

Response

json
[
  {
    "id":          "8a3f…",
    "fingerprint": "c1e4…",
    "level":       "error",
    "message":     "TypeError: cannot read property x of undefined",
    "platform":    "nodejs",
    "runtime":     "node-20.11.0",
    "environment": "production",
    "release":     "v1.2.3",
    "stack":       [ { "function": "handleRequest", "file": "/app/src/api.js", "line": 42 } ],
    "context":     { "request": { "url": "/api/foo" } },
    "occurredAt":  "2026-08-15T09:22:47Z",
    "receivedAt":  "2026-08-15T09:22:48Z"
  }
]

5. Ingest tokens — mint, list, revoke#

GET /projects/:projectId/errors/tokens#

Returns token summaries — never the plain secret.

Auth: platform JWT.

Response

json
[
  {
    "id":          "3b7c…",
    "name":        "prod backend",
    "tokenPrefix": "dke_abcd12",
    "createdAt":   "2026-08-01T10:00:00Z",
    "lastUsedAt":  "2026-08-15T09:22:48Z",
    "revokedAt":   null
  }
]

POST /projects/:projectId/errors/tokens#

Mint a new token. The plain field is only returned on this response. It's the caller's job to show it to the user immediately; it cannot be recovered later.

Auth: platform JWT.

Body

FieldTypeRequired
namestring (1–120 chars)yes

Response

json
{
  "id":        "3b7c…",
  "name":      "prod backend",
  "plain":     "dke_abcd1234…",
  "prefix":    "dke_abcd12",
  "createdAt": "2026-08-15T10:00:00Z"
}

DELETE /projects/:projectId/errors/tokens/:tokenId#

Soft-revoke. Apps using the token start receiving 401 immediately; the row stays for the audit trail (name, prefix, last-used-at).

Auth: platform JWT.

Response — 200 OK

json
{ "revoked": true }

Attempting to revoke a token that was never yours (or that's already revoked) returns 404.


6. Rate limits#

Per-token, sliding window, enforced in-process on each API node.

Env variableDefaultPurpose
ERROR_INGEST_RATE_LIMIT_PER_MINUTE100Events per token per window.
ERROR_INGEST_RATE_WINDOW_MS60000Window size in ms.

When exceeded:

code
HTTP/1.1 429 Too Many Requests
Retry-After: 43
Content-Type: application/json

{ "statusCode": 429, "message": "Rate limit exceeded — retry after 43s", "error": "Too Many Requests" }

The limit is enforced after auth, so an unauthed flood cannot consume rate-limit slots on behalf of a valid token. Since the state is per-node, a multi-node API deployment enforces roughly N × the limit across the fleet — this is a safety net against runaway clients, not a strict quota.


7. Retention#

Events are pruned daily by a scheduled job. The default is 30 days.

Env variableDefaultPurpose
ERROR_INGEST_RETENTION_DAYS30Delete events older than N days.
ERROR_INGEST_RETENTION_BATCH5000Rows per DELETE statement. Small enough that each txn stays sub-second on prod hardware.
ERROR_INGEST_RETENTION_ENABLE"true"Set to "false" to disable — useful if you handle retention externally (compliance regimes, cold-storage export).

The sweep runs at 03:17 UTC daily. Deletes are batched so ingest writers aren't blocked on a giant transaction. error_ingest_tokens is not subject to retention — revoke or delete manually.


8. Fingerprinting#

The server derives a stable 32-char hex fingerprint for every event so duplicates group without any client cooperation.

The default derivation is:

code
sha256( platform | topFrame.function | topFrame.file | topFrame.line | firstLineOfMessage )[:32]

Loose enough that line-number drift within one function still groups. Tight enough that different exceptions in the same file don't collide.

To override — for example when you want all "5xx from upstream Y" events to merge regardless of which handler tripped the retry — pass a deterministic string in context.fingerprint_override:

json
{
  "message": "upstream Y returned 502",
  "context": { "fingerprint_override": "upstream-y-5xx" }
}

Override strings are hashed the same way, so they don't need to be under any particular length.


9. SDKs & minimal integrations#

The endpoint is small enough that curl + fetch cover most needs. For Node/TypeScript apps, we ship a thin client in @dokwe/js:

ts
import { createErrorReporter } from '@dokwe/js/errors';

const reporter = createErrorReporter({
  endpoint:    'https://dokwe.com',
  projectId:   process.env.DOKWE_PROJECT_ID!,
  token:       process.env.DOKWE_INGEST_TOKEN!,
  defaults:    { environment: process.env.NODE_ENV, release: process.env.APP_VERSION },
});

try {
  await doWork();
} catch (err) {
  reporter.capture(err, { context: { user: { id: '42' } } });
  throw err;
}

See packages/dokwe-js/README.md for the full surface.

For other languages, the minimal integration is 5 lines:

Python

python
import requests

def report(err):
    requests.post(
        f"{BASE}/api/ingest/errors/{PROJECT_ID}",
        headers={"Authorization": f"Bearer {TOKEN}"},
        json={"message": str(err), "platform": "python"},
        timeout=2,
    )

PHP

php
function dokwe_report(Throwable $e): void {
    $ch = curl_init(BASE . "/api/ingest/errors/" . PROJECT_ID);
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . TOKEN,
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "message" => $e->getMessage(),
            "platform" => "php",
        ]),
        CURLOPT_TIMEOUT => 2,
        CURLOPT_RETURNTRANSFER => true,
    ]);
    curl_exec($ch);
    curl_close($ch);
}