Create a rule
const url = 'https://quikstik-core.fly.dev/conditions/rules';const options = { method: 'POST', headers: { 'x-tenant-id': '2489E9AD-2EE2-8E00-8EC9-32D5F69181C0', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"offering_variant_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","name":"example","window":"ride_hours","metric":"pop","op":"gt","threshold":1,"fraction":0,"outcome":"watch","copy_key":"example","enabled":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://quikstik-core.fly.dev/conditions/rules \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'x-tenant-id: 2489E9AD-2EE2-8E00-8EC9-32D5F69181C0' \ --data '{ "offering_variant_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "window": "ride_hours", "metric": "pop", "op": "gt", "threshold": 1, "fraction": 0, "outcome": "watch", "copy_key": "example", "enabled": true }'Over window, metric op threshold for at least fraction of the window’s hours that have
data (0 = any single hour) fires outcome. Of the rules that fire, the highest-precedence
outcome wins: operator_call over guest_may_cancel over watch. Rules are disabled, never
deleted, so a state’s rule_id always resolves. With an x-idempotency-key, a retry
returns the rule already made (200).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Tenant identifier (UUID).
Authn/authz semantics are intentionally TBD for this contract slice; this header exists to keep the contract explicitly multi-tenant from day 0.
When present, a retry returns the row already made under this key.
Request Bodyrequired
Section titled “Request Bodyrequired”object
ride_hours = the departure’s local start hour through its last minute; day = 07–19 local.
Ordered by precedence, lowest first.
Responses
Section titled “Responses”Idempotent replay — the rule already made under this key.
object
Null = every variant.
ride_hours = the departure’s local start hour through its last minute; day = 07–19 local.
Share of the window’s hours with data that must satisfy the test; 0 = any single hour.
Ordered by precedence, lowest first.
Example
{ "window": "ride_hours", "metric": "pop", "op": "gt", "outcome": "watch"}Created.
object
Null = every variant.
ride_hours = the departure’s local start hour through its last minute; day = 07–19 local.
Share of the window’s hours with data that must satisfy the test; 0 = any single hour.
Ordered by precedence, lowest first.
Example
{ "window": "ride_hours", "metric": "pop", "op": "gt", "outcome": "watch"}Missing or invalid session bearer token
object
Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).
Example
{ "reason": "sold_out"}The session’s effect authority does not cover this operation
object
Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).
Example
{ "reason": "sold_out"}invalid_body (unknown field or vocabulary), name_required, threshold_not_finite or fraction_out_of_range.
No durable backend is wired for this operation (fail-closed)
object
Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).
Example
{ "reason": "sold_out"}