The Credit Balance API adds funds to a user's wallet. This endpoint creates a credit transaction and updates the wallet balance atomically. Use this endpoint to deposit funds, award bonuses, or process refunds to user accounts.
Method Endpoint Authentication POST /api/v1/credit-balanceSignature Required
This endpoint requires Signature-based Authentication . You must include the following headers:
Header Description x-signatureHMAC-SHA256 signature of the request x-timestampUnix timestamp (seconds) when the request was generated
Note: See Overview for detailed information on how signature authentication works and how to generate signatures.
Field Type Required Default Validation clientIdstring Yes - Min 1 character amountnumber Yes - Min: 0.01 descriptionstring No - Max 500 characters referencestring No - Max 255 characters, external reference ID
{
" clientId " : " CLIENT_001 " ,
" amount " : 100.50 ,
" description " : " Deposit via bank transfer " ,
" reference " : " BANK_TXN_123456 "
}
{
" status " : " success " ,
" message " : " Balance credited successfully " ,
" data " : {
" userId " : 123 ,
" clientId " : " CLIENT_001 " ,
" amount " : 100.50 ,
" type " : " credit " ,
" transactionId " : 456 ,
" balance " : 1600.50
}
}
Field Type Description statusstring Always "success" for successful requests messagestring Human-readable success message data.userIdinteger Internal user ID data.clientIdstring Client identifier data.amountnumber Amount that was credited data.typestring Transaction type: "credit" data.transactionIdinteger Unique transaction ID for this credit operation data.balancenumber | null New wallet balance after credit, or null if unavailable
{
" status " : " failed " ,
" message " : " Validation failed " ,
" data " : {
" errors " : {
" clientId " : [ " The clientId field is required. " ],
" amount " : [ " The amount field is required. " , " The amount must be at least 0.01. " ]
}
}
}
{
" status " : " failed " ,
" message " : " User not found " ,
" data " : null
}
{
" status " : " error " ,
" message " : " Invalid signature " ,
" data " : null
}
{
" status " : " failed " ,
" message " : " Failed to credit balance " ,
" data " : {
" error " : " Database connection failed "
}
}
curl -X POST https://wdcf.xerve.online/api/v1/credit-balance \
-H " Content-Type: application/json " \
-H " x-signature: YOUR_SIGNATURE " \
-H " x-timestamp: 1706802000 " \
-d ' {
"clientId": "CLIENT_001",
"amount": 100.50,
"description": "Deposit via bank transfer",
"reference": "BANK_TXN_123456"
} '
Note: To generate the signature, refer to the Overview documentation.
import axios from ' axios ' ;
// Import your signature generation function (see Overview)
import { generateSignature } from ' ./signature-utils ' ;
const API_BASE_URL = ' https://wdcf.xerve.online ' ;
const CLIENT_SECRET = ' your-secret-key ' ;
interface CreditBalanceData {
clientId : string ;
amount : number ;
description ?: string ;
reference ?: string ;
}
async function creditBalance ( data : CreditBalanceData ) {
const timestamp = Math . floor ( Date . now () / 1000 ) ;
// Generate signature (see Overview for implementation)
const signature = generateSignature ( {
method : ' POST ' ,
path : ' /api/v1/credit-balance ' ,
payload : data ,
secret : CLIENT_SECRET ,
timestamp
} ) ;
try {
const response = await axios . post (
`${ API_BASE_URL } /api/v1/credit-balance ` ,
data ,
{
headers : {
' Content-Type ' : ' application/json ' ,
' x-signature ' : signature ,
' x-timestamp ' : timestamp . toString ()
}
}
) ;
console . log ( ' Credited amount: ' , response . data . data . amount ) ;
console . log ( ' New balance: ' , response . data . data . balance ) ;
console . log ( ' Transaction ID: ' , response . data . data . transactionId ) ;
return response . data ;
} catch ( error : any ) {
console . error ( ' Error: ' , error . response ?. data || error . message ) ;
throw error ;
}
}
// Usage
creditBalance ( {
clientId : ' CLIENT_001 ' ,
amount : 100.50 ,
description : ' Deposit via bank transfer ' ,
reference : ' BANK_TXN_123456 '
} ) ;
import requests
# Import your signature generation function (see Overview)
from signature_utils import generate_signature
import time
API_BASE_URL = 'https://wdcf.xerve.online'
CLIENT_SECRET = 'your-secret-key'
def credit_balance(client_id: str, amount: float, description: str = None, reference: str = None):
timestamp = int(time.time())
payload = {
"clientId": client_id,
"amount": amount
}
if description:
payload["description"] = description
if reference:
payload["reference"] = reference
# Generate signature (see Overview for implementation)
signature = generate_signature(
method="POST",
path="/api/v1/credit-balance",
payload=payload,
secret=CLIENT_SECRET,
timestamp=timestamp
)
headers = {
"Content-Type": "application/json",
"x-signature": signature,
"x-timestamp": str(timestamp)
}
response = requests.post(
f"{API_BASE_URL}/api/v1/credit-balance",
json=payload,
headers=headers
)
response.raise_for_status()
data = response.json()
print(f"Credited amount: {data['data']['amount']}")
print(f"New balance: {data['data']['balance']}")
print(f"Transaction ID: {data['data']['transactionId']}")
return data
# Usage
if __name__ == "__main__":
credit_balance(
client_id="CLIENT_001",
amount=100.50,
description="Deposit via bank transfer",
reference="BANK_TXN_123456"
)
Atomic Operation : The credit operation is atomic - either both the transaction record and balance update succeed, or both fail. This ensures data consistency.Idempotency : The reference field can be used to track external transaction IDs. If you need strict idempotency, implement checks on your side before calling this endpoint.Minimum Amount : The minimum credit amount is 0.01. Requests with smaller amounts will be rejected.Currency : All amounts are in the default currency (USD). Currency conversion is not handled by this endpoint.Transaction Record : Each credit operation creates a transaction record that can be retrieved using the Get Transactions API .Negative Amounts : Do not send negative amounts to this endpoint. Use the Debit Balance API for deductions.User Deposits : Credit user wallet when they make a depositPromotional Bonuses : Award bonus credits to usersRefund Processing : Return funds to user walletsCorrection Adjustments : Fix balance discrepanciesOverview - Authentication and signature generation guideV1 Generate Auth Token API - Authenticate usersV1 Get Balance API - Check balance before/after creditingV1 Debit Balance API - Deduct funds from user walletV1 Get Transactions API - View transaction historyError Code Possible Causes Resolution 400 Missing/invalid fields, amount < 0.01 Check validation errors and ensure amount meets minimum 401 Invalid signature or expired timestamp Verify signature generation and ensure timestamp is current 404 User not found Verify clientId exists; may need to create user first 500 Database or transaction service failure Check server logs and retry; transaction may have failed