younifyd
Menu

Update Earning Rule

Update Earning Rule

PUT/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}

Use it in a workflow

  1. Add a step and choose the Voucherify connector.
  2. Pick the Update Earning Rule action (under Loyalties).
  3. Fill in the fields below, then reference the result from later steps as {{updateEarningRule.response.data}}.

Request

Path parameters

campaignIdstringrequired

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`.

earningRuleIdstringrequired

A unique earning rule ID.

Request body

Enter the body as JSON in the step's Body field.

validation_rule_idstring

A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance.

loyaltyoneOf

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 `points` - `PROPORTIONAL` adds points proportionally based on a pre-defined ratio

sourceobject

Contains the custom earning rule name and parent campaign.

bannerstring

Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard.

activeboolean

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 rule - `false` indicates an *inactive* earning rule

start_datestring (date-time)

Start 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.

expiration_datestring (date-time)

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.

pending_pointsobject

Defines the configuration for pending points. Pending points can be used only with the `order.paid` event. Pass `null` to remove pending points from the earning rule.

period_typestring

Defines the type of the period during which the points are in the pending state. Currently, only `DAY` value is accepted.

One ofDAY

period_valueinteger

Defines for how long the points are in the pending state. The minimum value is 1, maximum is 90.

expiration_rulesobject

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.

period_typestring

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.

One ofFIXED_DAY_OF_YEARMONTH

period_valueinteger

Value of the period. Required for the `period_type: MONTH`.

rounding_typestring

Type of rounding of the expiration period. Optional for the `period_type: MONTH`.

One ofEND_OF_MONTHEND_OF_QUARTEREND_OF_HALF_YEAREND_OF_YEARPARTICULAR_MONTH

rounding_valueinteger

Value of rounding of the expiration period. Required for the `rounding_type`.

fixed_monthinteger

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`.

fixed_dayinteger

Determines the day of the month when the points expire. Required for the `period_type: FIXED_DAY_OF_YEAR`.

validity_timeframeobject

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`.

durationstring

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.

intervalstring

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.

validity_day_of_weekarray<integer>

Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday

validity_hoursobject

Determines the hours of validity, e.g. to create a happy hours scenario.

dailyarray<object>3 fields

Defines the recurring period(s) when the resource is active. The periods should not overlap.

metadataobject

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.

json
{
  "validation_rule_id": "val_248vs7tUjlIE",
  "loyalty": null,
  "source": {
    "banner": "Order Paid - You will get 100 points"
  },
  "active": false,
  "start_date": "2022-02-02T13:00:00.000Z",
  "expiration_date": "2022-03-03T14:30:00.000Z",
  "pending_points": {
    "period_type": "DAY",
    "period_value": 0
  },
  "expiration_rules": {
    "period_type": "FIXED_DAY_OF_YEAR",
    "period_value": 0,
    "rounding_type": "END_OF_MONTH",
    "rounding_value": 0,
    "fixed_month": 0,
    "fixed_day": 0
  },
  "validity_timeframe": {
    "duration": "PT1H",
    "interval": "P2D"
  },
  "validity_day_of_week": [
    0
  ],
  "validity_hours": {
    "daily": [
      {
        "start_time": "12:00",
        "days_of_week": [
          {}
        ],
        "expiration_time": "14:00"
      }
    ]
  },
  "metadata": {}
}

Response

Returns 200 with an object. Read it in later steps with {{updateEarningRule.response.data.<field>}}.

Need more? See the Voucherify guide for connection setup and behaviour shared by every action.