NeccessoryNeccessory
REST API

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

RecordedNot recorded
Successful callsRequests rejected after authentication, such as 400, 403 and 404
Authentication failures (401), with the reasonReads 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
QueryTypeDefaultDescription
limitnumber50Rows per page, 1–200
sinceTimenumber—Return rows at or after this time, epoch milliseconds
cursorstring—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

FieldTypeDescription
idstringRow ID
timenumberWhen the request arrived, epoch milliseconds
endpointstringPath without the query string
methodstringHTTP method
statusstringsuccess, unauthorized or rate_limited
latencyMsnumber | nullServer handling time
requestIdstringThe call's X-Request-Id
errorstring | nullHuman-readable reason. Do not branch on it
errorCodestring | nullMachine-readable reason. Branch on this
qualityLevelstring | nullgood, 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

errorCodeMeaning
missing_credentialsA signing header was missing
invalid_nonceThe nonce was shorter than 8 or longer than 128 characters
invalid_timestampx-timestamp was not a number
timestamp_out_of_windowThe timestamp was more than 300 s from the server clock
unknown_keyNo key has this key ID
key_disabledThe key is disabled
key_expiredThe key has expired
invalid_signatureThe signature did not match
nonce_reusedThe nonce was already used
rate_limitedA 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 requestId on the call's log row;
  • as requestId on the measurement stored by POST /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'));