curl --request PUT \
--url https://{cluster}.voucherify.io/v2/loyalties/earning-rules/{earningRuleId} \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"error": {
"message": "<string>"
},
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"metadata": {},
"name": "<string>",
"earnings": [
{
"effects": [
{}
],
"name": "<string>",
"tier_rules": {
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
},
"id": "<string>"
}
],
"validity_hours": {
"daily": [
{
"days_of_week": [
3
],
"start_time": "<string>",
"end_time": "<string>"
}
]
},
"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>",
"status": "DRAFT",
"earnings": [
{
"id": "<string>",
"tier_rules": {
"type": "NO_REQUIREMENTS",
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
},
"effects": [
{
"type": "POINTS",
"points": {
"value": 4503599627370495,
"card_definition_id": "<string>",
"points_expiration": {
"type": "NO_EXPIRATION",
"rolling_expiration": {
"period": {
"unit": "DAY",
"value": 2
},
"rounding": {
"type": "END_OF_MONTH",
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"earning_activity": true,
"period": {
"value": 2,
"unit": "DAY"
}
}
}
},
"points_proportional": {
"calculation_type": "PRE_DISCOUNT_ORDER_AMOUNT",
"card_definition_id": "<string>",
"points_expiration": {
"type": "NO_EXPIRATION",
"rolling_expiration": {
"period": {
"unit": "DAY",
"value": 2
},
"rounding": {
"type": "END_OF_MONTH",
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"earning_activity": true,
"period": {
"value": 2,
"unit": "DAY"
}
}
},
"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": [
{
"type": "product",
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"subtotal_amount": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"type": "product",
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"quantity": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"type": "product",
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
}
}
},
"benefit": {
"id": "<string>"
}
}
],
"name": "<string>",
"rules": {
"logic": "<string>"
}
}
],
"trigger": {
"event": "customer.order.paid",
"custom_event": {
"schema_id": "<string>"
},
"segment": {
"id": "<string>"
}
},
"validity_hours": {
"type": "DAILY",
"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": {
"type": "NO_COOLDOWN",
"fixed_cooldown": {
"period": {
"value": 2,
"unit": "HOUR"
}
}
},
"frequency": {
"type": "NO_LIMIT",
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {
"unit": "DAY"
}
},
"triggers": {
"max": 2
}
}
]
}
},
"earning_limits": {
"global": {
"type": "NO_LIMIT",
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {
"unit": "DAY"
}
},
"points": {
"max": 2
}
}
]
}
},
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"object": "earning_rule",
"error": {
"message": "<string>"
}
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}{
"code": 500,
"key": "api_error",
"message": "Something went wrong. Don't worry, your campaigns are still safe and the Voucherify Team has been notified. Check out our Help Center and forums for help, or head back to home."
}Update earning rule
This documentation is in progress. The parameters, fields, request and response bodies, and other data may be subject to change. If you need more information or you want to share feedback, 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, earning_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 https://{cluster}.voucherify.io/v2/loyalties/earning-rules/{earningRuleId} \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"error": {
"message": "<string>"
},
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"metadata": {},
"name": "<string>",
"earnings": [
{
"effects": [
{}
],
"name": "<string>",
"tier_rules": {
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
},
"id": "<string>"
}
],
"validity_hours": {
"daily": [
{
"days_of_week": [
3
],
"start_time": "<string>",
"end_time": "<string>"
}
]
},
"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>",
"status": "DRAFT",
"earnings": [
{
"id": "<string>",
"tier_rules": {
"type": "NO_REQUIREMENTS",
"any_of": [
{
"tier_structure_id": "<string>",
"tier_ids": [
"<string>"
]
}
]
},
"effects": [
{
"type": "POINTS",
"points": {
"value": 4503599627370495,
"card_definition_id": "<string>",
"points_expiration": {
"type": "NO_EXPIRATION",
"rolling_expiration": {
"period": {
"unit": "DAY",
"value": 2
},
"rounding": {
"type": "END_OF_MONTH",
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"earning_activity": true,
"period": {
"value": 2,
"unit": "DAY"
}
}
}
},
"points_proportional": {
"calculation_type": "PRE_DISCOUNT_ORDER_AMOUNT",
"card_definition_id": "<string>",
"points_expiration": {
"type": "NO_EXPIRATION",
"rolling_expiration": {
"period": {
"unit": "DAY",
"value": 2
},
"rounding": {
"type": "END_OF_MONTH",
"value": 6
}
},
"calendar_expiration": {
"expiration_dates": [
{
"day": 16,
"month": 6
}
]
},
"sliding_expiration": {
"earning_activity": true,
"period": {
"value": 2,
"unit": "DAY"
}
}
},
"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": [
{
"type": "product",
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"subtotal_amount": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"type": "product",
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
},
"quantity": {
"every": 4503599627370496,
"value": 4503599627370495.5,
"applicable_to": [
{
"type": "product",
"product": {
"id": "<string>"
},
"sku": {
"id": "<string>"
},
"products_collection": {
"id": "<string>"
}
}
]
}
}
},
"benefit": {
"id": "<string>"
}
}
],
"name": "<string>",
"rules": {
"logic": "<string>"
}
}
],
"trigger": {
"event": "customer.order.paid",
"custom_event": {
"schema_id": "<string>"
},
"segment": {
"id": "<string>"
}
},
"validity_hours": {
"type": "DAILY",
"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": {
"type": "NO_COOLDOWN",
"fixed_cooldown": {
"period": {
"value": 2,
"unit": "HOUR"
}
}
},
"frequency": {
"type": "NO_LIMIT",
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {
"unit": "DAY"
}
},
"triggers": {
"max": 2
}
}
]
}
},
"earning_limits": {
"global": {
"type": "NO_LIMIT",
"limits": [
{
"type": "TIME_BASED",
"period": {
"type": "CURRENT_PERIOD",
"current_period": {
"unit": "DAY"
}
},
"points": {
"max": 2
}
}
]
}
},
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"object": "earning_rule",
"error": {
"message": "<string>"
}
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}{
"code": 123,
"key": "<string>",
"message": "<string>",
"details": "<string>",
"request_id": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}{
"code": 500,
"key": "api_error",
"message": "Something went wrong. Don't worry, your campaigns are still safe and the Voucherify Team has been notified. Check out our Help Center and forums for help, or head back to home."
}Authorizations
Path Parameters
Identifies the earning rule. Format lern_[a-f0-9]+.
^lern_[a-f0-9]+$Body
Request body schema for PUT /v2/loyalties/earning-rules/{earningRuleId}.
Default error returned when rule validation fails. Can be null.
Show child attributes
Show child attributes
Date-time from which the rule is active. Can be null. When both start_date and end_date are set, start_date must be earlier than end_date.
Date-time until which the rule is active. Can be null.
Arbitrary key-value metadata. A request may omit this field or set it to null. null is stored as an empty object. The response always returns an object.
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
Hours during which the rule is active. Can be null.
Show child attributes
Show child attributes
Cooldown and frequency limits for the trigger. Can be null.
Show child attributes
Show child attributes
Response
Updated earning rule
Response body schema for PUT /v2/loyalties/earning-rules/{earningRuleId}.
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. Contains at least one earning.
1Show 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
Validity hours. Always present; defaults to { "type": "ANY_TIME" }.
Show child attributes
Show child attributes
Date-time from which the rule is active. Can be null.
Date-time until which the rule is active. Can be null.
Cooldown and frequency limits. Always present. cooldown and frequency are always objects. frequency.limits is always an array and is empty when frequency.type is NO_LIMIT.
Show child attributes
Show child attributes
Limits how many points this rule can award. Always present. Defaults to no global limit (global.type NO_LIMIT and global.limits []).
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"Default error configuration. Absent when not configured.
Show child attributes
Show child attributes

