Skip to content

Wallet Management APIs

The Wallet Management API is designed to manage tenant wallets, handle balance requests between parent and child tenants, process transactions, and generate financial reports. This API enables businesses to maintain wallet balances, request funds, approve/reject requests, and access detailed transaction history and ledger reports.

API Documentation

Base URL

Terminal window
# Production
https://apis.prayog.io/gateway/wallet/api
# Sandbox
https://sandbox-apis.prayog.io/gateway/wallet/api

Available Endpoints

  1. Health Check
  2. Get Wallet Balance
  3. Request Balance
  4. Get My Balance Requests
  5. Get Child Balance Requests
  6. Approve Balance Request
  7. Reject Balance Request
  8. Create Transaction
  9. Get Transactions
  10. Generate Invoice
  11. List Invoices
  12. Get Ledger Reports
  13. Get Profit Loss Reports
  14. Get Date Range Reports
  15. Get Tax Reports
  16. Get Ledger Summary

API Endpoints

1. Health Check

Checks if the service is running and healthy.

Endpoint: GET /ping

Response
{
"message": "Wallet controller is working!"
}

2. Get Wallet Balance

Retrieve the current balance for the specified tenant.

Endpoint: GET /balance

Request Headers:

{
"X-Tenant-Id": "tenant-123",
"authorization": "Bearer token-123",
"api-key": "1234567890" // Optional if authorization is provided
}
Response
{
"success": true,
"data": {
"balance": 50000,
"tenantId": "tenant-123",
"lastUpdated": "2024-03-20T10:30:00.000Z"
}
}

3. Request Balance

Create a new balance request from a child tenant to a parent tenant.

Endpoint: POST /balance-request

Request Headers:

{
"Content-Type": "application/json",
"X-Tenant-Id": "tenant-123",
"X-User-Id": "user-456",
"authorization": "Bearer token-123"
}

Request Body Parameters

ParameterRequiredTypeDescription
amountYesnumberAmount to request (min: 1)
walletCustomerIdYesstringWallet Customer ID
remarksNostringAdditional remarks for the request
Request Body Example
{
"amount": 1000,
"walletCustomerId": "customer-123",
"remarks": "Business expansion needs"
}
Response
{
"success": true,
"data": {
"id": "req-789",
"parentTenantId": "parent-tenant-001",
"subTenantId": "tenant-123",
"walletCustomerId": "customer-123",
"requestedAmount": "1000",
"status": "PENDING",
"remarks": "Business expansion needs",
"createdAt": "2024-03-20T10:30:00.000Z",
"updatedAt": "2024-03-20T10:30:00.000Z"
},
"message": "Balance request created successfully",
"timestamp": "2024-03-20T10:30:00.000Z"
}

4. Get My Balance Requests

Retrieve all balance requests submitted by the calling tenant to their parent tenant.

Endpoint: GET /my-balance-requests

Request Headers:

{
"X-Tenant-Id": "tenant-123",
"authorization": "Bearer token-123"
}

Query Parameters

ParameterTypeRequiredDescription
pagenumberNoPage number (default: 1)
limitnumberNoItems per page (default: 10)
statusstringNoFilter by request status (PENDING, APPROVED, REJECTED)
walletCustomerIdstringNoFilter by wallet customer ID
minAmountnumberNoFilter by minimum requested amount
maxAmountnumberNoFilter by maximum requested amount
createdAtFromstringNoFilter by creation date from (ISO)
createdAtTostringNoFilter by creation date to (ISO)
remarksSearchstringNoSearch in remarks field
Response
{
"success": true,
"message": "Successfully retrieved my balance requests",
"data": [
{
"id": "req-789",
"parentTenantId": "parent-tenant-001",
"subTenantId": "tenant-123",
"walletCustomerId": "customer-123",
"requestedAmount": "1000",
"status": "PENDING",
"remarks": "Business expansion needs",
"createdAt": "2024-03-20T10:30:00.000Z",
"updatedAt": "2024-03-20T10:30:00.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
},
"timestamp": "2024-03-20T10:30:00.000Z"
}

5. Get Child Balance Requests

Retrieve all balance requests submitted by child tenants to the calling parent tenant.

Endpoint: GET /child-balance-requests

Request Headers:

{
"X-Tenant-Id": "parent-tenant-123",
"authorization": "Bearer token-123"
}

Query Parameters

Same as “Get My Balance Requests”, plus:

ParameterTypeRequiredDescription
subTenantIdstringNoFilter by sub tenant ID
tenantNamestringNoFilter by tenant name
Response
{
"success": true,
"message": "Successfully retrieved child balance requests",
"data": [
{
"id": "req-789",
"parentTenantId": "parent-tenant-123",
"subTenantId": "child-tenant-456",
"tenantName": "Child Corp",
"walletCustomerId": "customer-456",
"requestedAmount": "2000",
"status": "PENDING",
"createdAt": "2024-03-20T11:00:00.000Z",
"updatedAt": "2024-03-20T11:00:00.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
},
"timestamp": "2024-03-20T11:00:00.000Z"
}

6. Approve Balance Request

Approve a balance request from a child tenant. Only parent tenants can perform this action.

Endpoint: PUT /balance-requests/:requestId/approve

Request Headers:

{
"Content-Type": "application/json",
"X-Tenant-Id": "parent-tenant-123",
"X-User-Id": "user-123",
"authorization": "Bearer token-123"
}

Request Body Parameters

ParameterRequiredTypeDescription
approvedAmountNonumberAmount to approve (for partial approval)
approvalRemarksNostringRemarks for approval
Request Body Example
{
"approvedAmount": 1000,
"approvalRemarks": "Approved after verification"
}
Response
{
"success": true,
"data": {
"id": "req-789",
"status": "APPROVED",
"approvedAmount": "1000",
"approvalRemarks": "Approved after verification",
"approvedBy": "poi-123-user",
"approvedAt": "2024-03-20T12:00:00.000Z",
"updatedAt": "2024-03-20T12:00:00.000Z"
},
"message": "Balance request full approved successfully",
"timestamp": "2024-03-20T12:00:00.000Z"
}

7. Reject Balance Request

Reject a balance request from a child tenant. Only parent tenants can perform this action.

Endpoint: PUT /balance-requests/:requestId/reject

Request Headers:

{
"Content-Type": "application/json",
"X-Tenant-Id": "parent-tenant-123",
"X-User-Id": "user-123",
"authorization": "Bearer token-123"
}

Request Body Parameters

ParameterRequiredTypeDescription
remarksNostringReason for rejection
Request Body Example
{
"remarks": "Insufficient documentation provided"
}
Response
{
"success": true,
"data": {
"id": "req-789",
"status": "REJECTED",
"rejectionReason": "Insufficient documentation provided",
"rejectedBy": "user-123",
"rejectedAt": "2024-03-20T12:00:00.000Z",
"updatedAt": "2024-03-20T12:00:00.000Z"
},
"message": "Balance request rejected successfully",
"timestamp": "2024-03-20T12:00:00.000Z"
}

8. Create Transaction

Create a new transaction. Requires either Authorization header OR X-Api-Key header.

Endpoint: POST /create-transaction

Request Headers:

{
"Content-Type": "application/json",
"X-Tenant-Id": "tenant-123",
"authorization": "Bearer token-123", // Optional if X-Api-Key is provided
"X-Api-Key": "1234567890" // Optional if authorization is provided
}

Request Body Parameters

ParameterRequiredTypeDescription
customerIdYesstringCustomer ID
entityTypeYesstringEntity type (e.g., ‘order’)
referenceIdYesstringReference ID (e.g., Order ID)
currencyYesstringCurrency code (e.g., ‘INR’)
chargesYesarrayArray of charge objects
metadataNoarrayArray of metadata objects

Charge Object Structure

ParameterRequiredTypeDescription
headYesstringCharge head (e.g., ‘GST’)
amountYesnumberCharge amount
hsnOrSacYesstringHSN or SAC code
isBillableYesbooleanIs the charge billable
absorbedByYesstringWho absorbs the charge (e.g., ‘merchant’)
transactionTypeYesstringTransaction type (‘debit’/‘credit’)
chargedAtNostringDate string
metadataNoarrayCharge metadata
breakupNoarrayCharge breakup
Request Body Example
{
"customerId": "cust_1234567890",
"entityType": "order",
"referenceId": "REF123456",
"currency": "INR",
"charges": [
{
"head": "GST",
"amount": 10050,
"hsnOrSac": "998314",
"isBillable": true,
"absorbedBy": "merchant",
"transactionType": "debit",
"metadata": [
{ "key": "tax_rate", "value": "18%" }
]
}
],
"metadata": [
{ "key": "source", "value": "web" }
]
}
Response
{
"success": true,
"data": {
"transactionId": "txn_987654321",
"status": "SUCCESS"
},
"message": "Transaction created successfully",
"timestamp": "2024-03-20T12:00:00.000Z"
}

9. Get Transactions

Retrieve transactions with optional filtering and sorting.

Endpoint: POST /transactions/filter

Request Headers:

{
"Content-Type": "application/json",
"X-Tenant-Id": "tenant-123",
"authorization": "Bearer token-123"
}

Request Body Parameters (Filters)

ParameterTypeDescription
pagenumberPage number (default: 1)
limitnumberItems per page (default: 10, max: 100)
transactionFiltersobjectFilter by IDs, entity types, references, date range
chargeFiltersobjectFilter by charge details, amounts, date range
sortingobjectSort by field and order
includeOptionsobjectInclude related data (charges, metadata)
Request Body Example
{
"page": 1,
"limit": 10,
"transactionFilters": {
"customerIds": ["cust_1234567890"],
"transactionDateRange": {
"start": "2024-01-01T00:00:00Z",
"end": "2024-01-31T23:59:59Z"
}
},
"sorting": {
"sortBy": "createdAt",
"sortOrder": "DESC"
},
"includeOptions": {
"includeCharges": true
}
}

10. Generate Invoice

Generate an invoice using the external invoice service.

Endpoint: POST /generate-invoice

Request Headers:

{
"Content-Type": "application/json",
"X-Tenant-Id": "tenant-123",
"authorization": "Bearer token-123"
}

Request Body Parameters

ParameterRequiredTypeDescription
templateNameYesstringTemplate name (e.g., ‘B2BInvoice’)
productIdYesstringProduct ID
buyerCustomerIdYesstringBuyer Customer ID
sellerCustomerIdYesstringSeller Customer ID
startDateYesstringStart date (YYYY-MM-DD)
endDateYesstringEnd date (YYYY-MM-DD)
Request Body Example
{
"templateName": "B2BInvoice",
"productId": "SMLPYOG",
"buyerCustomerId": "SMLPYOG000000000675615",
"sellerCustomerId": "SMLPYOG000000000675615",
"startDate": "2025-10-01",
"endDate": "2025-10-13"
}

11. List Invoices

Fetch invoices from external invoice service with filters.

Endpoint: GET /invoices

Query Parameters

ParameterRequiredDescription
startDateYesStart date (YYYY-MM-DD)
endDateYesEnd date (YYYY-MM-DD)
limitNoMax items per page
pageNoPage number
productIdYesProduct code
customerIdNoCustomer ID
templateNameNoTemplate name
search_in_custom_varsNoSearch text

12. Get Ledger Reports

Fetch ledger reports by head.

Endpoint: GET /ledgers/reports/heads

Query Parameters

ParameterRequiredDescription
customerIdYesCustomer ID
fromDateNoFrom date (ISO)
toDateNoTo date (ISO)
currencyNoCurrency code
headsNoComma-separated head names

13. Get Profit Loss Reports

Fetch profit-loss reports.

Endpoint: GET /ledgers/reports/profit-loss

Query Parameters

ParameterRequiredDescription
customerIdYesCustomer ID
fromDateYesFrom date (ISO)
toDateYesTo date (ISO)
includeBreakdownNoInclude breakdown (boolean)

14. Get Date Range Reports

Fetch date-range reports for a customer.

Endpoint: GET /ledgers/customers/:customerId/reports/date-range

Query Parameters

ParameterRequiredDescription
fromDateYesFrom date (ISO)
toDateYesTo date (ISO)
currencyYesCurrency code

15. Get Tax Reports

Fetch tax reports for a customer.

Endpoint: GET /ledgers/customers/:customerId/reports/tax

Query Parameters

ParameterRequiredDescription
fromDateYesFrom date (ISO)
toDateYesTo date (ISO)
currencyYesCurrency code

16. Get Ledger Summary

Fetch ledger summary for a customer.

Endpoint: GET /ledgers/customers/:customerId/summary

Query Parameters

ParameterRequiredDescription
fromDateYesFrom date (ISO)
toDateYesTo date (ISO)
currencyYesCurrency code

Error Codes

Error CodeTitleDescription
400Bad RequestThe request payload is invalid or missing required fields.
401UnauthorizedAuthentication token or API key is missing or invalid.
500Internal Server ErrorAn unexpected error occurred on the server.

Data Models

Balance Request

  • id: Unique request ID
  • parentTenantId: Parent tenant ID
  • subTenantId: Sub tenant ID
  • walletCustomerId: Wallet customer ID
  • requestedAmount: Amount requested
  • approvedAmount: Amount approved
  • status: Request status (PENDING, APPROVED, REJECTED)
  • remarks: Request remarks
  • approvalRemarks: Approval remarks
  • rejectionReason: Rejection reason
  • approvedBy: User ID who approved the request
  • rejectedBy: User ID who rejected the request
  • createdAt: Creation timestamp
  • updatedAt: Last update timestamp

Transaction

  • customerId: Customer ID
  • entityType: Entity type (e.g., ‘order’)
  • referenceId: Reference ID
  • currency: Currency code
  • charges: Array of Charge objects
  • metadata: Array of Metadata objects

Charge

  • head: Charge head (e.g., ‘GST’)
  • amount: Charge amount
  • hsnOrSac: HSN or SAC code
  • isBillable: Boolean indicating if charge is billable
  • absorbedBy: Who absorbs the charge
  • transactionType: ‘debit’ or ‘credit’
  • chargedAt: Timestamp
  • metadata: Array of Metadata objects
  • breakup: Array of ChargeBreakup objects

Invoice Generation Request

  • templateName: Name of the invoice template
  • productId: Product identifier
  • buyerCustomerId: Customer ID of the buyer
  • sellerCustomerId: Customer ID of the seller
  • startDate: Reporting period start date
  • endDate: Reporting period end date

Ledger Report Query

  • customerId: Target customer ID
  • fromDate: Start date for report
  • toDate: End date for report
  • currency: Currency for values
  • heads: Specific ledger heads to filter (optional)