Rules

Create a rule

Create a rule that evaluates a CEL condition against incoming events and executes actions when matched. Omit rule_set_id to use the default set. Omit position to append, or use first/last/before/after placement. ACTIVE and SUSPENDED rules retain unique positions 1..N. The response includes the resulting rule_configuration_version.

post/v1/rules

Request

  • Base URL: https://api.scrip.dev
  • URL: https://api.scrip.dev/v1/rules
  • Auth: HTTP bearer

Headers

Idempotency-Keystring

A key you choose to make this request safe to retry: 1 to 255 printable ASCII characters. Send the same key with the same request to get the first response again, marked Idempotent-Replayed: true. Routes that return a secret once, and claim links, do not replay a response. Event ingest uses the key as the event's identity.

Request body

active_fromstring date-time

Start of the rule's active window (RFC 3339). Null means immediately active. Checked against the event's event_timestamp, inclusive.

active_tostring date-time

End of the rule's active window (RFC 3339). Null means no end date. Checked against the event's event_timestamp, exclusive.

conditionstring required

CEL expression that determines when the rule fires

descriptionstring

Human-readable summary of what this rule does

namestring required

The name people see for the rule.

program_idstring uuid required

Program to attach this rule to

rule_set_idstring uuid

Rule set to attach this rule to. Omit to use the program's default set.

status'ACTIVE' | 'SUSPENDED'

Initial lifecycle status (ACTIVE or SUSPENDED). Defaults to ACTIVE.

stop_after_matchboolean

When true, no subsequent rules in this set evaluate after this one matches; other sets continue

Response

Rule created

actionsobject[]

Actions to execute when the condition matches

active_fromstring date-time

Start of the rule's active window (RFC 3339, null if always active). Checked against the event's event_timestamp, inclusive.

active_tostring date-time

End of the rule's active window (RFC 3339, null if no end date). Checked against the event's event_timestamp, exclusive.

conditionstring

CEL expression that determines when the rule fires

created_atstring date-time

When this rule was created (RFC 3339)

deleted_atstring date-time

When this rule was archived (null if not archived)

descriptionstring

Human-readable summary of what this rule does

idstring uuid

Unique identifier for this rule

namestring

The name people see for the rule.

orderinteger

Evaluation position within the containing rule set (lower = first; ACTIVE and SUSPENDED rules occupy unique positions)

program_idstring uuid

Program this rule belongs to

rule_configuration_versioninteger

Resulting program rule-configuration revision. Present on mutation responses.

rule_set_idstring uuid

Rule set that contains this rule and scopes its order and stop_after_match behavior

status'ACTIVE' | 'SUSPENDED' | 'ARCHIVED'

The rule's lifecycle state.

stop_after_matchboolean

When true, no subsequent rules in this set evaluate after this one matches; other sets continue

updated_atstring date-time

When this rule was last modified (RFC 3339)

Example response

{
  "actions": [
    {
      "amount": "${{ event.amount * 10 }}",
      "asset_id": "a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02",
      "type": "CREDIT"
    }
  ],
  "active_from": "2027-01-01T00:00:00Z",
  "active_to": "2027-12-31T23:59:59Z",
  "budgets": [
    {
      "asset_id": "a3bb189e-8bf9-4c8b-9be0-6b5d2f4e7a02",
      "consumed": "4500.00",
      "cron_expression": "0 0 1 * *",
      "interval": "720h",
      "limit": "10000.00",
      "next_reset_at": "2027-12-31T23:59:59Z",
      "schedule_type": "CRON",
      "scope": "PROGRAM"
    }
  ],
  "condition": "event.type == 'purchase' && event.amount > 0",
  "created_at": "2027-01-15T10:30:00Z",
  "deleted_at": "2027-01-15T10:30:00Z",
  "description": "Awards 10 points per dollar spent",
  "id": "c9f0f895-fb98-4b39-9f86-1e5a0d3e2b03",
  "name": "Purchase Reward",
  "order": 1,
  "program_id": "8f14e45f-ceea-4e70-9df8-2a7d1b3c9f01",
  "rule_configuration_version": 4,
  "rule_set_id": "d4735e3a-265e-4f16-b1a5-4c8e9d6f0a04",
  "status": "ACTIVE",
  "updated_at": "2027-01-15T10:30:00Z",
  "warnings": [
    {
      "code": "unknown_state_key",
      "key": "purchaseCnt",
      "kind": "counter",
      "message": "unknown counter \"purchaseCnt\" on participant: no rule in this program writes it; did you mean \"purchase_count\"?",
      "scope": "participant",
      "suggestion": "purchase_count"
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.