Skip to main content
PUT
Update earning rule

Authorizations

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

Path Parameters

earningRuleId
string
required

Identifies the earning rule. Format lern_[a-f0-9]+.

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

Body

application/json

Request body schema for PUT /v2/loyalties/earning-rules/{earningRuleId}.

error
Custom error message configuration · object | null

Default error returned when rule validation fails. On create, omit the field or set it to null to store no error. On update, omit the field or set it to null to keep the stored error. The response omits error when none is stored.

start_date
string<date-time> | null

Sets the date-time from which the rule is active. A calendar date (YYYY-MM-DD) is accepted and stored as midnight UTC. Set to null to clear the start. start_date must be earlier than end_date. On update, an omitted date keeps the stored value and is included in that comparison.

end_date
string<date-time> | null

Sets the date-time until which the rule is active. A calendar date (YYYY-MM-DD) is accepted and stored as midnight UTC. Set to null to clear the end. On update, an omitted date keeps the stored value.

metadata
object | null

Arbitrary key-value metadata. The response always returns an object. On create, omit the field or set it to null to store {}. On update, omit the field to keep stored keys, set null to clear them, or send an object to merge those keys into the stored object.

name
string

Sets the earning rule name.

Required string length: 1 - 200
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.

earnings
object[]

Replaces the earning list. An item whose id matches a stored lernei_ id replaces that item. An omitted id, or an id that is not on this rule, creates an item and the server assigns the id. Items left out of the array are removed. At least one item.

Minimum array length: 1
validity_hours
object | null

Sets the hours during which the rule is active. Omit the field or set it to null to keep the stored value. The response always returns validity_hours.

trigger_limits
object | null

Sets the cooldown and frequency limits for the trigger. Omit the field or set it to null to keep the stored value. The response always returns trigger_limits.

earning_limits
object | null

Sets how many points this rule can award. Omit the field or set it to null to keep the stored value. The response always returns earning_limits.

Response

Updated earning rule

Response body schema for PUT /v2/loyalties/earning-rules/{earningRuleId}.

id
string
required

Earning rule ID (lern_...).

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

Earning rule name.

Maximum string length: 200
status
enum<string>
required

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

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

Earning definitions of the rule. Contains at least one earning.

Minimum array length: 1
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.

validity_hours
object
required

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

start_date
string<date-time> | null
required

Date-time from which the rule is active. Can be null.

end_date
string<date-time> | null
required

Date-time until which the rule is active. Can be null.

trigger_limits
object
required

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.

earning_limits
object
required

Limits how many points this rule can award. Always present. Defaults to no global limit (global.type NO_LIMIT and global.limits []).

metadata
object
required

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

created_at
string<date-time>
required

Creation timestamp (ISO 8601).

updated_at
string<date-time> | null
required

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

object
string
required

Object type marker. Always earning_rule.

Allowed value: "earning_rule"
error
Custom error message configuration · object

Default error configuration. Absent when not configured.