Documentation

Issue Rewards

Create a reward template, redeem it to a recipient, and optionally have Davi issue it automatically with a trigger.

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_typeContent comes from
platformDavi renders it from content_template
externalYour 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"
  }'
FieldMeaning
identifierThe recipient; see Recipients
scopeRequired. A label of your choosing for this redemption, passed on to an external generator in reward.generate
idempotency_keyUp to 64 characters. A repeat with the same key returns the first redemption instead of issuing again
metadataOptional 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.

typevalueUse when
cardA card uidYou tapped or scanned a card
linkA Davi linkYou scanned a QR code or were handed a URL
walletA wallet addressYou already resolved the recipient
usernameA usernameThey told you who they are on Davi
user_idA user uuidYou 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": … }. Poll GET /rewards/deliveries/{delivery_uuid} until it reports completed (with a transaction_id) or failed.

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
  }'
FieldMeaning
trigger_scopesPatterns describing the condition. Unrelated to OAuth scopes
deduplication_window_secondsThe 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:

PatternFires on
activity.checked_inEvery check-in
activity.checked_in:firstA person's first check-in
activity.checked_in:count:user:5A person's fifth check-in, exactly
activity.checked_in:count:activity:100The 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