ContractsCheck stored contracts against live traffic

Check stored contracts against live traffic

Diffs every stored contract (or one, with event) against the events in the window and returns the violations, worst first.

Three violation kinds, kept separate because they have three different fixes: missing_required (key absent), null_value (key present but null), type_mismatch (key present with a type other than the declared one). Keys observed but not declared are reported under undeclared and are never violations — a growing integration always has some.

A contract whose event had no traffic returns status: "no_data" with no violations and is counted in summary.events_no_data. An event that stopped firing must not read as "every field is missing". no_data always carries a no_data_reason telling you which of its three causes applies — a tracking outage, this event alone not firing, or sampling — because the fix is different for each. See the EventReport schema.

Every violation carries a samples link to GET /client/v1/contracts/violations's companion endpoint /client/v1/contracts/samples, pre-filled with this window: the actual offending events, with session_id and page URL.

Cost note: this reads raw events to get the denominator. The window defaults to 1 day; pass event to narrow it, and sample for wide windows on high-volume events.

curl -X GET "https://mythic-analytics.gulp.workers.dev/client/v1/contracts/violations?location_id=example_string&event=example_string&date_from=2026-07-27&date_to=2026-08-03&sample=10" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
{
  "success": true,
  "data": {
    "window": {
      "date_from": "last 1 day",
      "date_to": "now",
      "sample": {
        "keeping": "1/10 of events",
        "note": "example_string"
      }
    },
    "summary": {
      "contracts": 3,
      "events_ok": 1,
      "events_with_violations": 1,
      "events_no_data": 1,
      "total_violations": 2,
      "reference": {
        "location_events": 41320,
        "source": "client_event_summary (unsampled)",
        "warning": "example_string"
      }
    },
    "events": [
      {
        "event": "order_completed",
        "status": "ok",
        "total_events": 1000,
        "reference_events": 1000,
        "no_data_reason": "no_events_at_all",
        "detail": "example_string",
        "warnings": [
          "example_string"
        ],
        "properties": [
          {
            "key": "value",
            "expected_type": "number",
            "required": true,
            "present": 700,
            "absent": 200,
            "null_values": 100,
            "type_mismatches": 150,
            "coverage": 0.7,
            "observed_types": {}
          }
        ],
        "violations": [
          {
            "key": "value",
            "kind": "missing_required",
            "count": 200,
            "rate": 0.2,
            "detail": "`value` is absent on 200 of 1000 events",
            "samples": "/client/v1/contracts/samples?event=order_completed&key=value&kind=missing_required",
            "samples_note": "example_string"
          }
        ],
        "undeclared": [
          {
            "key": "shipping_tier",
            "observed_type": "string",
            "occurrences": 300,
            "coverage": 0.3
          }
        ]
      }
    ],
    "truncated": true,
    "warning": "example_string",
    "hint": "example_string"
  }
}
GET
/client/v1/contracts/violations
GET
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token
Bearer Tokenstring
Required

Agency key (ak_) or location secret key (sk_). Scoped keys (mcp_) are accepted too and need contracts:read or contracts:write. See Using an mcp_ key over HTTP.

Agency key (ak_) or location secret key (sk_). Scoped keys (mcp_) are accepted too and need contracts:read or contracts:write. See Using an mcp_ key over HTTP.
query
location_idstring

Location to scope to. Required for ak_ keys (or send the X-Location-Id header); ignored for sk_.

query
eventstring

Check only this event's contract. Substantially cheaper than checking all.

query
date_fromstring

Start of the window, ISO 8601 date or timestamp. Defaults to 1 day ago.

query
date_tostring

End of the window (inclusive day), ISO 8601. Defaults to now.

query
sampleinteger

Keep a deterministic 1/N of events. Rates and coverage stay unbiased; counts become counts of the sample and are not scaled up. Use for wide windows on high-volume events — sample=10 handles 7 days of a 300k-event event name.

Min: 1 • Max: 1000
Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. Agency key (ak_) or location secret key (sk_). Scoped keys (mcp_) are accepted too and need contracts:read or contracts:write. See Using an mcp_ key over HTTP.

Query Parameters

location_idstring

Location to scope to. Required for ak_ keys (or send the X-Location-Id header); ignored for sk_.

eventstring

Check only this event's contract. Substantially cheaper than checking all.

date_fromstring

Start of the window, ISO 8601 date or timestamp. Defaults to 1 day ago.

Example:
2026-07-27
date_tostring

End of the window (inclusive day), ISO 8601. Defaults to now.

Example:
2026-08-03
sampleinteger

Keep a deterministic 1/N of events. Rates and coverage stay unbiased; counts become counts of the sample and are not scaled up. Use for wide windows on high-volume events — sample=10 handles 7 days of a 300k-event event name.

Example:
10

Responses

successboolean
dataobject