This page covers issuing a reward: create a reward template, then redeem it to
a recipient. Organization actions use an
org-scoped token. All paths are under
https://api.davi.social/api/v1.
A reward template defines what can be issued: points, plus optional content such as a badge, certificate, coupon, voucher, ticket or attachment.
1. Create a reward template
Scope reward:create.
curl -X POST "https://api.davi.social/api/v1/organizations/ORG_SLUG/rewards" \
-H "Authorization: Bearer ORG_SCOPED_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"organization_uuid": "ORG_UUID",
"name": "Check-in Badge",
"supply_total": null,
"content_config": { "storage_type": "platform" }
}'
organization_uuid, name and content_config are required. The template
always belongs to the organization in the path; organization_uuid must be
sent, and is the uuid from
GET /organizations/{organization_slug}.
Optional fields are description, category, activity_uuid (links the
template to an activity), supply_total (null is unlimited) and
required_entitlement, a membership entitlement the
recipient must hold. Omit points or send 0: issuing points is not open yet,
and any other value answers 400.
content_config.storage_type sets how the content is produced:
storage_type | Content comes from |
|---|---|
platform | Davi renders it from content_template |
external | Your webhook generates it (external_webhook_uuid); see reward.generate. Redemptions are asynchronous |
Templates start as drafts. Publish one by PATCHing its status (scope
reward:manage):
curl -X PATCH "https://api.davi.social/api/v1/rewards/REWARD_SLUG" \
-H "Authorization: Bearer ORG_SCOPED_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "status": "published" }'
status also takes draft, which returns a template to draft while it has no
redemptions, and archived, which withdraws it for good: an archived template
cannot be published again. A draft or archived template refuses redemption with
400.
2. Redeem a reward
Issue the reward to a recipient with POST /rewards/{reward_slug}/redeem
(scope reward:redeem):
curl -X POST "https://api.davi.social/api/v1/rewards/REWARD_SLUG/redeem" \
-H "Authorization: Bearer ORG_SCOPED_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"identifier": { "type": "username", "value": "ada" },
"scope": "single-use",
"idempotency_key": "unique-per-redemption"
}'
| Field | Meaning |
|---|---|
identifier | The recipient; see Recipients |
scope | Required. A label of your choosing for this redemption, passed on to an external generator in reward.generate |
idempotency_key | Up to 64 characters. A repeat with the same key returns the first redemption instead of issuing again |
metadata | Optional object recorded with the redemption |
Always send an idempotency_key, unique to the redemption you mean: one
per form response, per visit, per order. The key is checked across all of the
organization's redemptions, so reusing one for a different recipient or reward
returns the earlier redemption and issues nothing.
Recipients
identifier is an IdentifierRef, { "type": …, "value": … }. Every
endpoint that names a person takes the same shape, so a scanner can send
whatever a tap gave it without resolving the person first.
type | value | Use when |
|---|---|---|
card | A card uid | You tapped or scanned a card |
link | A Davi link | You scanned a QR code or were handed a URL |
wallet | A wallet address | You already resolved the recipient |
username | A username | They told you who they are on Davi |
user_id | A user uuid | You already know the Davi user. This is the uuid from GET /users/me, not the ID token's sub |
card and link resolve to the wallet behind the card, which can exist before
anyone has claimed it. A reward issued there waits for whoever claims the card;
see Rewarding Someone Without an Account.
An identifier that resolves to nothing answers 404 with identifier_unresolved.
Results
platform: the response is{ "status": "completed", "transaction_id": … }.external: the response is{ "status": "pending", "delivery_uuid": … }. PollGET /rewards/deliveries/{delivery_uuid}until it reportscompleted(with atransaction_id) orfailed.
The shape follows the template's storage_type, not the request, with one
exception: repeating an external redemption that has already completed
returns completed and its transaction_id. Handle both shapes in any code
that redeems, because changing a template's storage changes the response that
code receives.
The recipient reads the issued content with
GET /rewards/transactions/{transaction_id}; see
Read a User's Rewards.
Issue automatically with triggers
Read this if you want Davi to issue a reward when an event occurs, without a call from your service.
A reward trigger redeems a template when a matching event occurs. Create
one with POST /organizations/{organization_slug}/reward-triggers (scope
reward:manage):
curl -X POST \
"https://api.davi.social/api/v1/organizations/ORG_SLUG/reward-triggers" \
-H "Authorization: Bearer ORG_SCOPED_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Reward 5 check-ins",
"reward_template_uuid": "REWARD_UUID",
"trigger_scopes": ["activity.checked_in:count:user:5"],
"deduplication_window_seconds": 300
}'
| Field | Meaning |
|---|---|
trigger_scopes | Patterns describing the condition. Unrelated to OAuth scopes |
deduplication_window_seconds | The same trigger does not fire twice for a user within this window. Default 300; null disables it |
A trigger scope is an event type, optionally followed by a count condition:
| Pattern | Fires on |
|---|---|
activity.checked_in | Every check-in |
activity.checked_in:first | A person's first check-in |
activity.checked_in:count:user:5 | A person's fifth check-in, exactly |
activity.checked_in:count:activity:100 | The hundredth check-in to the activity |
Write the count as count:<scope>:<n>. count:5 without a scope is not a
condition and never matches.
When an activity check-in matches, Davi issues the reward to that user.
Next
- Read a User's Rewards: read the rewards a user holds.
- Run Activities and Check-ins: the events that fire triggers.
- Receive Webhooks: get notified on
reward.redeemed.