inspector.restDocs

Ingest wire format

The HTTP and JSON format the SDKs use to send recorded requests: endpoint, headers, compression, multipart binary bodies, batch envelope, record fields and response codes.

The SDKs send recorded requests to inspector.rest in batches. You do not need this page to use an SDK. It is for people who write their own client, debug traffic or want to know exactly what is stored. The format is defined by a JSON Schema (draft 07) that you can download; the field tables below are generated from it. Current wire version: 1. A breaking change increments v.

ingest.schema.jsonJSON Schema, draft 07, wire version 1

Request

Method and pathPOST /api/ingest on https://<org-slug>.api.inspector.rest
x-inspector-keyThe environment’s ingest key (irk_<org-slug>_<secret>)
content-typeapplication/json, or multipart/form-data when binary parts are attached
content-encodingzstd or gzip (absent when compression is off). Applies to the whole body. Large bodies are compressed as several independent frames or members that are concatenated; a standard decoder reads them as one stream.
acceptapplication/json

The address comes from the key: an environment key irk_acme_… belongs to the organization acme and is sent to https://acme.api.inspector.rest. The records are stored in the environment the key belongs to.

Multipart batches

When binary bodies are captured, the request is multipart/form-data. The first part is named batch (application/json) and holds the envelope below. Every further part holds the raw bytes of one binary body and is named by the part field of its body descriptor (b1, b2, …). Part names are unique within a batch and keep their names when a batch is split or sent again.

Response

200 OKJSON
{ "accepted": 2, "rejected": [ { "index": 1, "reason": "invalid record" } ] }

Every record is validated on its own. accepted is the number of stored records. rejected lists the records that were not stored, by position in records. A batch with an invalid record is still stored for the valid ones.

Status codes

StatusMeaningWhat the SDKs do
200Batch handled. See accepted and rejected.Done. Rejected records are counted, not retried.
401 invalid_keyThe ingest key is invalid or revoked.Disables itself and warns once.
403 organization_suspendedThe organization is suspended.Pauses like on quota_exceeded.
413 payload_too_largeThe batch is too large.Splits the batch in halves and sends them again.
415The compression is not supported.Switches from zstd to gzip.
429 quota_exceeded + Retry-After: 60The monthly request limit of the plan is reached.Stops capturing and sends an empty batch about once a minute. Capturing resumes when the empty batch is accepted.
503 disk_full + Retry-AfterThe storage server is almost out of disk space.Keeps the data in its queue and waits.
other 5xx, 408, network errorsTemporary failure.Keeps the batch and retries with exponential backoff.

Error responses have the form { "error": { "code", "message", "hint" } }. See Error codes.

Idempotent writes

  • A record with the same request_id replaces the previous one, except that an in_progress record never replaces a complete one. Batches may arrive out of order.
  • A batch that is sent again after a timeout or a 5xx keeps its batch_id, so the server can discard a duplicate within a short window.
  • Status, outcome and error phase of a request are derived from its highest numbered attempt.
  • Sorting uses started_at. Retention and paging use the server’s receive time. The clock skew of the client is corrected with sent_at.

Schema

Batch envelope

The JSON body of the request (the batch part in multipart requests).

FieldTypeRequiredDescription
v1yesrequiredWire format version.
sdkobjectyesrequired
sent_atnumberyesrequiredClient wall clock (epoch ms) when this send attempt was assembled. The server compares it with its own receive time to correct clock skew. Re-sent batches carry a fresh value.
servicestring | nullnooptionalOptional service name set in the SDK config.
instance_idstringyesrequiredRandom id of the SDK instance (one per process/inspector).
seqinteger (min 1)yesrequiredBatch sequence number within the instance, starting at 1.
batch_idstringyesrequired&lt;instance_id&gt;:&lt;seq&gt;. A re-sent batch (retry after timeout, 5xx, 503) keeps its batch_id, so the server can discard duplicates inside a short window.
droppedobjectyesrequiredWhat the SDK discarded since the previous batch that carried counts. Counts travel with exactly one batch (the same batch_id when re-sent).
recordsarray of objectyesrequiredOne record per request. Empty for the quota probe.

SDK info

The sdk field of the envelope.

FieldTypeRequiredDescription
namestringyesrequiredinspector-rest-sdk-node, inspector-rest-sdk-php.
versionstringyesrequired
runtimestring | nullnooptionalFree-form runtime description, e.g. node/24.1.0.

Dropped counters

The dropped field of the envelope. The counts travel with exactly one batch (the same one when it is sent again). The app shows them, for example as “N bodies skipped because of load”.

FieldTypeRequiredDescription
recordsintegeryesrequiredWhole records discarded (queue overflow, load budget, permanently rejected batches).
text_bodiesintegeryesrequiredText bodies omitted because of the load budget.
binary_bodiesintegeryesrequiredBinary bodies not uploaded because of the load budget or size limit (not counted when capture_binary is off).

Record

One request with all of its attempts.

FieldTypeRequiredDescription
request_idstringyesrequired
started_atnumberyesrequiredRequest start, epoch ms on the client clock (sub-millisecond fraction allowed).
in_progressbooleanyesrequiredtrue: sent while the request is still running (after 2 s) or at close; outcome and duration_ms are null.
methodstringyesrequired
urlstringyesrequired
labelsobjectyesrequiredFully resolved labels of the request (runtime < config < context < request). Keys and values are non-empty strings.
outcome"ok" | "error" | nullyesrequired
duration_msnumber | nullyesrequiredTotal duration measured with a monotonic clock.
errorobject | nullnooptionalRequest-level error (for example domain errors that belong to no attempt, or the final error given at settle time).
attemptsarray of objectyesrequiredAscending by attempt number. The server derives status, outcome and error phase from the highest numbered attempt.

Attempt

One try of a request. A request has one attempt unless the HTTP client retried it.

FieldTypeRequiredDescription
attemptinteger (min 1)yesrequired
offset_msnumbernooptionalStart of the attempt relative to the record’s started_at.
methodstringnooptionalOnly when different from the record’s method.
urlstringnooptionalOnly when different from the record’s url.
requestobject | nullnooptional
responseobject | nullnooptional
retryobject | nullnooptional
errorobject | nullnooptional

Request part

The request field of an attempt.

FieldTypeRequiredDescription
headersobjectnooptionalHeader names are lower-case. Repeated headers (set-cookie) are arrays.
proxy_urlstring | nullnooptional
bodyobject | nullnooptional

Response part

The response field of an attempt. It is null when no response was received.

FieldTypeRequiredDescription
statusintegernooptional
headersobjectnooptionalHeader names are lower-case. Repeated headers (set-cookie) are arrays.
duration_msnumber | nullnooptionalTime to response headers.
read_msnumber | nullnooptionalTime spent reading the body.
parse_okboolean | nullnooptionalfalse when the engine could not parse the body (raw body is kept).
bodyobject | nullnooptional

Retry

The retry field of an attempt: the decision that was made after this attempt.

FieldTypeRequiredDescription
policyanynooptionalRetry policy name or description.
stagestring | nullnooptional
delay_msnumber | nullnooptional
exhaustedboolean | nullnooptional

Error

Errors appear on records and attempts. Header names are always lower case; repeated headers such as set-cookie are arrays.

FieldTypeRequiredDescription
phasestring | nullnooptionalnetwork, http, parse, domain, or an engine-specific phase.
namestring | nullnooptionalError class name; HTTP status errors are named HttpError.
messagestring | nullnooptional
codestring | number | nullnooptional
stackstring | nullnooptional
request_idstring | nullnooptional
statusinteger | nullnooptionalHTTP status for HttpError.
detailsanynooptionalFree-form data returned by the error_details hook.
causeobjectnooptionalerror.cause chain (depth-limited).
errorsarray of objectnooptionalMembers of an AggregateError.

Body descriptor

Describes a request or response body. A body is binary when its content type says so (images, audio, video, archives, application/octet-stream and so on) or, when the type does not decide, when its bytes are not valid UTF-8.

FieldTypeRequiredDescription
encoding"utf8" | "part" | "none"yesrequiredutf8: the body text is inline in text. part: raw bytes travel in the multipart part named part. none: only metadata (see omitted).
sizeinteger | nullnooptionalSize of the original body in bytes (before truncation), null when unknown (streams).
content_typestring | nullnooptional
textstringnooptionalBody text (encoding utf8). Possibly truncated, see truncated.
truncatedbooleannooptionaltext was cut at max_body_bytes (UTF-8 character boundary).
binarybooleannooptionalDetected as binary (content type or invalid UTF-8).
partstringnooptionalMultipart part name (encoding part).
omitted"binary" | "load" | "too_large" | "stream"nooptionalWhy no content is carried (encoding none). binary: binary capture is off. load: dropped by the load budget. too_large: above max_binary_bytes. stream: body not readable (stream, FormData).

Labels and headers

  • labels is an object whose keys and values are non-empty strings. It contains the fully resolved labels of the request. See Labels.
  • headers is an object with lower-case header names. A header with several values is an array of strings.

Body encodings

encodingMeaning
utf8The body text is inline in text. size is the original size in bytes. truncated is true when text was cut at max_body_bytes.
partThe raw bytes are in the multipart part named by part. binary is true.
noneMetadata only. omitted says why: binary (binary capture is off), load (dropped by the load budget), too_large (above max_binary_bytes) or stream (the body could not be read, for example a stream or FormData).

Examples

Minimal batch

One successful request.

JSON
{
  "v": 1,
  "sdk": {
    "name": "inspector-rest-sdk-php",
    "version": "0.0.1"
  },
  "sent_at": 1790000000000,
  "instance_id": "c1a0e2f4-0000-4000-8000-000000000001",
  "seq": 1,
  "batch_id": "c1a0e2f4-0000-4000-8000-000000000001:1",
  "dropped": {
    "records": 0,
    "text_bodies": 0,
    "binary_bodies": 0
  },
  "records": [
    {
      "request_id": "5a1d2a54-7a9e-4b4e-8d0d-0d5c7f6a1001",
      "started_at": 1789999999000.125,
      "in_progress": false,
      "method": "GET",
      "url": "https://api.example.com/v1/items?limit=10",
      "labels": {},
      "outcome": "ok",
      "duration_ms": 41.5,
      "attempts": [
        {
          "attempt": 1,
          "offset_ms": 0,
          "request": {
            "headers": {
              "accept": "application/json"
            },
            "proxy_url": null,
            "body": null
          },
          "response": {
            "status": 200,
            "headers": {
              "content-type": "application/json"
            },
            "duration_ms": 38.2,
            "read_ms": 1.1,
            "parse_ok": true,
            "body": {
              "encoding": "utf8",
              "size": 11,
              "content_type": "application/json",
              "text": "{\"ok\":true}"
            }
          }
        }
      ]
    }
  ]
}

Quota probe

When the monthly limit is reached the SDK sends batches without records to find out when recording is possible again.

JSON
{
  "v": 1,
  "sdk": {
    "name": "inspector-rest-sdk-node",
    "version": "0.0.1",
    "runtime": "node/24.1.0"
  },
  "sent_at": 1790000000000,
  "service": null,
  "instance_id": "0b7f4c1e-52c1-4a7e-9f4f-1d9f5a0c2c11",
  "seq": 3,
  "batch_id": "0b7f4c1e-52c1-4a7e-9f4f-1d9f5a0c2c11:3",
  "dropped": {
    "records": 0,
    "text_bodies": 0,
    "binary_bodies": 0
  },
  "records": []
}

Full batch

Two records: a failed request with retries, a multipart binary body, an omitted body and an error chain, and a request that was still in progress.

JSON
{
  "v": 1,
  "sdk": {
    "name": "inspector-rest-sdk-node",
    "version": "0.0.1",
    "runtime": "node/24.1.0"
  },
  "sent_at": 1790000005000,
  "service": "billing",
  "instance_id": "0b7f4c1e-52c1-4a7e-9f4f-1d9f5a0c2c11",
  "seq": 12,
  "batch_id": "0b7f4c1e-52c1-4a7e-9f4f-1d9f5a0c2c11:12",
  "dropped": {
    "records": 4,
    "text_bodies": 17,
    "binary_bodies": 2
  },
  "records": [
    {
      "request_id": "5a1d2a54-7a9e-4b4e-8d0d-0d5c7f6a2001",
      "started_at": 1789999990123.456,
      "in_progress": false,
      "method": "POST",
      "url": "https://api.example.com/v1/charges",
      "labels": {
        "env": "production",
        "server_host": "web-1",
        "app_package": "billing",
        "app_commit": "a1b2c3d4e5f6",
        "op": "charge"
      },
      "outcome": "error",
      "duration_ms": 1530.25,
      "error": {
        "phase": "domain",
        "name": "Error",
        "message": "card declined",
        "code": "card_declined",
        "details": {
          "decline_code": "insufficient_funds"
        }
      },
      "attempts": [
        {
          "attempt": 1,
          "offset_ms": 0,
          "request": {
            "headers": {
              "authorization": "Bearer abc",
              "content-type": "application/json",
              "set-cookie": [
                "a=1",
                "b=2"
              ]
            },
            "proxy_url": "http://proxy.local:8080",
            "body": {
              "encoding": "utf8",
              "size": 27,
              "content_type": "application/json",
              "text": "{\"amount\":1200,\"cur\":\"usd\"}"
            }
          },
          "response": {
            "status": 503,
            "headers": {
              "retry-after": "1"
            },
            "duration_ms": 210.5,
            "read_ms": 0.4,
            "parse_ok": true,
            "body": {
              "encoding": "utf8",
              "size": 3,
              "text": "oops",
              "truncated": true
            }
          },
          "retry": {
            "policy": {
              "name": "backoff",
              "max": 3
            },
            "stage": "http",
            "delay_ms": 1000,
            "exhausted": false
          },
          "error": {
            "phase": "http",
            "name": "HttpError",
            "message": "HTTP 503 Service Unavailable",
            "status": 503
          }
        },
        {
          "attempt": 2,
          "offset_ms": 1210.75,
          "url": "https://api.example.com/v1/charges",
          "request": {
            "headers": {},
            "proxy_url": null,
            "body": {
              "encoding": "part",
              "size": 2048,
              "content_type": "image/png",
              "binary": true,
              "part": "b1"
            }
          },
          "response": {
            "status": 200,
            "headers": {
              "content-type": "image/png"
            },
            "duration_ms": 300,
            "read_ms": 12,
            "parse_ok": null,
            "body": {
              "encoding": "none",
              "size": 5000000,
              "content_type": "image/png",
              "binary": true,
              "omitted": "too_large"
            }
          },
          "error": {
            "phase": "network",
            "name": "AggregateError",
            "message": "all failed",
            "stack": "AggregateError: all failed\n    at x (/app/x.js:1:1)",
            "errors": [
              {
                "name": "Error",
                "message": "a",
                "cause": {
                  "name": "Error",
                  "message": "root cause",
                  "code": "ECONNRESET"
                }
              }
            ]
          }
        }
      ]
    },
    {
      "request_id": "5a1d2a54-7a9e-4b4e-8d0d-0d5c7f6a2002",
      "started_at": 1789999991000,
      "in_progress": true,
      "method": "GET",
      "url": "https://api.example.com/v1/slow",
      "labels": {
        "env": "production"
      },
      "outcome": null,
      "duration_ms": null,
      "attempts": [
        {
          "attempt": 1,
          "offset_ms": 0,
          "request": {
            "headers": {
              "accept": "*/*"
            }
          }
        }
      ]
    }
  ]
}