curl --request POST \
--url https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data @- <<EOF
{
"base_rule_configuration_version": 4,
"rule_sets": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"key": "seasonal",
"name": "Seasonal Promotions",
"rules": [
{
"actions": [
{
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Purchase reward",
"expires_at": "365d",
"matures_at": "30d",
"type": "CREDIT"
}
],
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"limit": "10000.00"
}
],
"condition": "event.type == 'purchase'",
"id": "550e8400-e29b-41d4-a716-446655440002",
"name": "Holiday purchase reward",
"status": "ACTIVE",
"stop_after_match": false,
"active_from": "2026-11-01T00:00:00Z",
"active_to": "2027-01-01T00:00:00Z",
"client_ref": "holiday-purchase",
"description": "<string>"
}
],
"client_ref": "seasonal"
}
]
}
EOFimport requests
url = "https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview"
payload = {
"base_rule_configuration_version": 4,
"rule_sets": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"key": "seasonal",
"name": "Seasonal Promotions",
"rules": [
{
"actions": [
{
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Purchase reward",
"expires_at": "365d",
"matures_at": "30d",
"type": "CREDIT"
}
],
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"limit": "10000.00"
}
],
"condition": "event.type == 'purchase'",
"id": "550e8400-e29b-41d4-a716-446655440002",
"name": "Holiday purchase reward",
"status": "ACTIVE",
"stop_after_match": False,
"active_from": "2026-11-01T00:00:00Z",
"active_to": "2027-01-01T00:00:00Z",
"client_ref": "holiday-purchase",
"description": "<string>"
}
],
"client_ref": "seasonal"
}
]
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
base_rule_configuration_version: 4,
rule_sets: [
{
id: '550e8400-e29b-41d4-a716-446655440001',
key: 'seasonal',
name: 'Seasonal Promotions',
rules: [
{
actions: [
{
amount: '${{ event.amount * 0.03 }}',
asset_id: '550e8400-e29b-41d4-a716-446655440000',
description: 'Purchase reward',
expires_at: '365d',
matures_at: '30d',
type: 'CREDIT'
}
],
budgets: [{asset_id: '550e8400-e29b-41d4-a716-446655440000', limit: '10000.00'}],
condition: 'event.type == \'purchase\'',
id: '550e8400-e29b-41d4-a716-446655440002',
name: 'Holiday purchase reward',
status: 'ACTIVE',
stop_after_match: false,
active_from: '2026-11-01T00:00:00Z',
active_to: '2027-01-01T00:00:00Z',
client_ref: 'holiday-purchase',
description: '<string>'
}
],
client_ref: 'seasonal'
}
]
})
};
fetch('https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview', 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/programs/{programId}/rule-configuration/preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'base_rule_configuration_version' => 4,
'rule_sets' => [
[
'id' => '550e8400-e29b-41d4-a716-446655440001',
'key' => 'seasonal',
'name' => 'Seasonal Promotions',
'rules' => [
[
'actions' => [
[
'amount' => '${{ event.amount * 0.03 }}',
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'description' => 'Purchase reward',
'expires_at' => '365d',
'matures_at' => '30d',
'type' => 'CREDIT'
]
],
'budgets' => [
[
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'limit' => '10000.00'
]
],
'condition' => 'event.type == \'purchase\'',
'id' => '550e8400-e29b-41d4-a716-446655440002',
'name' => 'Holiday purchase reward',
'status' => 'ACTIVE',
'stop_after_match' => false,
'active_from' => '2026-11-01T00:00:00Z',
'active_to' => '2027-01-01T00:00:00Z',
'client_ref' => 'holiday-purchase',
'description' => '<string>'
]
],
'client_ref' => 'seasonal'
]
]
]),
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/programs/{programId}/rule-configuration/preview"
payload := strings.NewReader("{\n \"base_rule_configuration_version\": 4,\n \"rule_sets\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"key\": \"seasonal\",\n \"name\": \"Seasonal Promotions\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"description\": \"Purchase reward\",\n \"expires_at\": \"365d\",\n \"matures_at\": \"30d\",\n \"type\": \"CREDIT\"\n }\n ],\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"limit\": \"10000.00\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440002\",\n \"name\": \"Holiday purchase reward\",\n \"status\": \"ACTIVE\",\n \"stop_after_match\": false,\n \"active_from\": \"2026-11-01T00:00:00Z\",\n \"active_to\": \"2027-01-01T00:00:00Z\",\n \"client_ref\": \"holiday-purchase\",\n \"description\": \"<string>\"\n }\n ],\n \"client_ref\": \"seasonal\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"base_rule_configuration_version\": 4,\n \"rule_sets\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"key\": \"seasonal\",\n \"name\": \"Seasonal Promotions\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"description\": \"Purchase reward\",\n \"expires_at\": \"365d\",\n \"matures_at\": \"30d\",\n \"type\": \"CREDIT\"\n }\n ],\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"limit\": \"10000.00\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440002\",\n \"name\": \"Holiday purchase reward\",\n \"status\": \"ACTIVE\",\n \"stop_after_match\": false,\n \"active_from\": \"2026-11-01T00:00:00Z\",\n \"active_to\": \"2027-01-01T00:00:00Z\",\n \"client_ref\": \"holiday-purchase\",\n \"description\": \"<string>\"\n }\n ],\n \"client_ref\": \"seasonal\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"base_rule_configuration_version\": 4,\n \"rule_sets\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"key\": \"seasonal\",\n \"name\": \"Seasonal Promotions\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"description\": \"Purchase reward\",\n \"expires_at\": \"365d\",\n \"matures_at\": \"30d\",\n \"type\": \"CREDIT\"\n }\n ],\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"limit\": \"10000.00\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440002\",\n \"name\": \"Holiday purchase reward\",\n \"status\": \"ACTIVE\",\n \"stop_after_match\": false,\n \"active_from\": \"2026-11-01T00:00:00Z\",\n \"active_to\": \"2027-01-01T00:00:00Z\",\n \"client_ref\": \"holiday-purchase\",\n \"description\": \"<string>\"\n }\n ],\n \"client_ref\": \"seasonal\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"base_rule_configuration_version": 123,
"change_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"diff": {
"rule_sets": [
{
"after": "<unknown>",
"before": "<unknown>",
"change_type": "create",
"client_ref": "<string>",
"fields": [
"<string>"
],
"id": "<string>"
}
],
"rules": [
{
"after": "<unknown>",
"before": "<unknown>",
"change_type": "create",
"client_ref": "<string>",
"fields": [
"<string>"
],
"id": "<string>"
}
]
},
"expires_at": "2023-11-07T05:31:56Z",
"local_references": {},
"preview_token": "<string>",
"proposed_rule_configuration": {
"base_rule_configuration_version": 123,
"program_id": "<string>",
"rule_sets": [
{
"client_ref": "<string>",
"existing": true,
"id": "<string>",
"key": "<string>",
"name": "<string>",
"order": 123,
"rules": [
{
"actions": [
{
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Purchase reward",
"expires_at": "365d",
"matures_at": "30d",
"type": "CREDIT"
}
],
"active_from": "2023-11-07T05:31:56Z",
"active_to": "2023-11-07T05:31:56Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"limit": "10000.00"
}
],
"client_ref": "<string>",
"condition": "<string>",
"description": "<string>",
"existing": true,
"id": "<string>",
"name": "<string>",
"order": 123,
"restore_archived": true,
"rule_set_id": "<string>",
"status": "<string>",
"stop_after_match": true
}
]
}
]
},
"request_hash": "<string>",
"source": {
"reference": "<string>",
"source_revision": 123,
"type": "<string>"
},
"warnings": [
{
"client_ref": "<string>",
"code": "<string>",
"key": "<string>",
"kind": "<string>",
"message": "<string>",
"rule_id": "<string>",
"rule_set_id": "<string>",
"scope": "<string>",
"suggestion": "<string>"
}
]
}{
"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": "rule_configuration_version_conflict",
"details": {
"current_rule_configuration_version": 4,
"expected_rule_configuration_version": 3,
"instruction": "Refetch the rule configuration and replan the mutation."
},
"message": "Rule configuration changed since this mutation was planned"
}{
"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": "unprocessable",
"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": "Business rule violation"
}{
"code": "internal_error",
"message": "An internal error occurred"
}Preview a rule-configuration change set
Validate a complete desired rule configuration, allocate stable IDs for client_ref resources, and return the exact server-computed plan, diff, warnings, request hash, and a short-lived preview token bound to the caller. Live configuration is not mutated.
curl --request POST \
--url https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data @- <<EOF
{
"base_rule_configuration_version": 4,
"rule_sets": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"key": "seasonal",
"name": "Seasonal Promotions",
"rules": [
{
"actions": [
{
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Purchase reward",
"expires_at": "365d",
"matures_at": "30d",
"type": "CREDIT"
}
],
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"limit": "10000.00"
}
],
"condition": "event.type == 'purchase'",
"id": "550e8400-e29b-41d4-a716-446655440002",
"name": "Holiday purchase reward",
"status": "ACTIVE",
"stop_after_match": false,
"active_from": "2026-11-01T00:00:00Z",
"active_to": "2027-01-01T00:00:00Z",
"client_ref": "holiday-purchase",
"description": "<string>"
}
],
"client_ref": "seasonal"
}
]
}
EOFimport requests
url = "https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview"
payload = {
"base_rule_configuration_version": 4,
"rule_sets": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"key": "seasonal",
"name": "Seasonal Promotions",
"rules": [
{
"actions": [
{
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Purchase reward",
"expires_at": "365d",
"matures_at": "30d",
"type": "CREDIT"
}
],
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"limit": "10000.00"
}
],
"condition": "event.type == 'purchase'",
"id": "550e8400-e29b-41d4-a716-446655440002",
"name": "Holiday purchase reward",
"status": "ACTIVE",
"stop_after_match": False,
"active_from": "2026-11-01T00:00:00Z",
"active_to": "2027-01-01T00:00:00Z",
"client_ref": "holiday-purchase",
"description": "<string>"
}
],
"client_ref": "seasonal"
}
]
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
base_rule_configuration_version: 4,
rule_sets: [
{
id: '550e8400-e29b-41d4-a716-446655440001',
key: 'seasonal',
name: 'Seasonal Promotions',
rules: [
{
actions: [
{
amount: '${{ event.amount * 0.03 }}',
asset_id: '550e8400-e29b-41d4-a716-446655440000',
description: 'Purchase reward',
expires_at: '365d',
matures_at: '30d',
type: 'CREDIT'
}
],
budgets: [{asset_id: '550e8400-e29b-41d4-a716-446655440000', limit: '10000.00'}],
condition: 'event.type == \'purchase\'',
id: '550e8400-e29b-41d4-a716-446655440002',
name: 'Holiday purchase reward',
status: 'ACTIVE',
stop_after_match: false,
active_from: '2026-11-01T00:00:00Z',
active_to: '2027-01-01T00:00:00Z',
client_ref: 'holiday-purchase',
description: '<string>'
}
],
client_ref: 'seasonal'
}
]
})
};
fetch('https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview', 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/programs/{programId}/rule-configuration/preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'base_rule_configuration_version' => 4,
'rule_sets' => [
[
'id' => '550e8400-e29b-41d4-a716-446655440001',
'key' => 'seasonal',
'name' => 'Seasonal Promotions',
'rules' => [
[
'actions' => [
[
'amount' => '${{ event.amount * 0.03 }}',
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'description' => 'Purchase reward',
'expires_at' => '365d',
'matures_at' => '30d',
'type' => 'CREDIT'
]
],
'budgets' => [
[
'asset_id' => '550e8400-e29b-41d4-a716-446655440000',
'limit' => '10000.00'
]
],
'condition' => 'event.type == \'purchase\'',
'id' => '550e8400-e29b-41d4-a716-446655440002',
'name' => 'Holiday purchase reward',
'status' => 'ACTIVE',
'stop_after_match' => false,
'active_from' => '2026-11-01T00:00:00Z',
'active_to' => '2027-01-01T00:00:00Z',
'client_ref' => 'holiday-purchase',
'description' => '<string>'
]
],
'client_ref' => 'seasonal'
]
]
]),
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/programs/{programId}/rule-configuration/preview"
payload := strings.NewReader("{\n \"base_rule_configuration_version\": 4,\n \"rule_sets\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"key\": \"seasonal\",\n \"name\": \"Seasonal Promotions\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"description\": \"Purchase reward\",\n \"expires_at\": \"365d\",\n \"matures_at\": \"30d\",\n \"type\": \"CREDIT\"\n }\n ],\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"limit\": \"10000.00\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440002\",\n \"name\": \"Holiday purchase reward\",\n \"status\": \"ACTIVE\",\n \"stop_after_match\": false,\n \"active_from\": \"2026-11-01T00:00:00Z\",\n \"active_to\": \"2027-01-01T00:00:00Z\",\n \"client_ref\": \"holiday-purchase\",\n \"description\": \"<string>\"\n }\n ],\n \"client_ref\": \"seasonal\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"base_rule_configuration_version\": 4,\n \"rule_sets\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"key\": \"seasonal\",\n \"name\": \"Seasonal Promotions\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"description\": \"Purchase reward\",\n \"expires_at\": \"365d\",\n \"matures_at\": \"30d\",\n \"type\": \"CREDIT\"\n }\n ],\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"limit\": \"10000.00\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440002\",\n \"name\": \"Holiday purchase reward\",\n \"status\": \"ACTIVE\",\n \"stop_after_match\": false,\n \"active_from\": \"2026-11-01T00:00:00Z\",\n \"active_to\": \"2027-01-01T00:00:00Z\",\n \"client_ref\": \"holiday-purchase\",\n \"description\": \"<string>\"\n }\n ],\n \"client_ref\": \"seasonal\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scrip.dev/v1/programs/{programId}/rule-configuration/preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"base_rule_configuration_version\": 4,\n \"rule_sets\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"key\": \"seasonal\",\n \"name\": \"Seasonal Promotions\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"amount\": \"${{ event.amount * 0.03 }}\",\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"description\": \"Purchase reward\",\n \"expires_at\": \"365d\",\n \"matures_at\": \"30d\",\n \"type\": \"CREDIT\"\n }\n ],\n \"budgets\": [\n {\n \"asset_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"limit\": \"10000.00\"\n }\n ],\n \"condition\": \"event.type == 'purchase'\",\n \"id\": \"550e8400-e29b-41d4-a716-446655440002\",\n \"name\": \"Holiday purchase reward\",\n \"status\": \"ACTIVE\",\n \"stop_after_match\": false,\n \"active_from\": \"2026-11-01T00:00:00Z\",\n \"active_to\": \"2027-01-01T00:00:00Z\",\n \"client_ref\": \"holiday-purchase\",\n \"description\": \"<string>\"\n }\n ],\n \"client_ref\": \"seasonal\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"base_rule_configuration_version": 123,
"change_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"diff": {
"rule_sets": [
{
"after": "<unknown>",
"before": "<unknown>",
"change_type": "create",
"client_ref": "<string>",
"fields": [
"<string>"
],
"id": "<string>"
}
],
"rules": [
{
"after": "<unknown>",
"before": "<unknown>",
"change_type": "create",
"client_ref": "<string>",
"fields": [
"<string>"
],
"id": "<string>"
}
]
},
"expires_at": "2023-11-07T05:31:56Z",
"local_references": {},
"preview_token": "<string>",
"proposed_rule_configuration": {
"base_rule_configuration_version": 123,
"program_id": "<string>",
"rule_sets": [
{
"client_ref": "<string>",
"existing": true,
"id": "<string>",
"key": "<string>",
"name": "<string>",
"order": 123,
"rules": [
{
"actions": [
{
"amount": "${{ event.amount * 0.03 }}",
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"description": "Purchase reward",
"expires_at": "365d",
"matures_at": "30d",
"type": "CREDIT"
}
],
"active_from": "2023-11-07T05:31:56Z",
"active_to": "2023-11-07T05:31:56Z",
"budgets": [
{
"asset_id": "550e8400-e29b-41d4-a716-446655440000",
"limit": "10000.00"
}
],
"client_ref": "<string>",
"condition": "<string>",
"description": "<string>",
"existing": true,
"id": "<string>",
"name": "<string>",
"order": 123,
"restore_archived": true,
"rule_set_id": "<string>",
"status": "<string>",
"stop_after_match": true
}
]
}
]
},
"request_hash": "<string>",
"source": {
"reference": "<string>",
"source_revision": 123,
"type": "<string>"
},
"warnings": [
{
"client_ref": "<string>",
"code": "<string>",
"key": "<string>",
"kind": "<string>",
"message": "<string>",
"rule_id": "<string>",
"rule_set_id": "<string>",
"scope": "<string>",
"suggestion": "<string>"
}
]
}{
"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": "rule_configuration_version_conflict",
"details": {
"current_rule_configuration_version": 4,
"expected_rule_configuration_version": 3,
"instruction": "Refetch the rule configuration and replan the mutation."
},
"message": "Rule configuration changed since this mutation was planned"
}{
"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": "unprocessable",
"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": "Business rule violation"
}{
"code": "internal_error",
"message": "An internal error occurred"
}id; new resources use a unique client_ref. Omitting an existing rule archives it when the preview is applied. Existing rule-set keys must remain unchanged.
The response contains the exact plan the server will commit, resource diff, warnings, stable IDs allocated for client_ref values, request hash, expiry time, and a preview token bound to the caller.
See Preview and apply.Authorizations
API key passed in the X-API-Key header.
Path Parameters
Program ID
Body
Complete proposed rule configuration
Current rule_configuration_version from the configuration read endpoint.
x >= 14
Complete desired rule-set and non-archived rule configuration in execution order.
1- Option 1
- Option 2
Show child attributes
Show child attributes
Optional caller category and correlation reference for audit history. Defaults to type api.
Show child attributes
Show child attributes
Response
OK
Configuration version the preview was planned from.
Stable preview/change identifier.
Resource-level changes between the base and proposed configurations.
Show child attributes
Show child attributes
Preview capability expiry time.
Mapping from each client_ref to its preview-allocated stable UUID.
Show child attributes
Show child attributes
Short-lived actor-bound capability consumed by apply.
Exact server-computed configuration that apply will commit.
Show child attributes
Show child attributes
SHA-256 request hash that must accompany apply.
Audit source recorded with the preview.
Show child attributes
Show child attributes
Non-blocking advisories found while validating the proposed configuration.
Show child attributes
Show child attributes