Redemption API

About Redemption

The Redemption API enables you to expend (or "burn") end-user asset (called an Award in the user and admin dashboards), while logging what they were redeemed for, such as a discount on a purchase. Functional use cases include:

  1. Redeeming store credits during the check out flow

  2. Redeeming loyalty points for perks, like an upgrade to a first-class seat

Although the Master Award Control -> Burn API also offers the option to effectively delete assets from the Village Ledger, the Redemption API is the preferred method for use cases in which users are trading their assets for something else, because it allows you to log what they were redeeming those asset for.

To see more about real-world Redemption use cases, check out our Guides->.

Important: in order to be redeemed using the Redemption API, awards need to be created as 'non-monetary award' types. Status & Badges cannot be burned/redeemed.

Endpoint

POST/networks/YOUR_NETWORK_ID/redemption

Where 'YOUR_NETWORK_ID' is replaced with your actual Network ID.

API Field Overview

Body Fields

Field NameJSON KeyTypeDescriptionRequired

User

user

string

The user. May be email or user_id.

Yes

Asset Short Name

asset_short_name

string

Short Name of the asset to be redeemed. This is the same Short Name created and viewable on the Village admin dashboard.

Yes

Amount

amount

string

Amount to be redeemed.

Yes

Metadata

metadata

object

Additional metadata. See Metadata fields for options.

No

Metadata

Field NameJSON KeyTypeDescriptionRequired

Reference ID

reference_id

string

An optional identifier that can be used for reporting purposes.

No

Redemption Timestamp

redemption_timestamp

integer

The Unix timestamp of when the redemption occurred. If this is blank, Village will use the timestamp the activity was received via the Village API as the Redemption Timestamp.

No

Redeemed For

redeemed_for

string

An optional descriptor that can be used to record what the user received in return for the redeemed asset.

No

Redeemed For Amount

redeemed_for_amount

string

An optional descriptor that can be used to record the amount of something the user received in return for the redeemed asset.

No

Description

description

string

A description of the redemption.

No

Examples

Body

// Example Redemption Body
{
    "user": "johnny.redemption@villagelabs.co",
    "asset_short_id": "POINT",
    "amount": "100.00",
    "metadata": {
        "reference_id": "dpi_Ylo2Cfr8US8u1JIdAl2eZvKB",
        "redemption_timestamp": 1664900628,
        "redeemed_for": "discount",
        "redeemed_for_amount": "15%",
        "description": "Standard 100 token for 15% discount redemption."
    }
}

By Language

# Remember to replace 'Bearer YOUR_API_KEY' and 'YOUR_NETWORK_ID' with your actual API key and Network ID

import requests
import json

url = "https://api-ledger.villagelabs.net/networks/YOUR_NETWORK_ID/redemption"

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}

data = {
    "user": "johnny.redemption@villagelabs.co",
    "asset_short_name": "POINT",
    "amount": "100.00",
    "metadata": {
        "reference_id": "dpi_Ylo2Cfr8US8u1JIdAl2eZvKB",
        "redemption_timestamp": 1664900628,
        "redeemed_for": "discount",
        "redeemed_for_amount": "15%",
        "description": "Standard 100 token for 15% discount redemption."
    }
}

response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.json())

Last updated