curl --request PATCH \
--url https://api.scrip.dev/v1/rules/{id} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data @- <<EOF
{
"actions": [
{
"allow_negative": false,
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"bucket": "AVAILABLE",
"delay": "24h",
"description": "Purchase reward",
"event_name": "check_status",
"expires_at": "365d",
"key": "purchase_count",
"level": "gold",
"matures_at": "30d",
"payload": {},
"reference_id": "${{ event.authorization_id }}",
"reset_after": "30d",
"tag": "VIP",
"target": {
"external_id": "${{ event.referrer_id }}",
"id": "550e8400-e29b-41d4-a716-446655440000",
"participant_id": "${{ event.recipient_id }}",
"type": "PARTICIPANT"
},
"tier": "status",
"type": "CREDIT",
"value": "1"
}
],
"active_from": "2024-01-01T00:00:00Z",
"active_to": "2024-12-31T23:59:59Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"cron_expression": "0 0 1 * *",
"interval": "30d",
"limit": "10000.00",
"schedule_type": "CRON"
}
],
"condition": "event.type == 'purchase'",
"description": "Updated description",
"name": "Updated Rule Name",
"order": 50,
"status": "SUSPENDED",
"stop_after_match": true
}
EOFimport requests
url = "https://api.scrip.dev/v1/rules/{id}"
payload = {
"actions": [
{
"allow_negative": False,
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"bucket": "AVAILABLE",
"delay": "24h",
"description": "Purchase reward",
"event_name": "check_status",
"expires_at": "365d",
"key": "purchase_count",
"level": "gold",
"matures_at": "30d",
"payload": {},
"reference_id": "${{ event.authorization_id }}",
"reset_after": "30d",
"tag": "VIP",
"target": {
"external_id": "${{ event.referrer_id }}",
"id": "550e8400-e29b-41d4-a716-446655440000",
"participant_id": "${{ event.recipient_id }}",
"type": "PARTICIPANT"
},
"tier": "status",
"type": "CREDIT",
"value": "1"
}
],
"active_from": "2024-01-01T00:00:00Z",
"active_to": "2024-12-31T23:59:59Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"cron_expression": "0 0 1 * *",
"interval": "30d",
"limit": "10000.00",
"schedule_type": "CRON"
}
],
"condition": "event.type == 'purchase'",
"description": "Updated description",
"name": "Updated Rule Name",
"order": 50,
"status": "SUSPENDED",
"stop_after_match": True
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
actions: [
{
allow_negative: false,
amount: '${{ event.amount * 0.03 }}',
asset_id: '550e8400-e29b-41d4-a716-446655440000',
bucket: 'AVAILABLE',
delay: '24h',
description: 'Purchase reward',
event_name: 'check_status',
expires_at: '365d',
key: 'purchase_count',
level: 'gold',
matures_at: '30d',
payload: {},
reference_id: '${{ event.authorization_id }}',
reset_after: '30d',
tag: 'VIP',
target: {
external_id: '${{ event.referrer_id }}',
id: '550e8400-e29b-41d4-a716-446655440000',
participant_id: '${{ event.recipient_id }}',
type: 'PARTICIPANT'
},
tier: 'status',
type: 'CREDIT',
value: '1'
}
],
active_from: '2024-01-01T00:00:00Z',
active_to: '2024-12-31T23:59:59Z',
budgets: [
{
asset_id: '550e8400-e29b-41d4-a716-446655440000',
cron_expression: '0 0 1 * *',
interval: '30d',
limit: '10000.00',
schedule_type: 'CRON'
}
],
condition: 'event.type == \'purchase\'',
description: 'Updated description',
name: 'Updated Rule Name',
order: 50,
status: 'SUSPENDED',
stop_after_match: true
})
};
fetch('https://api.scrip.dev/v1/rules/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.scrip.dev/v1/rules/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'actions' => [
[
'allow_negative' => false,
'amount' => '${{ event.amount * 0.03 }}',
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'bucket' => 'AVAILABLE',
'delay' => '24h',
'description' => 'Purchase reward',
'event_name' => 'check_status',
'expires_at' => '365d',
'key' => 'purchase_count',
'level' => 'gold',
'matures_at' => '30d',
'payload' => [
],
'reference_id' => '${{ event.authorization_id }}',
'reset_after' => '30d',
'tag' => 'VIP',
'target' => [
'external_id' => '${{ event.referrer_id }}',
'id' => '550e8400-e29b-41d4-a716-446655440000',
'participant_id' => '${{ event.recipient_id }}',
'type' => 'PARTICIPANT'
],
'tier' => 'status',
'type' => 'CREDIT',
'value' => '1'
]
],
'active_from' => '2024-01-01T00:00:00Z',
'active_to' => '2024-12-31T23:59:59Z',
'budgets' => [
[
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'cron_expression' => '0 0 1 * *',
'interval' => '30d',
'limit' => '10000.00',
'schedule_type' => 'CRON'
]
],
'condition' => 'event.type == \'purchase\'',
'description' => 'Updated description',
'name' => 'Updated Rule Name',
'order' => 50,
'status' => 'SUSPENDED',
'stop_after_match' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.scrip.dev/v1/rules/{id}"
payload := strings.NewReader("{\n \"actions\": [\n {\n \"allow_negative\": false,\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"bucket\": \"AVAILABLE\",\n \"delay\": \"24h\",\n \"description\": \"Purchase reward\",\n \"event_name\": \"check_status\",\n \"expires_at\": \"365d\",\n \"key\": \"purchase_count\",\n \"level\": \"gold\",\n \"matures_at\": \"30d\",\n \"payload\": {},\n \"reference_id\": \"${{ event.authorization_id }}\",\n \"reset_after\": \"30d\",\n \"tag\": \"VIP\",\n \"target\": {\n \"external_id\": \"${{ event.referrer_id }}\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"participant_id\": \"${{ event.recipient_id }}\",\n \"type\": \"PARTICIPANT\"\n },\n \"tier\": \"status\",\n \"type\": \"CREDIT\",\n \"value\": \"1\"\n }\n ],\n \"active_from\": \"2024-01-01T00:00:00Z\",\n \"active_to\": \"2024-12-31T23:59:59Z\",\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"cron_expression\": \"0 0 1 * *\",\n \"interval\": \"30d\",\n \"limit\": \"10000.00\",\n \"schedule_type\": \"CRON\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"description\": \"Updated description\",\n \"name\": \"Updated Rule Name\",\n \"order\": 50,\n \"status\": \"SUSPENDED\",\n \"stop_after_match\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.scrip.dev/v1/rules/{id}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"actions\": [\n {\n \"allow_negative\": false,\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"bucket\": \"AVAILABLE\",\n \"delay\": \"24h\",\n \"description\": \"Purchase reward\",\n \"event_name\": \"check_status\",\n \"expires_at\": \"365d\",\n \"key\": \"purchase_count\",\n \"level\": \"gold\",\n \"matures_at\": \"30d\",\n \"payload\": {},\n \"reference_id\": \"${{ event.authorization_id }}\",\n \"reset_after\": \"30d\",\n \"tag\": \"VIP\",\n \"target\": {\n \"external_id\": \"${{ event.referrer_id }}\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"participant_id\": \"${{ event.recipient_id }}\",\n \"type\": \"PARTICIPANT\"\n },\n \"tier\": \"status\",\n \"type\": \"CREDIT\",\n \"value\": \"1\"\n }\n ],\n \"active_from\": \"2024-01-01T00:00:00Z\",\n \"active_to\": \"2024-12-31T23:59:59Z\",\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"cron_expression\": \"0 0 1 * *\",\n \"interval\": \"30d\",\n \"limit\": \"10000.00\",\n \"schedule_type\": \"CRON\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"description\": \"Updated description\",\n \"name\": \"Updated Rule Name\",\n \"order\": 50,\n \"status\": \"SUSPENDED\",\n \"stop_after_match\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scrip.dev/v1/rules/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"actions\": [\n {\n \"allow_negative\": false,\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"bucket\": \"AVAILABLE\",\n \"delay\": \"24h\",\n \"description\": \"Purchase reward\",\n \"event_name\": \"check_status\",\n \"expires_at\": \"365d\",\n \"key\": \"purchase_count\",\n \"level\": \"gold\",\n \"matures_at\": \"30d\",\n \"payload\": {},\n \"reference_id\": \"${{ event.authorization_id }}\",\n \"reset_after\": \"30d\",\n \"tag\": \"VIP\",\n \"target\": {\n \"external_id\": \"${{ event.referrer_id }}\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"participant_id\": \"${{ event.recipient_id }}\",\n \"type\": \"PARTICIPANT\"\n },\n \"tier\": \"status\",\n \"type\": \"CREDIT\",\n \"value\": \"1\"\n }\n ],\n \"active_from\": \"2024-01-01T00:00:00Z\",\n \"active_to\": \"2024-12-31T23:59:59Z\",\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"cron_expression\": \"0 0 1 * *\",\n \"interval\": \"30d\",\n \"limit\": \"10000.00\",\n \"schedule_type\": \"CRON\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"description\": \"Updated description\",\n \"name\": \"Updated Rule Name\",\n \"order\": 50,\n \"status\": \"SUSPENDED\",\n \"stop_after_match\": true\n}"
response = http.request(request)
puts response.read_body{
"actions": [
{
"amount": "${{ event.amount * 10 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440002",
"type": "CREDIT"
}
],
"active_from": "2024-01-01T00:00:00Z",
"active_to": "2024-12-31T23:59:59Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"consumed": "4500.00",
"cron_expression": "0 0 1 * *",
"interval": "720h",
"limit": "10000.00",
"next_reset_at": "2026-03-01T00:00:00Z",
"schedule_type": "CRON"
}
],
"condition": "event.type == 'purchase' && event.amount > 0",
"created_at": "2024-01-15T10:30:00Z",
"deleted_at": "2024-06-01T00:00:00Z",
"description": "Awards 10 points per dollar spent",
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Purchase Reward",
"order": 100,
"program_id": "550e8400-e29b-41d4-a716-446655440001",
"status": "ACTIVE",
"stop_after_match": false,
"updated_at": "2024-01-15T10:30:00Z",
"warnings": [
{
"code": "unknown_state_key",
"key": "purchaseCnt",
"kind": "counter",
"message": "unknown counter \"purchaseCnt\" — no rule in this program writes it; did you mean \"purchase_count\"?",
"scope": "participant",
"suggestion": "purchase_count"
}
]
}{
"code": "bad_request",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Invalid request parameters"
}{
"code": "unauthorized",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Missing or invalid credentials"
}{
"code": "forbidden",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Insufficient permissions for this action"
}{
"code": "not_found",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Resource not found"
}{
"code": "conflict",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Resource already exists or state conflict"
}{
"code": "unsupported_media_type",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Content-Type must be application/json"
}{
"code": "internal_error",
"message": "An internal error occurred"
}Update a rule
Partially update a rule. At least one field must be provided, and actions when included must be non-empty.
curl --request PATCH \
--url https://api.scrip.dev/v1/rules/{id} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data @- <<EOF
{
"actions": [
{
"allow_negative": false,
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"bucket": "AVAILABLE",
"delay": "24h",
"description": "Purchase reward",
"event_name": "check_status",
"expires_at": "365d",
"key": "purchase_count",
"level": "gold",
"matures_at": "30d",
"payload": {},
"reference_id": "${{ event.authorization_id }}",
"reset_after": "30d",
"tag": "VIP",
"target": {
"external_id": "${{ event.referrer_id }}",
"id": "550e8400-e29b-41d4-a716-446655440000",
"participant_id": "${{ event.recipient_id }}",
"type": "PARTICIPANT"
},
"tier": "status",
"type": "CREDIT",
"value": "1"
}
],
"active_from": "2024-01-01T00:00:00Z",
"active_to": "2024-12-31T23:59:59Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"cron_expression": "0 0 1 * *",
"interval": "30d",
"limit": "10000.00",
"schedule_type": "CRON"
}
],
"condition": "event.type == 'purchase'",
"description": "Updated description",
"name": "Updated Rule Name",
"order": 50,
"status": "SUSPENDED",
"stop_after_match": true
}
EOFimport requests
url = "https://api.scrip.dev/v1/rules/{id}"
payload = {
"actions": [
{
"allow_negative": False,
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"bucket": "AVAILABLE",
"delay": "24h",
"description": "Purchase reward",
"event_name": "check_status",
"expires_at": "365d",
"key": "purchase_count",
"level": "gold",
"matures_at": "30d",
"payload": {},
"reference_id": "${{ event.authorization_id }}",
"reset_after": "30d",
"tag": "VIP",
"target": {
"external_id": "${{ event.referrer_id }}",
"id": "550e8400-e29b-41d4-a716-446655440000",
"participant_id": "${{ event.recipient_id }}",
"type": "PARTICIPANT"
},
"tier": "status",
"type": "CREDIT",
"value": "1"
}
],
"active_from": "2024-01-01T00:00:00Z",
"active_to": "2024-12-31T23:59:59Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"cron_expression": "0 0 1 * *",
"interval": "30d",
"limit": "10000.00",
"schedule_type": "CRON"
}
],
"condition": "event.type == 'purchase'",
"description": "Updated description",
"name": "Updated Rule Name",
"order": 50,
"status": "SUSPENDED",
"stop_after_match": True
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
actions: [
{
allow_negative: false,
amount: '${{ event.amount * 0.03 }}',
asset_id: '550e8400-e29b-41d4-a716-446655440000',
bucket: 'AVAILABLE',
delay: '24h',
description: 'Purchase reward',
event_name: 'check_status',
expires_at: '365d',
key: 'purchase_count',
level: 'gold',
matures_at: '30d',
payload: {},
reference_id: '${{ event.authorization_id }}',
reset_after: '30d',
tag: 'VIP',
target: {
external_id: '${{ event.referrer_id }}',
id: '550e8400-e29b-41d4-a716-446655440000',
participant_id: '${{ event.recipient_id }}',
type: 'PARTICIPANT'
},
tier: 'status',
type: 'CREDIT',
value: '1'
}
],
active_from: '2024-01-01T00:00:00Z',
active_to: '2024-12-31T23:59:59Z',
budgets: [
{
asset_id: '550e8400-e29b-41d4-a716-446655440000',
cron_expression: '0 0 1 * *',
interval: '30d',
limit: '10000.00',
schedule_type: 'CRON'
}
],
condition: 'event.type == \'purchase\'',
description: 'Updated description',
name: 'Updated Rule Name',
order: 50,
status: 'SUSPENDED',
stop_after_match: true
})
};
fetch('https://api.scrip.dev/v1/rules/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.scrip.dev/v1/rules/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'actions' => [
[
'allow_negative' => false,
'amount' => '${{ event.amount * 0.03 }}',
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'bucket' => 'AVAILABLE',
'delay' => '24h',
'description' => 'Purchase reward',
'event_name' => 'check_status',
'expires_at' => '365d',
'key' => 'purchase_count',
'level' => 'gold',
'matures_at' => '30d',
'payload' => [
],
'reference_id' => '${{ event.authorization_id }}',
'reset_after' => '30d',
'tag' => 'VIP',
'target' => [
'external_id' => '${{ event.referrer_id }}',
'id' => '550e8400-e29b-41d4-a716-446655440000',
'participant_id' => '${{ event.recipient_id }}',
'type' => 'PARTICIPANT'
],
'tier' => 'status',
'type' => 'CREDIT',
'value' => '1'
]
],
'active_from' => '2024-01-01T00:00:00Z',
'active_to' => '2024-12-31T23:59:59Z',
'budgets' => [
[
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'cron_expression' => '0 0 1 * *',
'interval' => '30d',
'limit' => '10000.00',
'schedule_type' => 'CRON'
]
],
'condition' => 'event.type == \'purchase\'',
'description' => 'Updated description',
'name' => 'Updated Rule Name',
'order' => 50,
'status' => 'SUSPENDED',
'stop_after_match' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.scrip.dev/v1/rules/{id}"
payload := strings.NewReader("{\n \"actions\": [\n {\n \"allow_negative\": false,\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"bucket\": \"AVAILABLE\",\n \"delay\": \"24h\",\n \"description\": \"Purchase reward\",\n \"event_name\": \"check_status\",\n \"expires_at\": \"365d\",\n \"key\": \"purchase_count\",\n \"level\": \"gold\",\n \"matures_at\": \"30d\",\n \"payload\": {},\n \"reference_id\": \"${{ event.authorization_id }}\",\n \"reset_after\": \"30d\",\n \"tag\": \"VIP\",\n \"target\": {\n \"external_id\": \"${{ event.referrer_id }}\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"participant_id\": \"${{ event.recipient_id }}\",\n \"type\": \"PARTICIPANT\"\n },\n \"tier\": \"status\",\n \"type\": \"CREDIT\",\n \"value\": \"1\"\n }\n ],\n \"active_from\": \"2024-01-01T00:00:00Z\",\n \"active_to\": \"2024-12-31T23:59:59Z\",\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"cron_expression\": \"0 0 1 * *\",\n \"interval\": \"30d\",\n \"limit\": \"10000.00\",\n \"schedule_type\": \"CRON\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"description\": \"Updated description\",\n \"name\": \"Updated Rule Name\",\n \"order\": 50,\n \"status\": \"SUSPENDED\",\n \"stop_after_match\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.scrip.dev/v1/rules/{id}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"actions\": [\n {\n \"allow_negative\": false,\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"bucket\": \"AVAILABLE\",\n \"delay\": \"24h\",\n \"description\": \"Purchase reward\",\n \"event_name\": \"check_status\",\n \"expires_at\": \"365d\",\n \"key\": \"purchase_count\",\n \"level\": \"gold\",\n \"matures_at\": \"30d\",\n \"payload\": {},\n \"reference_id\": \"${{ event.authorization_id }}\",\n \"reset_after\": \"30d\",\n \"tag\": \"VIP\",\n \"target\": {\n \"external_id\": \"${{ event.referrer_id }}\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"participant_id\": \"${{ event.recipient_id }}\",\n \"type\": \"PARTICIPANT\"\n },\n \"tier\": \"status\",\n \"type\": \"CREDIT\",\n \"value\": \"1\"\n }\n ],\n \"active_from\": \"2024-01-01T00:00:00Z\",\n \"active_to\": \"2024-12-31T23:59:59Z\",\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"cron_expression\": \"0 0 1 * *\",\n \"interval\": \"30d\",\n \"limit\": \"10000.00\",\n \"schedule_type\": \"CRON\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"description\": \"Updated description\",\n \"name\": \"Updated Rule Name\",\n \"order\": 50,\n \"status\": \"SUSPENDED\",\n \"stop_after_match\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scrip.dev/v1/rules/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"actions\": [\n {\n \"allow_negative\": false,\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"bucket\": \"AVAILABLE\",\n \"delay\": \"24h\",\n \"description\": \"Purchase reward\",\n \"event_name\": \"check_status\",\n \"expires_at\": \"365d\",\n \"key\": \"purchase_count\",\n \"level\": \"gold\",\n \"matures_at\": \"30d\",\n \"payload\": {},\n \"reference_id\": \"${{ event.authorization_id }}\",\n \"reset_after\": \"30d\",\n \"tag\": \"VIP\",\n \"target\": {\n \"external_id\": \"${{ event.referrer_id }}\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"participant_id\": \"${{ event.recipient_id }}\",\n \"type\": \"PARTICIPANT\"\n },\n \"tier\": \"status\",\n \"type\": \"CREDIT\",\n \"value\": \"1\"\n }\n ],\n \"active_from\": \"2024-01-01T00:00:00Z\",\n \"active_to\": \"2024-12-31T23:59:59Z\",\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"cron_expression\": \"0 0 1 * *\",\n \"interval\": \"30d\",\n \"limit\": \"10000.00\",\n \"schedule_type\": \"CRON\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"description\": \"Updated description\",\n \"name\": \"Updated Rule Name\",\n \"order\": 50,\n \"status\": \"SUSPENDED\",\n \"stop_after_match\": true\n}"
response = http.request(request)
puts response.read_body{
"actions": [
{
"amount": "${{ event.amount * 10 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440002",
"type": "CREDIT"
}
],
"active_from": "2024-01-01T00:00:00Z",
"active_to": "2024-12-31T23:59:59Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"consumed": "4500.00",
"cron_expression": "0 0 1 * *",
"interval": "720h",
"limit": "10000.00",
"next_reset_at": "2026-03-01T00:00:00Z",
"schedule_type": "CRON"
}
],
"condition": "event.type == 'purchase' && event.amount > 0",
"created_at": "2024-01-15T10:30:00Z",
"deleted_at": "2024-06-01T00:00:00Z",
"description": "Awards 10 points per dollar spent",
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Purchase Reward",
"order": 100,
"program_id": "550e8400-e29b-41d4-a716-446655440001",
"status": "ACTIVE",
"stop_after_match": false,
"updated_at": "2024-01-15T10:30:00Z",
"warnings": [
{
"code": "unknown_state_key",
"key": "purchaseCnt",
"kind": "counter",
"message": "unknown counter \"purchaseCnt\" — no rule in this program writes it; did you mean \"purchase_count\"?",
"scope": "participant",
"suggestion": "purchase_count"
}
]
}{
"code": "bad_request",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Invalid request parameters"
}{
"code": "unauthorized",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Missing or invalid credentials"
}{
"code": "forbidden",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Insufficient permissions for this action"
}{
"code": "not_found",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Resource not found"
}{
"code": "conflict",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Resource already exists or state conflict"
}{
"code": "unsupported_media_type",
"details": {
"expected": "uuid",
"field": "asset_id",
"fields": [
{
"expected": "<unknown>",
"field": "amount",
"message": "This field is required",
"reason": "required",
"received": "-10.00"
}
],
"reason": "invalid",
"received": "not-a-uuid"
},
"message": "Content-Type must be application/json"
}{
"code": "internal_error",
"message": "An internal error occurred"
}name, description, condition, actions, order, stop_after_match, active_from, active_to, budgets, or status. Only the fields included in the request body are changed; omitted fields remain untouched.
The budgets field is a full replacement when present. The provided array replaces all existing budgets. Omitting the field leaves budgets unchanged. To remove all budgets, send an empty budgets array.
To suspend a rule without archiving it, set status to SUSPENDED. To archive a rule, set status to ARCHIVED. Changing the order field will fail with a 409 if another active rule in the same program already occupies that position.
Archived rules cannot be modified. Rules belonging to an archived program also cannot be modified.
Authorizations
API key passed in the X-API-Key header.
Path Parameters
Rule ID
Body
Fields to update
Request body for updating an existing rule. Only provided fields are updated; at least one field must be specified.
Replacement actions array. Omit to leave actions unchanged. If provided, must be non-empty.
Show child attributes
Show child attributes
Start of the rule's active window (RFC 3339). Send null to clear.
"2024-01-01T00:00:00Z"
End of the rule's active window (RFC 3339). Send null to clear.
"2024-12-31T23:59:59Z"
Replacement budget array. Omit to leave budgets unchanged. Send empty array to remove all budgets.
Show child attributes
Show child attributes
Updated CEL expression
1"event.type == 'purchase'"
Updated description
1000"Updated description"
Updated display name
1 - 255"Updated Rule Name"
Updated evaluation sequence position
x >= 150
Updated lifecycle status: ACTIVE, SUSPENDED, or ARCHIVED
ACTIVE, SUSPENDED, ARCHIVED "SUSPENDED"
Whether to stop evaluating subsequent rules after this one matches
true
Response
Updated rule
Actions to execute when the condition matches
[
{
"amount": "${{ event.amount * 10 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440002",
"type": "CREDIT"
}
]Start of the rule's active window (RFC 3339, null if always active). Checked against the event's event_timestamp, inclusive.
"2024-01-01T00:00:00Z"
End of the rule's active window (RFC 3339, null if no end date). Checked against the event's event_timestamp, exclusive.
"2024-12-31T23:59:59Z"
Budget constraints applied to this rule
Show child attributes
Show child attributes
CEL expression that determines when the rule fires
"event.type == 'purchase' && event.amount > 0"
When this rule was created (RFC 3339)
"2024-01-15T10:30:00Z"
When this rule was archived (null if not archived)
"2024-06-01T00:00:00Z"
Human-readable summary of what this rule does
"Awards 10 points per dollar spent"
Unique identifier for this rule
"550e8400-e29b-41d4-a716-446655440000"
Display name
"Purchase Reward"
Evaluation sequence (lower = first, must be unique per program)
100
Program this rule belongs to
"550e8400-e29b-41d4-a716-446655440001"
Lifecycle status: ACTIVE, SUSPENDED, or ARCHIVED
"ACTIVE"
When true, no subsequent rules evaluate after this one matches
false
When this rule was last modified (RFC 3339)
"2024-01-15T10:30:00Z"
Non-blocking advisories about the rule's condition or action expressions, such as unknown state-key typos or deprecated CEL aliases. Present on create/update only; never blocks the save.
Show child attributes
Show child attributes