Skip to main content

Client Logging

The /api/_log endpoint lets browser apps and external clients ship log events back to the server, where they're persisted alongside the API's own event log.

Use sparingly

This is a lightweight logging endpoint, not a full telemetry or observability platform. It has no sampling, no rate limiting, and no structured properties. Reach for it when you want a quick way to see client-side errors and warnings server-side — not for analytics, user behaviour tracking, or verbose debug traces.

Endpoint

POST /api/_log
RequirementValue
AuthRequired — Bearer token or access cookie. Anonymous calls are rejected with 401.
Bodyapplication/json — array of event objects
Response200 OK on success, 400 Bad Request on malformed JSON

Request Body

Send a JSON array of events, even if you only have one:

POST /api/_log
Content-Type: application/json
Authorization: Bearer <access-token>

[
{
"severity": 1,
"message": "Uncaught TypeError: cannot read 'id' of undefined"
}
]

Fields

FieldTypeRequiredDescription
messagestringYesThe log text.
severityintNoLog level. Defaults to 3 (Info). See table below.

Severity Levels

ValueLevel
0Fatal
1Error
2Warning
3Info (default)
4Debug
5Trace

The authenticated user is attached to each event automatically from the request token.

Example: Browser Error Reporter

window.addEventListener("error", (e) => {
fetch("/api/_log", {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: JSON.stringify([
{
severity: 1,
message: `${e.message} @ ${e.filename}:${e.lineno}`,
},
]),
});
});

Notes

  • The endpoint accepts a batch — buffer events on the client and flush periodically to reduce request volume.
  • Sample or filter noisy events client-side. Treat each call as something a human will read.