Points Exchange API
Use these APIs to perform points exchange transactions and offer new exchange options to your customers.
Last updated
Was this helpful?
Use these APIs to perform points exchange transactions and offer new exchange options to your customers.
Last updated
Was this helpful?
POST /transactions
The following types of of exchange options are currently supported by the qiibee API
All points_to_external_rewards
requests have been migrated to exchange
type. Depending on the value of brandB_token_id
that's passed, determines the exact type of exchange.
To get the value of brandB_token_id,
please check the Exchange partnerships endpoint.
The value of the points credited, will depend on the offramp value of Brand A's points and the onramp value of Brand B's points. The exchange rate is calculated as follows
exchange rate = Brand A token offramp value ÷ Brand B token onramp value
The value of the cryptocurrency that is credited, will depend on the market rate of said currency at the time this API call is made. Note that exchange to crypto is not available in the sandbox API.
The following fields are optional:
exchange_rate_override
: number - use this field to specify a different exchange rate from what you've configured.
eg. 1 point is 40 airline miles but you want to change it to 80 for a particular user based on their tier.
It will not overwrite the stored exchange rate
brandB_membership_number
: string - use this field to override the user's saved membership number only for this action. It will not overwrite the saved number in the account. The format followed is specified at .
If you try to exchange more points than the user currently has, you'll receive a 400
. The points/miles to be received will be calculated as the floor of the value obtained after multiplying the points to be burned with the exchange rate. When exchanging to crypto, the floor is not applied to the amount of crypto to be received.
Body:
amount
- The amount of brand A points to be burned. Can be an integer or string but not decimal/fraction.
user_auth_id
- The identifier by which a user is identified in your loyalty program.
Responses
Success: HTTP 202
Bad request: HTTP 400
Insufficient balance
User/Token does not exist
Exchange not allowed
Invalid membership number
This endpoint is used when a user redeems their points for an NFT. The request body remains the same as above with a few differences. The responses will be the same. The points to burn is calculated as
points_to_burn = ceil(NFT value (onramp) ÷ loyalty point onramp value)
Body (all fields are mandatory):
reward_type
: string - to indicate the type of transaction.
from_token_id
: number - the token ID of your loyalty point.
to_token_id
: number - the token ID of your NFT.
user_auth_id
: string - the auth ID of the user performing the exchange.
Example request:
GET /token-exchange-whitelist
This request returns the list of active exchange partnerships to the brands with whom you're connected. It contains the token IDs that you would need to pass in the request to perform exchange transactions.
To filter the exchange option by token types, send the token_to_types
list as a query param.
Success: HTTP 200
with data in the following format:
GET /transactions
This request returns paginated transaction history.
By default, it returns the last 100 transactions associated with your brand. The most recent transactions are returned first.
You can query transactions using the following query parameters:
limit
: (optional) sets the required limit of transaction history to be requested.
Defaults: 100
Maximum: 100
offset
: (optional) number of transactions to offset when getting the remaining transactions.
Default: 0
user_auth_id
: (optional) Use this parameter to query transactions for a particular user of your brand. If not passed returns all the transactions for your brand. Can be used along with limit
and offset.
types
: (optional) Use this parameter to query transactions for specific loyalty event types. The events must be sent in a list.
Defaults: List of all loyalty event types
token_id
: (optional) This will let you query the transactions for a specific token ID.
Defaults: All tokens that belong to the brand.
from_time
: (optional) queries for transactions that begin from the specified datetime.
Defaults: The datetime at which the brand was created in the qiibee database.
to_time
: (optional) queries for transactions until the specified datetime.
Defaults: The current datetime.
The params, limit and offset, work exactly as they’re used in SQL.
Success: HTTP 200
with data in the following format:
If there are no transactions, an empty transactions
list will be returned. total_tx_count
is the total number of transactions available for the given params.
Bad data: HTTP 404
with error message
eg. not found
Transaction reversal: In the event that an exchange transaction fails for any reason, qiibee will initiate a reversal for the failed exchange transaction. You can choose to notify your users regarding the failure via email. To setup the reversal email for your brand, please write to us at .
The exchange limits can be updated in the . You can use these to check if the points to be burned is within the specified limit.