Create or replace one event's contract
Upserts the contract for one event name. Replaces the property set: a key omitted from properties stops being checked. Merge is not offered because it has no way to express "stop requiring this field".
A bare type string is shorthand for { "type": <t>, "required": true }. Required is the default because a contract whose every property is optional cannot fail, and is indistinguishable from no contract at all.
min_daily_events follows the same replace rule: omit it and the volume check is off.
Agency key (ak_) required.
curl -X PUT "https://mythic-analytics.gulp.workers.dev/client/v1/contracts?location_id=example_string" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"event": "order_completed",
"properties": {
"value": "number",
"currency": "string",
"coupon_code": {
"type": "string",
"required": false
}
},
"note": "Checkout v3 — value is gross, pre-refund",
"min_daily_events": 100
}'
import requests
import json
url = "https://mythic-analytics.gulp.workers.dev/client/v1/contracts?location_id=example_string"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
"event": "order_completed",
"properties": {
"value": "number",
"currency": "string",
"coupon_code": {
"type": "string",
"required": false
}
},
"note": "Checkout v3 — value is gross, pre-refund",
"min_daily_events": 100
}
response = requests.put(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://mythic-analytics.gulp.workers.dev/client/v1/contracts?location_id=example_string", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
},
body: JSON.stringify({
"event": "order_completed",
"properties": {
"value": "number",
"currency": "string",
"coupon_code": {
"type": "string",
"required": false
}
},
"note": "Checkout v3 — value is gross, pre-refund",
"min_daily_events": 100
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"event": "order_completed",
"properties": {
"value": "number",
"currency": "string",
"coupon_code": {
"type": "string",
"required": false
}
},
"note": "Checkout v3 — value is gross, pre-refund",
"min_daily_events": 100
}`)
req, err := http.NewRequest("PUT", "https://mythic-analytics.gulp.workers.dev/client/v1/contracts?location_id=example_string", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://mythic-analytics.gulp.workers.dev/client/v1/contracts?location_id=example_string')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.body = '{
"event": "order_completed",
"properties": {
"value": "number",
"currency": "string",
"coupon_code": {
"type": "string",
"required": false
}
},
"note": "Checkout v3 — value is gross, pre-refund",
"min_daily_events": 100
}'
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"event": "order_completed",
"properties": {},
"note": "example_string",
"min_daily_events": 100,
"created_at": "2024-12-25T10:00:00Z",
"updated_at": "2024-12-25T10:00:00Z"
}
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Forbidden",
"message": "You don't have permission to access this resource",
"code": 403
}
/client/v1/contracts
Target server for requests. Edit to use your own host.
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.
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.Location to scope to. Required for ak_ keys (or send the X-Location-Id header); ignored for sk_.
The media type of the request body
Event name the contract applies to.
Map of property key to type. Value is either a type string (required) or { type, required }. Keys cannot be empty.
Free text — where the contract came from. Echoed back on read.
Declared minimum events per day for this event name. Below it, the report adds a low_volume violation. null or omitted means the check is off.
Compared against the unsampled reference count and only over an exact whole-day window (pass both date_from and date_to) — a volume threshold checked against a sampled scan, or against the fuzzy default window, fires on healthy traffic. When either is missing the check is skipped and says so under the event's warnings, never as a violation.
This is what makes alerting possible without a volume-baseline engine: the threshold is declared rather than inferred.
Request Preview
Response
Response will appear here after sending the request
Authentication
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 to scope to. Required for ak_ keys (or send the X-Location-Id header); ignored for sk_.
Body
Map of property key to type. Value is either a type string (required) or \\{ type, required \\}. Keys cannot be empty.
{"value":"number","currency":"string","coupon_code":{"type":"string","required":false}}Free text — where the contract came from. Echoed back on read.
Checkout v3 — value is gross, pre-refundDeclared minimum events per day for this event name. Below it, the report adds a low_volume violation. null or omitted means the check is off.
Compared against the unsampled reference count and only over an exact whole-day window (pass both date_from and date_to) — a volume threshold checked against a sampled scan, or against the fuzzy default window, fires on healthy traffic. When either is missing the check is skipped and says so under the event's warnings, never as a violation.
This is what makes alerting possible without a volume-baseline engine: the threshold is declared rather than inferred.
100