curl --request POST \
--url https://{cluster}.voucherify.io/v1/loyalties/{campaignId}/earning-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data @- <<EOF
[
{
"event": "order.paid",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "FIXED",
"points": "5"
},
"source": {
"banner": "Order paid 5 points."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid - fixed amount of points"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_AMOUNT",
"order": {
"amount": {
"every": 1,
"points": 1
}
}
},
"source": {
"banner": "Order paid - 1 point for 1 dollar spent excluding discounts."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_TOTAL_AMOUNT",
"order": {
"total_amount": {
"every": 1,
"points": 1
}
}
},
"source": {
"banner": "Order paid - 1 point for 1 dollar spent including discounts."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order total amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_METADATA",
"order": {
"metadata": {
"every": 2,
"points": 1,
"property": "number_of_store_visits"
}
}
},
"source": {
"banner": "Order paid - 2 points for each store visit."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to numerical order metadata property "
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_AMOUNT",
"order_items": {
"amount": {
"every": 2,
"points": 1,
"object": "product",
"id": "prod_0bae32322150fd0546"
}
}
},
"source": {
"banner": "Order paid - 2 points for 1 dollar spent on items excluding discounts."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order items amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_SUBTOTAL_AMOUNT",
"order_items": {
"subtotal_amount": {
"every": 2,
"points": 1,
"object": "products_collection",
"id": "pc_75U0dHlr7u75BJodrW1AE3t6"
}
}
},
"source": {
"banner": "Order paid - 2 points for every dollar spent on the product collection."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order items subtotal amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_QUANTITY",
"order_items": {
"quantity": {
"every": 1,
"points": 1,
"object": "sku",
"id": "sku_0b7d7dfb090be5c619"
}
}
},
"source": {
"banner": "Order paid - 1 point for every brand phone in your cart."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid - points proportional to quantity of items in a cart of a product varient."
}
},
{
"event": "order.paid",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"source": {
"banner": "Order paid 1 point for 1 month of being a customer with us."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid - points proportional to customer metadata property"
}
},
{
"event": "customer.segment.entered",
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"source": {
"banner": "Customer entered birthday segment - 1 point for each month of being a customer with us."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Entered segment - points proportional to customer metadata property"
}
},
{
"event": "customer.segment.entered",
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "FIXED",
"points": "5"
},
"source": {
"banner": "Customer entered birthday segment - 5 points"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Entered segment - fixed points"
}
},
{
"event": "page_view",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 3,
"type": "FIXED"
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"source": {
"banner": "See page - 3 points"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - fixed points for viewing a page"
}
},
{
"event": "page_view",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOM_EVENT_METADATA",
"custom_event": {
"metadata": {
"every": 1,
"points": 2,
"property": "volume_number"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"source": {
"banner": "See page X - get 2 points multiplied by the page number"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on custom event metadata"
}
},
{
"event": "page_view",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"source": {
"banner": "Get 2 points for every month you're a customer for viewing a page"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on customer metadata"
}
},
{
"event": "customer.loyalty.tier.prolonged",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"loyalty_tier": {
"id": "ltr_pudTGWasuIqxdiDM0go31OV1"
},
"source": {
"banner": "Get 2 points for every month you're a customer when your loyalty tier is prolonged."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - proportional points for extending a loyalty tier based on customer metadata."
}
}
]
EOF[
{
"id": "ern_63g6NQgtepfXn2z0QbT2ksLf",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 5,
"type": "FIXED"
},
"event": "order.paid",
"source": {
"banner": "Order paid 5 points.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_knM56LS3oygL0Ue0oeSNt4WA",
"metadata": {
"Type": "Order paid - fixed amount of points"
}
},
{
"id": "ern_Ov5RWerVFubVSjIHOMco34dv",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_AMOUNT",
"order": {
"amount": {
"every": 1,
"points": 1
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 1 point for 1 dollar spent excluding discounts.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_2R4x6pMFVEIPz1Lhz5ZVo33Y",
"metadata": {
"Type": "Order paid- points proportional to order amount"
}
},
{
"id": "ern_5rWPz4arGlTv4FVc1vETeFfe",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_TOTAL_AMOUNT",
"order": {
"total_amount": {
"every": 1,
"points": 1
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 1 point for 1 dollar spent including discounts.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_fXasfs6Eh7P2haZkI33PEumI",
"metadata": {
"Type": "Order paid- points proportional to order total amount"
}
},
{
"id": "ern_Xs3o43dHr1O3RM5ojoeu1l6b",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_METADATA",
"order": {
"metadata": {
"every": 2,
"points": 1,
"property": "number_of_store_visits"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 2 points for each store visit.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_jucMzF25jisrqiG3k6JyyviT",
"metadata": {
"Type": "Order paid- points proportional to numerical order metadata property "
}
},
{
"id": "ern_9CjMBP2V8zgpsHLga4YOQo0A",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_AMOUNT",
"order_items": {
"amount": {
"every": 2,
"points": 1,
"object": "product",
"id": "prod_0bae32322150fd0546"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 2 points for 1 dollar spent on items excluding discounts.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_y60lx7XsW1YdOOOFuDaYjvG4",
"metadata": {
"Type": "Order paid- points proportional to order items amount"
}
},
{
"id": "ern_uI7hRj8PNodK8xWRsn3gpDdG",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_SUBTOTAL_AMOUNT",
"order_items": {
"subtotal_amount": {
"every": 2,
"points": 1,
"object": "products_collection",
"id": "pc_75U0dHlr7u75BJodrW1AE3t6"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 2 points for every dollar spent on the product collection.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_Lk1WROGexXA72FabUWhR1p7X",
"metadata": {
"Type": "Order paid- points proportional to order items subtotal amount"
}
},
{
"id": "ern_dL13AmZEO0ToImOY44YUP1ru",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_QUANTITY",
"order_items": {
"quantity": {
"every": 1,
"points": 1,
"object": "sku",
"id": "sku_0b7d7dfb090be5c619"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 1 point for every brand phone in your cart.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_4F9iJG0hmKTiqSsmkfbB8vUF",
"metadata": {
"Type": "Order paid - points proportional to quantity of items in a cart of a product varient."
}
},
{
"id": "ern_ublD9yGhxPrd9ayPAMTc4aOZ",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid 1 point for 1 month of being a customer with us.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_raft7C1hVw427OnEobmzhXjD",
"metadata": {
"Type": "Order paid - points proportional to customer metadata property"
}
},
{
"id": "ern_6tBwufmR7UNJInhZq8zNRrj5",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"event": "customer.segment.entered",
"source": {
"banner": "Customer entered birthday segment - 1 point for each month of being a customer with us.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_mQ8SCABGLnrGMBbh8QS6DUpX",
"metadata": {
"Type": "Entered segment - points proportional to customer metadata property"
}
},
{
"id": "ern_yBR0JtdcDyJXgZf30C8KQLPw",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 5,
"type": "FIXED"
},
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"event": "customer.segment.entered",
"source": {
"banner": "Customer entered birthday segment - 5 points",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_Co7zjgYPIKZ45vcK0jn7qrY8",
"metadata": {
"Type": "Entered segment - fixed points"
}
},
{
"id": "ern_Ic2AUznt4cJInIl1wt6n0Fbv",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 3,
"type": "FIXED"
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"event": "page_view",
"source": {
"banner": "See page - 3 points",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_KWvcBS3bdmJnWD4BTw29eRNT",
"metadata": {
"Type": "Custom Event - fixed points for viewing a page"
}
},
{
"id": "ern_4SRj1TY1j8Q617R2Y4qiN1sy",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOM_EVENT_METADATA",
"custom_event": {
"metadata": {
"every": 1,
"points": 2,
"property": "volume_number"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"event": "page_view",
"source": {
"banner": "See page X - get 2 points multiplied by the page number",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_WWESERcKoTRSbCDal7Hr7H0A",
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on custom event metadata"
}
},
{
"id": "ern_WXBa4b5a6N5XZt9A9Nf9dagA",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"event": "page_view",
"source": {
"banner": "Get 2 points for every month you're a customer for viewing a page",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_zv3mCOeZOaHCsFMG0yIKu0ax",
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on customer metadata"
}
},
{
"id": "ern_DvdegDzcaMUXzf2fayzCqMEV",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"event": "customer.loyalty.tier.prolonged",
"loyalty_tier": {
"id": "ltr_pudTGWasuIqxdiDM0go31OV1"
},
"source": {
"banner": "Get 2 points for every month you're a customer when your loyalty tier is prolonged.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_fpfYyNcpVskgwcrs21kQ91Wx",
"metadata": {
"Type": "Custom Event - proportional points for extending a loyalty tier based on customer metadata."
}
}
]Create earning rules for a loyalty campaign.
🚧 Maximum number of earning rules
You can create up to 100 earning rules per project. The limit can be customized for clients with a single-tenant setup.
curl --request POST \
--url https://{cluster}.voucherify.io/v1/loyalties/{campaignId}/earning-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data @- <<EOF
[
{
"event": "order.paid",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "FIXED",
"points": "5"
},
"source": {
"banner": "Order paid 5 points."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid - fixed amount of points"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_AMOUNT",
"order": {
"amount": {
"every": 1,
"points": 1
}
}
},
"source": {
"banner": "Order paid - 1 point for 1 dollar spent excluding discounts."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_TOTAL_AMOUNT",
"order": {
"total_amount": {
"every": 1,
"points": 1
}
}
},
"source": {
"banner": "Order paid - 1 point for 1 dollar spent including discounts."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order total amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_METADATA",
"order": {
"metadata": {
"every": 2,
"points": 1,
"property": "number_of_store_visits"
}
}
},
"source": {
"banner": "Order paid - 2 points for each store visit."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to numerical order metadata property "
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_AMOUNT",
"order_items": {
"amount": {
"every": 2,
"points": 1,
"object": "product",
"id": "prod_0bae32322150fd0546"
}
}
},
"source": {
"banner": "Order paid - 2 points for 1 dollar spent on items excluding discounts."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order items amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_SUBTOTAL_AMOUNT",
"order_items": {
"subtotal_amount": {
"every": 2,
"points": 1,
"object": "products_collection",
"id": "pc_75U0dHlr7u75BJodrW1AE3t6"
}
}
},
"source": {
"banner": "Order paid - 2 points for every dollar spent on the product collection."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid- points proportional to order items subtotal amount"
}
},
{
"event": "order.paid",
"validation_rule_id": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_QUANTITY",
"order_items": {
"quantity": {
"every": 1,
"points": 1,
"object": "sku",
"id": "sku_0b7d7dfb090be5c619"
}
}
},
"source": {
"banner": "Order paid - 1 point for every brand phone in your cart."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid - points proportional to quantity of items in a cart of a product varient."
}
},
{
"event": "order.paid",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"source": {
"banner": "Order paid 1 point for 1 month of being a customer with us."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Order paid - points proportional to customer metadata property"
}
},
{
"event": "customer.segment.entered",
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"source": {
"banner": "Customer entered birthday segment - 1 point for each month of being a customer with us."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Entered segment - points proportional to customer metadata property"
}
},
{
"event": "customer.segment.entered",
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "FIXED",
"points": "5"
},
"source": {
"banner": "Customer entered birthday segment - 5 points"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Entered segment - fixed points"
}
},
{
"event": "page_view",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 3,
"type": "FIXED"
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"source": {
"banner": "See page - 3 points"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - fixed points for viewing a page"
}
},
{
"event": "page_view",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOM_EVENT_METADATA",
"custom_event": {
"metadata": {
"every": 1,
"points": 2,
"property": "volume_number"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"source": {
"banner": "See page X - get 2 points multiplied by the page number"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on custom event metadata"
}
},
{
"event": "page_view",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"source": {
"banner": "Get 2 points for every month you're a customer for viewing a page"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on customer metadata"
}
},
{
"event": "customer.loyalty.tier.prolonged",
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"loyalty_tier": {
"id": "ltr_pudTGWasuIqxdiDM0go31OV1"
},
"source": {
"banner": "Get 2 points for every month you're a customer when your loyalty tier is prolonged."
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"metadata": {
"Type": "Custom Event - proportional points for extending a loyalty tier based on customer metadata."
}
}
]
EOF[
{
"id": "ern_63g6NQgtepfXn2z0QbT2ksLf",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 5,
"type": "FIXED"
},
"event": "order.paid",
"source": {
"banner": "Order paid 5 points.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_knM56LS3oygL0Ue0oeSNt4WA",
"metadata": {
"Type": "Order paid - fixed amount of points"
}
},
{
"id": "ern_Ov5RWerVFubVSjIHOMco34dv",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_AMOUNT",
"order": {
"amount": {
"every": 1,
"points": 1
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 1 point for 1 dollar spent excluding discounts.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_2R4x6pMFVEIPz1Lhz5ZVo33Y",
"metadata": {
"Type": "Order paid- points proportional to order amount"
}
},
{
"id": "ern_5rWPz4arGlTv4FVc1vETeFfe",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_TOTAL_AMOUNT",
"order": {
"total_amount": {
"every": 1,
"points": 1
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 1 point for 1 dollar spent including discounts.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_fXasfs6Eh7P2haZkI33PEumI",
"metadata": {
"Type": "Order paid- points proportional to order total amount"
}
},
{
"id": "ern_Xs3o43dHr1O3RM5ojoeu1l6b",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_METADATA",
"order": {
"metadata": {
"every": 2,
"points": 1,
"property": "number_of_store_visits"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 2 points for each store visit.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_jucMzF25jisrqiG3k6JyyviT",
"metadata": {
"Type": "Order paid- points proportional to numerical order metadata property "
}
},
{
"id": "ern_9CjMBP2V8zgpsHLga4YOQo0A",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_AMOUNT",
"order_items": {
"amount": {
"every": 2,
"points": 1,
"object": "product",
"id": "prod_0bae32322150fd0546"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 2 points for 1 dollar spent on items excluding discounts.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_y60lx7XsW1YdOOOFuDaYjvG4",
"metadata": {
"Type": "Order paid- points proportional to order items amount"
}
},
{
"id": "ern_uI7hRj8PNodK8xWRsn3gpDdG",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_SUBTOTAL_AMOUNT",
"order_items": {
"subtotal_amount": {
"every": 2,
"points": 1,
"object": "products_collection",
"id": "pc_75U0dHlr7u75BJodrW1AE3t6"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 2 points for every dollar spent on the product collection.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_Lk1WROGexXA72FabUWhR1p7X",
"metadata": {
"Type": "Order paid- points proportional to order items subtotal amount"
}
},
{
"id": "ern_dL13AmZEO0ToImOY44YUP1ru",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "ORDER_ITEMS_QUANTITY",
"order_items": {
"quantity": {
"every": 1,
"points": 1,
"object": "sku",
"id": "sku_0b7d7dfb090be5c619"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid - 1 point for every brand phone in your cart.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_4F9iJG0hmKTiqSsmkfbB8vUF",
"metadata": {
"Type": "Order paid - points proportional to quantity of items in a cart of a product varient."
}
},
{
"id": "ern_ublD9yGhxPrd9ayPAMTc4aOZ",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"event": "order.paid",
"source": {
"banner": "Order paid 1 point for 1 month of being a customer with us.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_raft7C1hVw427OnEobmzhXjD",
"metadata": {
"Type": "Order paid - points proportional to customer metadata property"
}
},
{
"id": "ern_6tBwufmR7UNJInhZq8zNRrj5",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 1,
"property": "customer_life_time_value"
}
}
},
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"event": "customer.segment.entered",
"source": {
"banner": "Customer entered birthday segment - 1 point for each month of being a customer with us.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_mQ8SCABGLnrGMBbh8QS6DUpX",
"metadata": {
"Type": "Entered segment - points proportional to customer metadata property"
}
},
{
"id": "ern_yBR0JtdcDyJXgZf30C8KQLPw",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 5,
"type": "FIXED"
},
"segment": {
"id": "seg_OlE7DmfzMI5pHyD5VAv512r1"
},
"event": "customer.segment.entered",
"source": {
"banner": "Customer entered birthday segment - 5 points",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_Co7zjgYPIKZ45vcK0jn7qrY8",
"metadata": {
"Type": "Entered segment - fixed points"
}
},
{
"id": "ern_Ic2AUznt4cJInIl1wt6n0Fbv",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"points": 3,
"type": "FIXED"
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"event": "page_view",
"source": {
"banner": "See page - 3 points",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_KWvcBS3bdmJnWD4BTw29eRNT",
"metadata": {
"Type": "Custom Event - fixed points for viewing a page"
}
},
{
"id": "ern_4SRj1TY1j8Q617R2Y4qiN1sy",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOM_EVENT_METADATA",
"custom_event": {
"metadata": {
"every": 1,
"points": 2,
"property": "volume_number"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"event": "page_view",
"source": {
"banner": "See page X - get 2 points multiplied by the page number",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_WWESERcKoTRSbCDal7Hr7H0A",
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on custom event metadata"
}
},
{
"id": "ern_WXBa4b5a6N5XZt9A9Nf9dagA",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"custom_event": {
"schema_id": "ms_gn4Qe4xsFPf7orCArCiNVY13"
},
"event": "page_view",
"source": {
"banner": "Get 2 points for every month you're a customer for viewing a page",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_zv3mCOeZOaHCsFMG0yIKu0ax",
"metadata": {
"Type": "Custom Event - proportional points for viewing a page based on customer metadata"
}
},
{
"id": "ern_DvdegDzcaMUXzf2fayzCqMEV",
"created_at": "2022-11-29T11:10:46.523Z",
"updated_at": null,
"validation_rule_id": "val_7SxpdhPeBngA",
"loyalty": {
"type": "PROPORTIONAL",
"calculation_type": "CUSTOMER_METADATA",
"customer": {
"metadata": {
"every": 1,
"points": 2,
"property": "customer_life_time_value"
}
}
},
"event": "customer.loyalty.tier.prolonged",
"loyalty_tier": {
"id": "ltr_pudTGWasuIqxdiDM0go31OV1"
},
"source": {
"banner": "Get 2 points for every month you're a customer when your loyalty tier is prolonged.",
"object_id": "camp_fkZ28pe7DUAEmmabofkxHI8N",
"object_type": "campaign"
},
"active": true,
"start_date": "2022-11-02T13:00:00.000Z",
"expiration_date": "2023-03-03T14:30:00.000Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P1D"
},
"validity_day_of_week": [
0,
1,
2,
3,
4,
5
],
"object": "earning_rule",
"automation_id": "auto_fpfYyNcpVskgwcrs21kQ91Wx",
"metadata": {
"Type": "Custom Event - proportional points for extending a loyalty tier based on customer metadata."
}
}
]The access token received from the authorization server in the OAuth 2.0 flow.
The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign.
"camp_rRsfatlwN7unSeUIJDCYedal"
Customize the request body based on the type of earning rules you would like to create. The request body is an array of objects. The required minimum properties to include in the payload for each object are event and loyalty. Additionally, if you choose to add a validity_timeframe, you must include a start_date. Furthermore, an earning rule event type:
customer.segment.entered requires a segment objectcustom_event objectcustomer.loyalty.tier.joined, customer.loyalty.tier.left, customer.loyalty.tier.upgraded, customer.loyalty.tier.downgraded, customer.loyalty.tier.prolonged requires a loyalty_tier objectThis is an object representing an earning rule for a paid order.
A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance.
"val_248vs7tUjlIE"
An object that defines the number of points that will be added to a loyalty card and how the points will be added.
FIXED adds a fixed number of pointsPROPORTIONAL adds points proportionally based on a pre-defined ratioShow child attributes
The number of points to be added to the loyalty card.
FIXED Defines how the points will be added to the loyalty card. FIXED adds a fixed number of points.
Formula used to dynamically calculate the rewarded points.
Defines the event which triggers the earning rule to add points to a loyalty card.
order.paid an event defined by the Voucherify API corresponding to an order status PAID.order.paid A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date.
true indicates an active earning rulefalse indicates an inactive earning ruleStart date defines when the earning rule starts to be active. Activation timestamp is presented in the ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it will inherit the campaign start date by default.
"2022-02-02T13:00:00.000Z"
Expiration date defines when the earning rule expires. Expiration timestamp is presented in the ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it will inherit the campaign expiration date by default.
"2022-03-03T14:30:00.000Z"
Defines the configuration for pending points. Pending points can be used only with the order.paid event.
Show child attributes
Defines the type of the period during which the points are in the pending state. Currently, only DAY value is accepted.
DAY Defines for how long the points are in the pending state. The minimum value is 1, maximum is 90.
1 <= x <= 90Defines the loyalty point expiration rule. This expiration rule applies only to this earning rule and supersedes expiration_rules defined in the voucher.loyalty_card object.
Show child attributes
Type of period. Can be set for MONTH or FIXED_DAY_OF_YEAR. MONTH requires the period_value field. FIXED_DAY_OF_YEAR requires the fixed_month and fixed_day fields.
FIXED_DAY_OF_YEAR, MONTH Value of the period. Required for the period_type: MONTH.
Type of rounding of the expiration period. Optional for the period_type: MONTH.
END_OF_MONTH, END_OF_QUARTER, END_OF_HALF_YEAR, END_OF_YEAR, PARTICULAR_MONTH Value of rounding of the expiration period. Required for the rounding_type.
Determines the month when the points expire; 1 is January, 2 is February, and so on. Required for the period_type: FIXED_DAY_OF_YEAR.
1 <= x <= 12Determines the day of the month when the points expire. Required for the period_type: FIXED_DAY_OF_YEAR.
1 <= x <= 31Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.start_date required when including the validity_timeframe.
Show child attributes
Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a duration of PT1H will be valid for a duration of one hour.
"PT1H"
Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an interval of P2D will be valid every other day.
"P2D"
Integer array corresponding to the particular days of the week in which the voucher is valid.
0 Sunday1 Monday2 Tuesday3 Wednesday4 Thursday5 Friday6 Saturday0, 1, 2, 3, 4, 5, 6 Determines the hours of validity, e.g. to create a happy hours scenario.
Show child attributes
Defines the recurring period(s) when the resource is active. The periods should not overlap.
Show child attributes
Defines the starting hour of validity in the HH:mm format. The resource is inactive before this time.
"12:00"
Integer array corresponding to the particular days of the week in which the resource is valid.
0 Sunday1 Monday2 Tuesday3 Wednesday4 Thursday5 Friday6 Saturday0, 1, 2, 3, 4, 5, 6 Defines the ending hour of validity in the HH:mm format. The resource is inactive after this time.
"14:00"
The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format.
Returns an array of earning rule objects.
Assigned by the Voucherify API, identifies the earning rule object.
Timestamp representing the date and time when the earning rule was created. The value is shown in the ISO 8601 format.
Show child attributes
The number of points to be added to the loyalty card.
FIXED Defines how the points will be added to the loyalty card. FIXED adds a fixed number of points.
Formula used to dynamically calculate the rewarded points.
Contains the custom earning rule name and parent campaign.
Show child attributes
A unique campaign identifier assigned by the Voucherify API.
Defines the object associated with the earning rule. Defaults to campaign.
campaign Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard.
The type of the object represented by JSON. Default is earning_rule.
earning_rule For internal use by Voucherify.
The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format.
A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance.
Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format.
A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date.
true indicates an active earning rulefalse indicates an inactive earning ruleDefines the event which triggers the earning rule to add points to a loyalty card.
"order.paid, customer.segment.entered, customer.loyalty.tier.upgraded, customer.loyalty.tier.downgraded, customer.loyalty.tier.prolonged, customer.loyalty.tier.joined, customer.loyalty.tier.left"
Defines the configuration for pending points. Pending points can be used only with the order.paid event.
Show child attributes
Defines the type of the period during which the points are in the pending state. Currently, only DAY value is accepted.
DAY Defines for how long the points are in the pending state. The minimum value is 1, maximum is 90.
1 <= x <= 90Start date defines when the earning rule starts to be active. Activation timestamp is presented in the ISO 8601 format. The earning rule is inactive before this date. If you do not define the start date for an earning rule, it will inherit the campaign start date by default.
Expiration date defines when the earning rule expires. Expiration timestamp is presented in the ISO 8601 format. The earning rule is inactive after this date. If you do not define the expiration date for an earning rule, it will inherit the campaign expiration date by default.
Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.start_date required when including the validity_timeframe.
Show child attributes
Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a duration of PT1H will be valid for a duration of one hour.
"PT1H"
Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an interval of P2D will be valid every other day.
"P2D"
Integer array corresponding to the particular days of the week in which the voucher is valid.
0 Sunday1 Monday2 Tuesday3 Wednesday4 Thursday5 Friday6 Saturday0, 1, 2, 3, 4, 5, 6 Determines the hours of validity, e.g. to create a happy hours scenario.
Show child attributes
Defines the recurring period(s) when the resource is active. The periods should not overlap.
Show child attributes
Defines the starting hour of validity in the HH:mm format. The resource is inactive before this time.
"12:00"
Integer array corresponding to the particular days of the week in which the resource is valid.
0 Sunday1 Monday2 Tuesday3 Wednesday4 Thursday5 Friday6 Saturday0, 1, 2, 3, 4, 5, 6 Defines the ending hour of validity in the HH:mm format. The resource is inactive after this time.
"14:00"
Defines the loyalty point expiration rule. This expiration rule applies only to this earning rule and supersedes expiration_rules defined in the voucher.loyalty_card object.
Show child attributes
Type of period. Can be set for MONTH or FIXED_DAY_OF_YEAR. MONTH requires the period_value field. FIXED_DAY_OF_YEAR requires the fixed_month and fixed_day fields.
FIXED_DAY_OF_YEAR, MONTH Value of the period. Required for the period_type: MONTH.
Type of rounding of the expiration period. Optional for the period_type: MONTH.
END_OF_MONTH, END_OF_QUARTER, END_OF_HALF_YEAR, END_OF_YEAR, PARTICULAR_MONTH Value of rounding of the expiration period. Required for the rounding_type.
Determines the month when the points expire; 1 is January, 2 is February, and so on. Required for the period_type: FIXED_DAY_OF_YEAR.
1 <= x <= 12Determines the day of the month when the points expire. Required for the period_type: FIXED_DAY_OF_YEAR.
1 <= x <= 31Was this page helpful?