Skip to main content
POST
Create a rule as a draft

Authorizations

Authorization
string
header
required

A project key (Developers → API keys). Keep it on your server, not in an app.

Headers

traceparent
string

W3C Trace Context; joins your trace to ours

Idempotency-Key
string
required

A retry with the same key and body returns the first response

Required string length: 1 - 255

Body

application/json
name
string
required

What people call the rule, 1 to 80 characters

Required string length: 1 - 80
when
object
required

What starts the rule: an event, a schedule, or a unit's balance reaching a number or crossing multiples of it. Give one

do
object[]
required

What the rule changes: units. Needs at least one action unless the rule has effects, which are not available yet

Maximum array length: 10

One change to a unit. It has exactly one of add, remove, reset or streak

key
string

The rule's key, which other rules and Activity call it by: lowercase letters, digits and dashes, starting with a letter, up to 64 characters. Defaults to a slug of the name

Pattern: ^[a-z][a-z0-9-]{0,63}$
if
object[]

Conditions that must all hold, up to 20. Leave out for none

Maximum array length: 20

One IF clause. It has exactly one key, and every clause in a list must hold

limit
object[]

How often the rule may apply to one person, up to 5. Leave out for no limit

Maximum array length: 5
budget
object[]

Caps on what the rule gives everyone, not one person (limit does that). Leave out for none

Maximum array length: 5
modify
object[]

Changes to what the rule gives, for some people, in order: VIPs get double. Leave out for none

Maximum array length: 5
effects
object[]

Not available yet. What the rule would do in a chat platform besides changing units: post in a channel or message the person. A key or agent that saves a rule with effects gets approval_required. Leave out for none

Maximum array length: 3

Response

Create a rule as a draft

id
string
required

A rule ID, starting with rule_.

key
string
required

The rule's key, which other rules and Activity call it by: lowercase letters, digits and dashes, starting with a letter, up to 64 characters

Pattern: ^[a-z][a-z0-9-]{0,63}$
name
string
required

What people call the rule, 1 to 80 characters

status
enum<string>
required

draft: saved, never taken live. live: running. paused: stopped, and runs again when resumed

Available options:
draft,
live,
paused
version
integer
required

The newest version

live_version
integer | null
required

The version running now; null if the rule has never been live

definition
object
required

What the newest version does: when it starts, the conditions, limits and changes