Skip to content

Create a rule

POST
/conditions/rules
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).

x-tenant-id
required
string format: uuid

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.

x-idempotency-key
string
>= 1 characters

When present, a retry returns the row already made under this key.

Media typeapplication/json
object
offering_variant_id
string format: uuid
nullable
name
required
string
>= 1 characters
window
required

ride_hours = the departure’s local start hour through its last minute; day = 07–19 local.

string
Allowed values: ride_hours day
metric
required
string
Allowed values: pop precip_in temp_f feels_f wind_mph gust_mph thunder vis_mi wave_ft uv
op
required
string
Allowed values: gt gte lt lte eq
threshold
required
number
fraction
number
0 <= 1
outcome
required

Ordered by precedence, lowest first.

string
Allowed values: watch guest_may_cancel operator_call
copy_key
string
nullable
enabled
boolean
default: true

Idempotent replay — the rule already made under this key.

Media typeapplication/json
object
id
required
string format: uuid
offering_variant_id

Null = every variant.

string format: uuid
nullable
name
required
string
window
required

ride_hours = the departure’s local start hour through its last minute; day = 07–19 local.

string
Allowed values: ride_hours day
metric
required
string
Allowed values: pop precip_in temp_f feels_f wind_mph gust_mph thunder vis_mi wave_ft uv
op
required
string
Allowed values: gt gte lt lte eq
threshold
required
number
fraction
required

Share of the window’s hours with data that must satisfy the test; 0 = any single hour.

number
<= 1
outcome
required

Ordered by precedence, lowest first.

string
Allowed values: watch guest_may_cancel operator_call
copy_key
string
nullable
enabled
required
boolean
created_at_ms
required
integer format: int64

Example

{
"window": "ride_hours",
"metric": "pop",
"op": "gt",
"outcome": "watch"
}

Created.

Media typeapplication/json
object
id
required
string format: uuid
offering_variant_id

Null = every variant.

string format: uuid
nullable
name
required
string
window
required

ride_hours = the departure’s local start hour through its last minute; day = 07–19 local.

string
Allowed values: ride_hours day
metric
required
string
Allowed values: pop precip_in temp_f feels_f wind_mph gust_mph thunder vis_mi wave_ft uv
op
required
string
Allowed values: gt gte lt lte eq
threshold
required
number
fraction
required

Share of the window’s hours with data that must satisfy the test; 0 = any single hour.

number
<= 1
outcome
required

Ordered by precedence, lowest first.

string
Allowed values: watch guest_may_cancel operator_call
copy_key
string
nullable
enabled
required
boolean
created_at_ms
required
integer format: int64

Example

{
"window": "ride_hours",
"metric": "pop",
"op": "gt",
"outcome": "watch"
}

Missing or invalid session bearer token

Media typeapplication/json
object
reason
required

Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).

string

Example

{
"reason": "sold_out"
}

The session’s effect authority does not cover this operation

Media typeapplication/json
object
reason
required

Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).

string

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)

Media typeapplication/json
object
reason
required

Stable, machine-readable reason code (e.g. “sold_out”, “processor_not_configured”, “rail_refused”).

string

Example

{
"reason": "sold_out"
}