group (points, progress, badge or perk), a name, and switches that decide what it can do. Make one with POST /v1/units, change one with PATCH /v1/units/{id}. A change to a switch applies from then on and never changes anybody’s balance.
What each switch does
An earn-only unit (it cannot go down) is never spendable, usable or sendable: turning
goes_down off turns those off with it, and turning one of them on needs goes_down.
Spending and using
Two ways to take a unit from a person, for two different things. Both need a unit that can go down (an earn-only unit has nothing to take) and are all or nothing: if the person holds less than the amount above the unit’s lowest balance, the call isinsufficient_balance and nothing is taken. Both take a reference of your own (an order or scan ID), which is optional and can be used once per unit: a second use with it is reference_used, and a retry of the same request returns the first answer.
- Spend (
POST /v1/units/spend) is your server taking value for a reward: “a free coffee for 100 Beans”. It needs areason. The receipt hascause: "spend". - Use (
POST /v1/units/use) is a person redeeming the thing itself: a coupon at the till, a ticket at the door. It takes one by default. The receipt hascause: "use"and the webhookunit.usedfires.
Sending between people
A unit withsendable on can be moved from one person to another with POST /v1/units/send: two receipts, send and receive, that share a transfer ID and happen together or not at all.
- The sender must hold the amount above the unit’s lowest balance, and the receiver must be able to hold it (the cap).
- A person can send at most
send_cap_per_dayof it a day (100 unless you change it), counted in your project’s time zone. Past it the call israte_limited. - Both people must already be known to Lurk.
- What expires keeps its expiry: the receiver gets the sender’s clock.
- A send makes nothing. It is not counted as given or spent, so a thank-you never looks like issuing. Find the two receipts with
GET /v1/activity?transfer=<id>. - A send cannot be undone from one side. The way back is a send the other way.
- A unit is off by default: nothing can be sent until you turn
sendableon for that unit. - Units cannot be bought, cashed out or given a money value, and sending does not change that.
Giving by hand
An owner or admin can give the same amount of one unit to up to 200 people at once, in the dashboard. A project key and an agent cannot; Lurky can propose a give as a change card, and a person applies it.- People are
usr_…IDs or your own IDs, each counted once, and each gets one receipt with the optionalnote. An ID that matches nobody is returned innot_found, and nothing is created for it. - The unit’s own settings apply. Someone it cannot be given to (a cap it would pass, for example) is skipped with the reason, and the others still get theirs.
count_againstnames a rule with a budget in this unit. The give is counted in that budget, and if it would pass it, nothing is given.POST /v1/units/give/previewtakes the same input and writes nothing: it says who would get the unit, who would be skipped and why, and what is left of the budget. A project key and an agent can call it.
The leaderboard
GET /v1/units/{unit}/leaderboard lists the top of one unit, most first: up to limit people (1 to 10, 10 if you leave it out). Each row has a rank, the person’s usr_… ID and the amount; people with the same amount share a rank (1, 1, 3). Only people holding more than 0 are listed, and a person merged into another is not (what they held moved to the person kept). It never carries your own identifier for a person or an email, so it is safe to show to your own users. The agent tool may leave the unit out: it then uses the oldest unit that someone holds, or the oldest unit if nobody holds any.