A valid request URL is required to generate request examples{
"id": "<string>",
"name": "<string>",
"earnings": [
{
"id": "<string>",
"name": "<string>",
"rules": {
"logic": "<string>"
},
"tier_rules": {
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
},
"effects": [
{
"points": {
"value": 4503599627370495,
"card_definition_id": "<string>",
"points_expiration": {
"rolling_expiration": {
"period": {
"value": 2
},
"rounding": {
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"period": {
"value": 2
},
"earning_activity": true,
"spending_activity": true,
"custom_activity": true,
"custom_activity_types": [
"<string>"
]
}
}
},
"points_proportional": {
"card_definition_id": "<string>",
"points_expiration": {
"rolling_expiration": {
"period": {
"value": 2
},
"rounding": {
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"period": {
"value": 2
},
"earning_activity": true,
"spending_activity": true,
"custom_activity": true,
"custom_activity_types": [
"<string>"
]
}
},
"order": {
"amount": {
"every": 4503599627370496,
"value": 4503599627370495.5
},
"total_amount": {
"every": 4503599627370496,
"value": 4503599627370495.5
},
"metadata": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"property": "<string>"
}
},
"customer": {
"metadata": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"property": "<string>"
}
},
"custom_event": {
"metadata": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"property": "<string>"
}
},
"order_items": {
"amount": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"subtotal_amount": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"quantity": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
}
}
},
"benefit": {
"id": "<string>"
}
}
]
}
],
"trigger": {
"custom_event": {
"schema_id": "<string>"
},
"segment": {
"id": "<string>"
}
},
"error": {
"message": "<string>"
},
"validity_hours": {
"daily": [
{
"days_of_week": [
3
],
"start_time": "<string>",
"end_time": "<string>"
}
]
},
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"trigger_limits": {
"cooldown": {
"fixed_cooldown": {
"period": {
"value": 2
}
}
},
"frequency": {
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {}
},
"triggers": {
"max": 2
}
}
]
}
},
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"object": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}Update earning rule
⚠️ BETA endpoint
This is a work-in-progress documentation of a BETA endpoint. The parameters, fields, request and response bodies, and other data may subject to change. If you want to share feedback or improvements, contact Voucherify support or your Technical Account Manager.
Updates an earning rule. All properties are optional; status cannot be changed
through this endpoint (use the activate/deactivate/draft endpoints). For rules that
are not in DRAFT status, only the following properties may effectively change:
name, earnings, error, validity_hours, start_date, end_date, trigger_limits, metadata.
Earnings items may carry an id (lernei_...) to update an existing earning item;
items without an id are created.
curl --request PUT \
--url {protocol}://{host}/v2/loyalties/earning-rules/{earningRuleId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"name": "<string>",
"earnings": [
{
"effects": [
{}
],
"id": "<string>",
"rules": {
"logic": "<string>"
},
"name": "<string>",
"tier_rules": {
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
}
}
],
"error": {
"message": "<string>"
},
"validity_hours": {
"daily": [
{
"days_of_week": [
3
],
"start_time": "<string>",
"end_time": "<string>"
}
]
},
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"metadata": {},
"trigger_limits": {
"cooldown": {
"fixed_cooldown": {
"period": {
"value": 2
}
}
},
"frequency": {
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {}
},
"triggers": {
"max": 2
}
}
]
}
}
}
'{
"id": "<string>",
"name": "<string>",
"earnings": [
{
"id": "<string>",
"name": "<string>",
"rules": {
"logic": "<string>"
},
"tier_rules": {
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
},
"effects": [
{
"points": {
"value": 4503599627370495,
"card_definition_id": "<string>",
"points_expiration": {
"rolling_expiration": {
"period": {
"value": 2
},
"rounding": {
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"period": {
"value": 2
},
"earning_activity": true,
"spending_activity": true,
"custom_activity": true,
"custom_activity_types": [
"<string>"
]
}
}
},
"points_proportional": {
"card_definition_id": "<string>",
"points_expiration": {
"rolling_expiration": {
"period": {
"value": 2
},
"rounding": {
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"period": {
"value": 2
},
"earning_activity": true,
"spending_activity": true,
"custom_activity": true,
"custom_activity_types": [
"<string>"
]
}
},
"order": {
"amount": {
"every": 4503599627370496,
"value": 4503599627370495.5
},
"total_amount": {
"every": 4503599627370496,
"value": 4503599627370495.5
},
"metadata": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"property": "<string>"
}
},
"customer": {
"metadata": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"property": "<string>"
}
},
"custom_event": {
"metadata": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"property": "<string>"
}
},
"order_items": {
"amount": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"subtotal_amount": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"quantity": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
}
}
},
"benefit": {
"id": "<string>"
}
}
]
}
],
"trigger": {
"custom_event": {
"schema_id": "<string>"
},
"segment": {
"id": "<string>"
}
},
"error": {
"message": "<string>"
},
"validity_hours": {
"daily": [
{
"days_of_week": [
3
],
"start_time": "<string>",
"end_time": "<string>"
}
]
},
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"trigger_limits": {
"cooldown": {
"fixed_cooldown": {
"period": {
"value": 2
}
}
},
"frequency": {
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {}
},
"triggers": {
"max": 2
}
}
]
}
},
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"object": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Earning rule ID.
^lern_[a-f0-9]+$Body
Request body for updating an earning rule. All properties are optional; status is not updatable here.
Earning rule name.
1 - 200Event that triggers the earning rule. Depending on event, either custom_event or segment is required and the other trigger contexts must be null/absent.
Show child attributes
Show child attributes
Earning definitions. Items with an id update existing earning items; items without an id are created. Omitted existing items are removed.
1Show child attributes
Show child attributes
Default error returned when rule validation fails. Nullable.
Show child attributes
Show child attributes
Hours during which the rule is active. Nullable.
Show child attributes
Show child attributes
Date-time from which the rule is active. Nullable.
Date-time until which the rule is active. Nullable.
Arbitrary key-value metadata. Nullable.
Cooldown and frequency limits for the trigger. Nullable.
Show child attributes
Show child attributes
Response
Updated earning rule
Earning rule as returned by the API.
Earning rule ID (lern_...).
^lern_[a-f0-9]+$Earning rule name.
200Current status. DELETED also exists internally but deleted rules are excluded from API reads.
DRAFT, ACTIVE, INACTIVE Earning definitions of the rule.
Show child attributes
Show child attributes
Event that triggers the earning rule. Depending on event, either custom_event or segment is required and the other trigger contexts must be null/absent.
Show child attributes
Show child attributes
Default error configuration. Absent when not configured.
Show child attributes
Show child attributes
Validity hours. Always present; defaults to { "type": "ANY_TIME" }.
Show child attributes
Show child attributes
Date-time from which the rule is active. Nullable.
Date-time until which the rule is active. Nullable.
Cooldown and frequency limits. In responses, frequency.limits is always an array (empty for NO_LIMIT).
Show child attributes
Show child attributes
Arbitrary key-value metadata. Always present (empty object when unset).
Creation timestamp (ISO 8601).
Last update timestamp (ISO 8601). Null when never updated.
Object type marker. Always earning_rule.
"earning_rule"Was this page helpful?

