Debit/Credit Wallet
Learn how to use the Debit/Credit Wallet API to adjust user wallet points, manage loyalty rewards, and effectively offer users real-time incentives.
Overview
The Debit/Credit Wallet API allows you to update the points in the user's wallet by either debiting (subtracting) or crediting (adding) them. The wallet ledger balance is updated immediately after the transaction is processed.
This API provides flexibility for a range of scenarios where point adjustments are required for the user's wallet, as follows:
- Redeeming Wallet Points in Transactions: Enable users to redeem wallet points during transactions, providing them with a seamless way to utilize their loyalty rewards.
- Crediting Points to User Wallets: Add points to the user wallet as and when needed.
This API is essential for businesses managing customer loyalty programs. It allows you to update loyalty balances based on user actions or rewards instantly. For example, if a user earns 100 loyalty points after a purchase, the API instantly credits the points to their wallet. Later, if the user returns the item, the API can debit the corresponding points, ensuring the loyalty balance remains accurate. By leveraging this API, businesses can enhance user experience and build trust through accurate and immediate loyalty point transactions.
Example Use Case
Consider an example user case where a user makes a purchase worth $200 and has a balance of 200 points in their wallet. You can use the Debit/Credit Wallet API to redeem wallet points during this transaction as follows:
-
Determine Redemption Details: With a conversion rate of 1 point = $1, this redemption translates into a $50 discount.
-
Calculate Final Payable Amount: Apply the $50 discount to the purchase amount of $200. The userโs final payable amount is $150.
-
Invoke the Debit API: Invoke the Debit API to deduct the redeemed points from the user's wallet after completing the transaction successfully. Pass the transaction details, such as
walletId
,identity
, andpoints
to be debited (in this case, 50) in the API request. -
Update Wallet Ledger: Update the wallet balance to 150 points, ensuring the user wallet accurately reflects the redeemed points.
Example Credit Use Case
This above example illustrates a scenario specific to the Debit API. Consider an example where the current user balance is 200 points and earns 50 points after a transaction. In this case, the Credit API is invoked to add points to the user wallet, updating the wallet balance to 250 points.
Base URL
Here is an example base URL from the account in the India region:
https://in1.api.clevertap.com/1/promo/creditDebit
Region
To identify the API endpoint for the region of your account, refer to Region.
Headers
For more information about API headers used while processing API requests, refer to Headers.
HTTP Method
POST
Query Parameters
Parameter | Description | Required/Optional | Type | Sample Value |
---|---|---|---|---|
identity | Identifies the user associated with the wallet. | Required | String | KMN@123 |
walletId | Unique identifier assigned to each user wallet within the application. | Required | String | wallet_123 |
Body Parameters
Parameter | Description | Required/Optional | Datatype | Sample Value |
---|---|---|---|---|
description | Description of the transaction. | Optional | String | Redemption for order |
points | Loyalty points value to be debited/credited. Only positive point values are accepted. Requests with negative points for debit or credit transactions are rejected. | Required | Numeric | 100 |
transactionType | Type of transaction. Valid values are:
| Required | String | DEBIT |
bucketType | Specifies the bucket where points are credited, either ACTIVE or PENDING . This applies only to credit transactions. If no value is provided, points are credited to the ACTIVE bucket by default. | Optional | String | PENDING or ACTIVE |
activationDuration | Specifies the time duration before points move from the Pending bucket to the Active bucket. This applies only to credit transactions. If the value is set to zero, the credit is applied immediately. The format is space separated as follows: Xw Xd Xh Xm, where: Xw Xd Xh Xm where:
| Optional | Number | 2d 3h |
expiryDuration | Specifies the expiry duration. This applies only to credit transactions. If not provided, the system defaults to the wallet-level expiry. The format is space separated as follows: Xw Xd Xh Xm where:
| Optional | Number | 1w 2d |
orderId | References the bill number to associate the transaction with a specific order ID for potential future refunds. This enables tracking transactions for return sales. | Optional | String | ORD12345 |
saleChannel | The source channel for the transaction (e.g., Mobile, Web, POS). Applies to both credit and debit transactions created via API. | Optional | String | POS |
locationId | Identifier for the transaction location (e.g., store code). Applies to both credit and debit transactions created via API. | Optional | String | BAN123 |
saleAmount | Gross order value tied to the transaction. Applies to both credit and debit transactions. | Optional | Numeric | 2499.00 |
metadata | The keyโvalue pairs to persist with the transaction. Applies to both credit and debit transactions. | Optional | Object | { "cashierId": "C42", "campaign": "FESTIVE25" } |
Metadata Validation
- You may include any number of keyโvalue pairs.
- Do not send an empty object ({}) for metadata. If metadata is present but empty, the request fails with error code 777 and message metadata key value can not be empty.
- All keyโvalue pairs in metadata are saved with each credit/debit transaction in the wallet transaction store.
Debit Transactions Validation
If debit transactions exceed available active points, they are not processed to prevent overdrafts in the wallet.
Sample Request
Here is an example request to the Debit/Credit Wallet API, including the headers needed to authenticate the request:
curl -X POST "https://in1.api.clevertap.com/1/promo/creditDebit?identity=krishna123&walletId=1963" \
-H "X-CleverTap-Account-Id: ACCOUNT_ID" \
-H "X-CleverTap-Passcode: PASSCODE \
-H "Content-Type: application/json"
Find CleverTap Account ID and Passcode
You can find the CleverTap Account ID and Passcode from the CleverTap dashboard by navigating to the Settings > Project page on the CleverTap dashboard.

Find CleverTap Project Details
The following are the request payloads for debit/credit transactions:
{
"description": "Reward points for purchase",
"points": 100,
"transactionType": "DEBIT",
"orderId": "order123",
"saleChannel": "POS",
"saleAmount": 1000,
"locationId": "BAN123",
"metadata":
{
"RuleId": "123",
"vouchercode": "oomco123",
"brand": "amazon"
}
}
{
"description": "Reward points for purchase",
"points": 100,
"transactionType": "CREDIT",
"bucketType": "ACTIVE",
"expiryDuration": "1d 10m",
"activationDuration": "3d",
"orderId": "order123",
"saleChannel": "POS",
"saleAmount": 1000,
"locationId": "BAN123",
"metadata":
{
"RuleId": "123",
"vouchercode": "oomco123",
"brand": "amazon"
}
}
Sample Response
The sample response returns the updated wallet balance and transaction details in the following format:
{
"status": "success",
"record": {
"saleAmount": 1000,
"walletId": 1963,
"metadata": {
"RuleId": "123",
"brand": "amazon",
"vouchercode": "oomco123"
},
"activePoints": 120.46,
"orderId": "order123",
"saleChannel": "POS",
"locationId": "BAN123",
"description": "Reward points for purchase",
"tnxId": "wl_EjKlltmdYqrJYDiRaRcGv",
"points": 100
}
}
On a successful API call, the system debits or credits the specified points from the user's wallet based on the transactionType
in the request body and returns a response indicating the updated wallet balance and transaction details.
Note
Response fields are illustrative. The
saleChannel
,locationId
,saleAmount
,metadata
response fields affect what is stored, not necessarily what is returned. If your implementation returns any of these fields, document them in your environmentโs response schema.
Errors
To know the errors applicable to the Debit/Credit Wallet API, refer to API Error Cases.
Updated 1 day ago