Skip to main content
POST
/
v2
/
loyalties
/
earning-rules
Create earning rule
curl --request POST \
  --url {protocol}://{host}/v2/loyalties/earning-rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-App-Id: <api-key>' \
  --header 'X-App-Token: <api-key>' \
  --data '
{
  "name": "<string>",
  "trigger": {
    "custom_event": {
      "schema_id": "<string>"
    },
    "segment": {
      "id": "<string>"
    }
  },
  "earnings": [
    {
      "effects": [
        {}
      ],
      "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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

X-App-Id
string
header
required
X-App-Token
string
header
required

Body

application/json

Request body for creating an earning rule.

name
string
required

Earning rule name.

Required string length: 1 - 200
trigger
object
required

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.

earnings
object[]
required

Earning definitions (rules and effects) evaluated when the trigger fires.

Minimum array length: 1
status
enum<string>

Initial status. Only DRAFT and ACTIVE are allowed at creation. Defaults to DRAFT.

Available options:
DRAFT,
ACTIVE
error
object | null

Default error returned when rule validation fails. Nullable.

validity_hours
object | null

Hours during which the rule is active. Defaults to { "type": "ANY_TIME" } when omitted. Nullable.

start_date
string<date-time> | null

Date-time from which the rule is active. Nullable.

end_date
string<date-time> | null

Date-time until which the rule is active. Nullable.

metadata
object | null

Arbitrary key-value metadata. Nullable.

trigger_limits
object | null

Cooldown and frequency limits for the trigger. Defaults to { "cooldown": { "type": "NO_COOLDOWN" }, "frequency": { "type": "NO_LIMIT" } } when omitted. Nullable.

Response

Earning rule created

Earning rule as returned by the API.

id
string

Earning rule ID (lern_...).

Pattern: ^lern_[a-f0-9]+$
name
string

Earning rule name.

Maximum string length: 200
status
enum<string>

Current status. DELETED also exists internally but deleted rules are excluded from API reads.

Available options:
DRAFT,
ACTIVE,
INACTIVE
earnings
object[]

Earning definitions of the rule.

trigger
object

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.

error
object | null

Default error configuration. Absent when not configured.

validity_hours
object

Validity hours. Always present; defaults to { "type": "ANY_TIME" }.

start_date
string<date-time> | null

Date-time from which the rule is active. Nullable.

end_date
string<date-time> | null

Date-time until which the rule is active. Nullable.

trigger_limits
object | null

Cooldown and frequency limits. In responses, frequency.limits is always an array (empty for NO_LIMIT).

metadata
object

Arbitrary key-value metadata. Always present (empty object when unset).

created_at
string<date-time>

Creation timestamp (ISO 8601).

updated_at
string<date-time> | null

Last update timestamp (ISO 8601). Null when never updated.

object
string

Object type marker. Always earning_rule.

Allowed value: "earning_rule"
Last modified on July 10, 2026