The Get Unused Retainer Payments API returns a list of all retainer payments associated with a specific contact that have a remaining balance. This is essential for workflows where you want to automatically apply available credits to a new invoice or show a customer their "Available Fund Balance" in a custom portal.
At Kalki LLP, we use this endpoint to build "Smart Billing" logic that alerts account managers if a customer has an aging retainer that should be applied to their current outstanding work.
To fetch the list of unused retainers, perform a GET request targeting the contact's unique ID.
Endpoint: GET /contacts/{contact_id}/retainerpayments?organization_id={organization_id}
| Header Name | Value | Description |
Authorization | Zoho-oauthtoken {access_token} | Requires ZohoBooks.retainerinvoices.READ scope. |
The response returns a retainer_payments array. Each object details the original retainer amount and the unused_amount available for application.
Sample JSON Response:
{
"code": 0,
"message": "success",
"retainer_payments": [
{
"retainer_payment_id": "460000000026301",
"retainer_invoice_id": "460000000026295",
"date": "2023-11-15",
"payment_number": "RET-PAY-001",
"reference_number": "REF-7722",
"amount": 5000.00,
"unused_amount": 1250.00,
"status": "unused"
}
]
}
This script calculates the total "Credit Pool" from retainers for a specific customer before generating a new invoice.
// Target Contact ID
contactID = "460000000026049";
orgID = "123456789";
// Execute the GET request
response = invokeurl
[
url :"https://www.zohoapis.in/books/v3/contacts/" + contactID + "/retainerpayments?organization_id=" + orgID
type :GET
connection :"kalki_books_connection"
];
if(response.get("code") == 0)
{
retainerList = response.get("retainer_payments");
totalUnusedRetainers = 0.0;
for each ret in retainerList
{
totalUnusedRetainers = totalUnusedRetainers + ret.get("unused_amount").toDecimal();
}
info "Kalki Financial Health: Customer has " + totalUnusedRetainers + " available in retainers.";
}
else
{
info "Kalki Error: Could not fetch retainer data. " + response.get("message");
}
| Error Code | Meaning | Fix for Kalki LLP Developers |
| 2 | Invalid ID | The contact_id provided is incorrect or does not exist. |
| 57 | Unauthorized | Ensure your OAuth token includes Retainer Invoices scopes, not just Contacts. |
| 6024 | Wrong Org | The organization_id does not match the account context. |
| Empty List | No Retainers | The customer has no retainers, or all existing retainers have been fully applied. |
For kalkillp.com clients, retrieving this data programmatically provides:
Improved Cash Flow Visibility: Knowing exactly how much unearned revenue is sitting in the ledger.
Automated Credit Application: Building scripts that automatically apply retainer balances to invoices as soon as they are approved.
Customer Transparency: Allowing clients to see their "Prepaid Balance" in a custom-built Kalki dashboard.
Retainers are the lifeblood of service-based businesses. KalkiLLP specializes in building sophisticated retainer-management workflows that ensure your advance payments are tracked, applied, and reported with 100% accuracy.