{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/knoxcall/json-schema/knoxcall-egress-observation-batch-schema.json",
  "title": "EgressObservationBatch",
  "description": "POST /wrap/egress-observations request body.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/knoxcall-wrap-credentials-api-openapi.yml#/components/schemas/EgressObservationBatch",
  "type": "object",
  "required": [
    "sdk",
    "observations"
  ],
  "properties": {
    "sdk": {
      "type": "string",
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]*/[A-Za-z0-9][A-Za-z0-9._+-]*$",
      "description": "The reporting SDK and its version, `<name>/<version>`."
    },
    "observations": {
      "type": "array",
      "maxItems": 200,
      "description": "At most 200 per request; more is a `413`.",
      "items": {
        "$ref": "#/$defs/EgressObservation"
      }
    }
  },
  "$defs": {
    "EgressObservation": {
      "type": "object",
      "description": "One (host, first path segment, method, credential header NAME) key the SDK's interceptor saw a credential leave for without interception, with how often and when. Never a credential value, a full path, a query string or a body — the server drops an entry carrying any of those.",
      "required": [
        "host",
        "first_segment",
        "method",
        "header_name",
        "count",
        "first_seen",
        "last_seen"
      ],
      "properties": {
        "host": {
          "type": "string",
          "maxLength": 253,
          "description": "Bare DNS hostname. The server lower-cases it, strips a trailing dot, converts an IDN to punycode and drops a port — the same normalisation the intercept manifest applies to a Route's target. A scheme, path, query or userinfo is refused (`invalid_host`); an IP literal (`ip_literal`) and any KnoxCall host (`own_host`) are dropped."
        },
        "first_segment": {
          "type": "string",
          "pattern": "^/[A-Za-z0-9._~!$&'()*+,;=:@%-]{0,255}$",
          "description": "`/` or `/<one segment>` — no deeper path, no query string."
        },
        "method": {
          "type": "string",
          "enum": [
            "GET",
            "HEAD",
            "POST",
            "PUT",
            "PATCH",
            "DELETE",
            "OPTIONS",
            "CONNECT",
            "TRACE"
          ],
          "description": "Upper-case, exactly."
        },
        "header_name": {
          "type": "string",
          "maxLength": 64,
          "pattern": "^[a-z0-9][a-z0-9_-]*$",
          "description": "Lower-case NAME of the header the credential travelled in, from the shared allowlist (`authorization`, `proxy-authorization`, `x-api-key`, `api-key`, `apikey`, `x-apikey`, `x-auth-token`, `x-access-token`, `x-token`, `token`, `x-secret`, `x-secret-key`, `x-client-secret`, `ocp-apim-subscription-key`, `x-goog-api-key`, `x-amz-security-token`, `x-shopify-access-token`, `klaviyo-api-key`, `x-hubspot-api-key`) or any name ending in `-api-key`, `-token`, `-secret` or `-auth`. Anything else is dropped (`invalid_header_name`). The value is never sent."
        },
        "count": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000,
          "description": "Calls observed for this key in the reported interval."
        },
        "first_seen": {
          "type": "string",
          "format": "date-time",
          "description": "ISO-8601 with an offset. Older than 7 days is dropped (`stale`)."
        },
        "last_seen": {
          "type": "string",
          "format": "date-time",
          "description": "ISO-8601 with an offset, not before `first_seen`, not more than 5 minutes ahead of the server clock (`future`). Its UTC calendar day is the row the entry merges into."
        }
      }
    }
  }
}