Browser Ingest
Send events from browsers and single-page apps. Browser code is public, so it never holds your secret key - your backend mints a short-lived session token (1 hour) and the browser sends events with x-bugwatch-session.
The flow
- Backend calls Server Ingest API → Mint browser session token with the secret DSN key.
- Your page fetches that token from your own endpoint (the JS SDK does this automatically via
sessionUrl). - The browser posts events to
/api/v1/bugwatch/ingest/browserwith the token. On a401(expired token) re-fetch and retry once.
Origin allow-list: the project's allowed origins (Dashboard → project → Settings) is enforced on every browser event - a mismatched Origin gets 403 origin_not_allowed. An empty list allows any origin; lock it down before go-live.
Using @newinstance/bugwatch in the browser? Install per Install an SDK → JavaScript & TypeScript, pass sessionUrl (never projectKey), and this wire format is what the SDK produces for you.
/api/v1/bugwatch/ingest/browserBrowser ingest – error event
Ingest events from browser / SPA applications.
Authentication: x-bugwatch-session - a short-lived token minted by your backend via POST /api/v1/bugwatch/browser-session. Mint a token first and send it as {{sessionToken}}.
The secret key never reaches the browser. The session token is ingest-only, scoped to one project+environment, and honours the project's allowedOrigins allow-list.
Request
- Header:
x-bugwatch-session: {{sessionToken}} - Content-Type:
application/jsonorapplication/x-ndjson - Max body: 2 MB
- CORS: allowed from any origin in the project's
allowedOrigins(empty = allow all)
Success - 202 Accepted
{ "ingested": 1, "skipped": 0, "deduped": 0 }Common errors
401- invalid or expired session token403- origin not inallowedOrigins(origin_not_allowed)404- project not found or inactive
Headers
x-bugwatch-sessionRequest body
application/json{
"level": 50,
"time": {{nowMs}},
"message": "Uncaught TypeError in browser",
"release": "1.0.0",
"environment": "production",
"tags": { "browser": "Chrome", "page": "/checkout" },
"user": { "id": "usr_browser_001", "ip": "203.0.113.42" },
"exception": {
"type": "TypeError",
"value": "Cannot read properties of null (reading 'getAttribute')",
"stacktrace": {
"frames": [
{ "filename": "https://app.example.com/static/js/main.chunk.js", "function": "handleClick", "lineno": 112, "colno": 45 }
]
}
}
}Responses
202 – Browser event ingested
{
"ingested": 1,
"skipped": 0,
"deduped": 0
}https://api.newinstance.cloud/api/v1/bugwatch/ingest/browserHeaders
x-bugwatch-sessionRequest body
Code samples
curl -X POST 'https://api.newinstance.cloud/api/v1/bugwatch/ingest/browser' \
-H 'Content-Type: application/json' \
--data-raw '{
"level": 50,
"time": {{nowMs}},
"message": "Uncaught TypeError in browser",
"release": "1.0.0",
"environment": "production",
"tags": { "browser": "Chrome", "page": "/checkout" },
"user": { "id": "usr_browser_001", "ip": "203.0.113.42" },
"exception": {
"type": "TypeError",
"value": "Cannot read properties of null (reading '\''getAttribute'\'')",
"stacktrace": {
"frames": [
{ "filename": "https://app.example.com/static/js/main.chunk.js", "function": "handleClick", "lineno": 112, "colno": 45 }
]
}
}
}'