Usage log
Read your key's call log to see which requests reached Neccessory and why a call was refused.
Neccessory records the signed calls your key makes. Read the log to confirm that a request arrived and to find out why a call was refused.
What is recorded
| Recorded | Not recorded |
|---|---|
| Successful calls | Requests rejected after authentication, such as 400, 403 and 404 |
Authentication failures (401), with the reason | Reads of the log itself |
Rate-limited calls (429) |
A refused call is recorded under your key only when its x-key-id names one of your keys.
Read the log
GET /sdk/v1/logs| Query | Type | Default | Description |
|---|---|---|---|
limit | number | 50 | Rows per page, 1–200 |
sinceTime | number | — | Return rows at or after this time, epoch milliseconds |
cursor | string | — | nextCursor from the previous page. Returns rows strictly after it. Takes precedence over sinceTime |
Rows come oldest first. Without sinceTime or cursor, the log starts from the oldest row.
{
"ok": true,
"data": {
"items": [
{
"id": "log_4f7c1b90a2d8e35617c4a0f2",
"time": 1790000000123,
"endpoint": "/sdk/v1/measurements",
"method": "POST",
"status": "success",
"latencyMs": 38,
"requestId": "req_9a1c4e77b0d2358fc6e4",
"error": null,
"errorCode": null,
"qualityLevel": "good"
},
{
"id": "log_8b2e0d4c71f93a5602e8b1d7",
"time": 1790000004510,
"endpoint": "/sdk/v1/cloud/sessions",
"method": "POST",
"status": "unauthorized",
"latencyMs": 3,
"requestId": "req_1f0e6c2a9b47d3805ea2",
"error": "Timestamp outside allowed window",
"errorCode": "timestamp_out_of_window",
"qualityLevel": null
}
],
"nextCursor": "1790000004510.log_8b2e0d4c71f93a5602e8b1d7",
"serverTime": 1790000009000
}
}Row fields
| Field | Type | Description |
|---|---|---|
id | string | Row ID |
time | number | When the request arrived, epoch milliseconds |
endpoint | string | Path without the query string |
method | string | HTTP method |
status | string | success, unauthorized or rate_limited |
latencyMs | number | null | Server handling time |
requestId | string | The call's X-Request-Id |
error | string | null | Human-readable reason. Do not branch on it |
errorCode | string | null | Machine-readable reason. Branch on this |
qualityLevel | string | null | good, fair or poor when the call stored a measurement |
nextCursor points after the last row of the page. On an empty page it repeats the cursor you
sent. serverTime is the server clock, epoch milliseconds.
errorCode
errorCode | Meaning |
|---|---|
missing_credentials | A signing header was missing |
invalid_nonce | The nonce was shorter than 8 or longer than 128 characters |
invalid_timestamp | x-timestamp was not a number |
timestamp_out_of_window | The timestamp was more than 300 s from the server clock |
unknown_key | No key has this key ID |
key_disabled | The key is disabled |
key_expired | The key has expired |
invalid_signature | The signature did not match |
nonce_reused | The nonce was already used |
rate_limited | A request limit was reached |
Fixes for each authentication code are in Authentication.
Follow the log
Poll with the cursor to follow new rows as they arrive. This example uses neccessory from
Authentication and prints every refused call from the last hour
onward.
import { neccessory } from './neccessory.js';
const PAGE = 200;
let cursor = null;
const since = Date.now() - 60 * 60 * 1000;
for (;;) {
const position = cursor ? `cursor=${encodeURIComponent(cursor)}` : `sinceTime=${since}`;
const page = await neccessory('GET', `/sdk/v1/logs?limit=${PAGE}&${position}`);
for (const row of page.items) {
if (row.status !== 'success') {
console.log(new Date(row.time).toISOString(), row.method, row.endpoint, row.errorCode, row.requestId);
}
}
cursor = page.nextCursor ?? cursor;
if (page.items.length < PAGE) await new Promise((resolve) => setTimeout(resolve, 5000));
}The log endpoint allows 60 requests per minute per key. Beyond that it returns
429 rate_limited, and that call is recorded.
Trace a call with X-Request-Id
Every response carries an X-Request-Id header. The same value appears:
- as
requestIdon the call's log row; - as
requestIdon the measurement stored byPOST /sdk/v1/measurements; - in the console search, which opens the call or the measurement.
Log the header with every failed call. It links your application logs, the usage log and the stored measurement.
const res = await fetch(url, { method: 'POST', headers, body });
if (!res.ok) console.warn('neccessory call failed', res.status, res.headers.get('x-request-id'));