Create a rule
The rule is created at version 1. It isn't used anywhere until you attach it to a program. A definition that breaks the rule structure returns 422 with its code, message and path, for example {"error":"tiers_gap","message":"tier 1 must start at 10","path":"definition.payout.tiers[1].from"}. A full library returns 409 library_full.
Headers
- Type: stringIdempotency
- Key max length:255requiredRequired on every POST, PATCH and DELETE, up to 255 characters. A repeated key with the same request replays the stored response.
Body
required
application/json
- Properties: 4Type: objectdefinitionrequired
- Type: stringnamemin length:1max length:200required
- Type: stringdescriptionmax length:2000
Responses
- application/json
- application/json
- application/json
- application/json
- application/json
Request Example for post/api/v1/rewards/rules
curl https://rewards-api.bettermoney.com/api/v1/rewards/rules \
--request POST \
--header 'Idempotency-Key: ' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_SECRET_TOKEN' \
--data '{
"name": "",
"description": "",
"definition": {
"measure": {
"type": "daily_balance",
"metricKey": ""
},
"condition": {
"type": "always"
},
"payout": {
"type": "fixed",
"amount": ""
},
"limits": [
{
"type": "cap_per_period",
"amount": ""
}
]
}
}'
{
"id": "string",
"name": "string",
"description": null,
"version": -9007199254740991,
"status": "active",
"isDefault": true,
"definition": {
"measure": {
"type": "daily_balance",
"metricKey": "string"
},
"condition": {
"type": "always"
},
"payout": {
"type": "fixed",
"amount": "string"
},
"limits": [
{
"type": "cap_per_period",
"amount": "string"
}
]
},
"summary": null,
"usedBy": [
{
"programId": "string",
"programName": "string",
"ruleKey": "string",
"ruleVersion": -9007199254740991,
"effectivePeriodId": "string"
}
],
"createdAt": "string",
"updatedAt": "string"
}