ContractsScaffold a contract from live traffic

Scaffold a contract from live traffic

Infers a contract for one event from the window. The response body is PUT-able to /client/v1/contracts as-is.

Rules: type is the dominant observed JSON type; required is true when the key is present on at least 99% of events in the window; internal $-prefixed properties are excluded unless include_internal=1; keys that are always null or under 1% coverage are returned in skipped with a reason, so a dead field does not look like a missing one.

Review required before storing — inference from one window is a starting point, not a decision.

curl -X GET "https://mythic-analytics.gulp.workers.dev/client/v1/contracts/suggest?location_id=example_string&event=order_completed&date_from=2026-07-27&date_to=2026-08-03&sample=10&include_internal=0" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
{
  "success": true,
  "data": {
    "event": "order_completed",
    "properties": {},
    "based_on": {
      "total_events": 1000,
      "window": {
        "date_from": "last 1 day",
        "date_to": "now",
        "sample": {
          "keeping": "1/10 of events",
          "note": "example_string"
        }
      }
    },
    "skipped": [
      {
        "key": "legacy_flag",
        "coverage": 0.04,
        "reason": "always_null"
      }
    ],
    "note": "example_string"
  }
}
GET
/client/v1/contracts/suggest
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
Required

Event to infer a contract for.

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
query
include_internalstring

Set to 1 to include Mythic's own $-prefixed properties.

Options: 0, 1
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
Required

Event to infer a contract for.

Example:
order_completed
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
include_internalstring

Set to 1 to include Mythic's own $-prefixed properties.

Allowed values:01

Responses

successboolean
dataobject