Overview
The Heartswill for NGOs API lets your organisation's own systems talk to Heartswill: your website's donation form, your payment gateway's webhook, your CRM or your reporting tools. It is a JSON API over HTTPS.
| Base URL | https://app.ngo.heartswill.com/api/v1 |
| Format | JSON in, JSON out. Amounts in rupees. Dates as YYYY-MM-DD, times in ISO 8601 UTC. |
| Version | v1. Additive changes don't change the version; breaking changes get a new one with notice. |
Authentication
Owners and admins create keys in the app under API keys. A key looks like hwn_live_ followed by 48 characters and is shown once. Send it on every request:
Authorization: Bearer hwn_live_3f9a…Server side only. Never put a key in a website's JavaScript, a mobile app or a public repository. The API refuses cross-origin browser calls. If a key leaks, revoke it in the app; it stops working immediately.
Scopes
| Scope | Allows |
|---|---|
| donations:write | Record donations and issue receipts |
| donations:read | List donations, with donor IDs masked to the last four characters |
| receipts:read | Look up a receipt by number or verify code |
| programmes:read | List projects and deliveries |
| impact:read | Read totals for the year and units delivered |
Give each integration its own key with only the scopes it needs. A website donation form needs donations:write; an impact widget needs only impact:read.
Rate limits and retries
Each key can make 120 requests a minute. Over that you get 429 with Retry-After: 60. On 5xx or a network error, retry with the same external_ref: it is always safe.
Errors
Errors return a JSON body and an HTTP status:
{
"error": {
"code": "invalid_request",
"message": "donor.pan must look like ABCDE1234F",
"docs": "https://heartswill.com/ngos/developers/api"
}
}| Status | Code | What to do |
|---|---|---|
| 401 | unauthorized | Key missing, malformed or revoked. Check the header. |
| 403 | forbidden | The key lacks the scope. Create a key with it. |
| 404 | not_found | No such endpoint or record in your organisation. |
| 422 | invalid_request | Fix the field named in the message. Don't retry unchanged. |
| 429 | rate_limited | Wait 60 seconds, then retry. |
| 500 | server_error | Retry with the same external_ref. |
Endpoints
/donations
donations:writeRecords a donation, matches or creates the donor, and issues a receipt unless you set issue_receipt to false. Returns 201 for a new donation, or 200 with duplicate: true if this external_ref was already recorded.
| Field | Type | |
|---|---|---|
| external_ref | string | Required. Your unique ID, such as a Razorpay payment ID. Makes retries safe. |
| amount_inr | number | Required. Rupees, e.g. 1500 or 1500.50. |
| donor.name | string | Required. |
| donor.email / donor.phone | string | Used to match a returning donor. |
| donor.pan or donor.aadhaar | string | Needed for the donation statement (Form 113). Stored encrypted. |
| donor.kind | string | individual (default) or organisation. |
| donor.address, city, state, pincode | string | Printed on the receipt. |
| mode | string | online (default), upi, bank, cheque, cash or kind. |
| received_on | date | Defaults to today (India time). Can't be in the future. |
| donation_type | string | others (default), corpus or specific. |
| purpose, notes, payment_reference | string | Optional. |
| fcra | boolean | True for foreign contribution. Kept out of the donation statement and not deduction-eligible. |
| issue_receipt | boolean | Default true. |
curl -X POST https://app.ngo.heartswill.com/api/v1/donations \
-H "Authorization: Bearer $HEARTSWILL_NGO_KEY" -H "Content-Type: application/json" \
-d '{"external_ref":"pay_TyXaZl5tn28x5r","amount_inr":1500,"mode":"upi",
"donor":{"name":"Riya Kapoor","email":"riya@example.org","pan":"ABCDE1234F"}}'{
"donation_id": "6f1c…",
"duplicate": false,
"external_ref": "pay_TyXaZl5tn28x5r",
"receipt": {
"number": "ASHA/2026-27/0042",
"status": "issued",
"eligible_for_deduction": true,
"verify_code": "9c1e2a7f40b3d6e1",
"verify_url": "https://app.ngo.heartswill.com/verify/9c1e2a7f40b3d6e1",
"issued_on": "2026-11-15"
}
}Deduction eligibility follows the same rules as the app: your organisation needs a valid donor deduction approval, and cash above ₹2,000, gifts in kind and FCRA gifts are not eligible.
/donations
donations:readLists donations, newest first. Query: since and until (dates), limit (1–200, default 50) and before (the next_before value from the previous page).
{
"data": [
{
"donation_id": "6f1c\u2026",
"external_ref": "pay_TyXaZl5tn28x5r",
"source": "api",
"amount_inr": 1500,
"mode": "upi",
"received_on": "2026-11-15",
"financial_year": "2026-27",
"donation_type": "others",
"fcra": false,
"donor": {
"name": "Riya Kapoor",
"kind": "individual",
"id_type": "pan",
"id_last4": "234F"
},
"receipt_number": "ASHA/2026-27/0042",
"receipt_status": "issued",
"created_at": "2026-11-15T06:12:09Z"
}
],
"next_before": null
}/receipts/{number}
receipts:readFetches one receipt by its number (slashes are fine, e.g. /receipts/ASHA/2026-27/0042) or by its verify code. The content is the version frozen at issue.
/projects
programmes:readLists projects with their impact unit, unit cost, target and units delivered and sealed.
/deliveries
programmes:readLists deliveries, newest first, with status (recorded, submitted, sealed, rejected), photo and witness counts, proof hash and, once sealed, the public ledger number and story link. Query: project, limit, before.
/impact
impact:readTotals for the current financial year: amount raised, donations, donors, sealed deliveries and units per active project. Good for a live counter on your site.
{
"financial_year": "2026-27",
"raised_inr_fy": 1840000,
"donations_fy": 389,
"donors_total": 412,
"deliveries_sealed": 37,
"projects": [
{
"name": "Girl Child Education",
"unit": "school day",
"units_delivered": 2140,
"units_sealed": 1980
}
]
}/org
no keyReturns your organisation's name, registration flags and the calling key's name and scopes. Any valid key works. Handy as a connection test.
/verify/{code}
no keyPublic. Checks a receipt from the code in its QR and returns the organisation, number, amount, date, status and donor initials only. No key needed.
Recipe: Razorpay to receipts, automatically
Record a donation for every captured Razorpay payment, from the webhook, so it works even if the donor closes the tab. Use the payment ID as external_ref.
import crypto from "node:crypto";
export async function POST(req) {
const raw = await req.text();
const expected = crypto.createHmac("sha256", process.env.RAZORPAY_WEBHOOK_SECRET).update(raw).digest("hex");
if (req.headers.get("x-razorpay-signature") !== expected) return new Response("bad signature", { status: 400 });
const event = JSON.parse(raw);
if (event.event !== "payment.captured") return new Response("ignored");
const p = event.payload.payment.entity;
const res = await fetch("https://app.ngo.heartswill.com/api/v1/donations", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.HEARTSWILL_NGO_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
external_ref: p.id, // same payment, same receipt, however many retries
amount_inr: p.amount / 100, // Razorpay sends paise
mode: p.method === "upi" ? "upi" : "online",
payment_reference: p.id,
donor: { name: p.notes?.name || "Donor", email: p.email, phone: p.contact, pan: p.notes?.pan },
}),
});
if (res.status >= 500 || res.status === 429) return new Response("retry later", { status: 503 }); // Razorpay will retry
if (!res.ok) console.error("Heartswill refused donation", p.id, await res.text()); // fix data, don't loop
return new Response("ok");
}import os, requests
r = requests.post(
"https://app.ngo.heartswill.com/api/v1/donations",
headers={"Authorization": f"Bearer {os.environ['HEARTSWILL_NGO_KEY']}"},
json={"external_ref": "order-10293", "amount_inr": 2500, "mode": "bank",
"donor": {"name": "Kavya Traders LLP", "kind": "organisation", "pan": "AAAPL1234C"}},
timeout=15,
)
r.raise_for_status()
print(r.json()["receipt"]["verify_url"])Security and privacy
- Keys are stored only as SHA-256 fingerprints. Lose a key and you create a new one; nobody can recover it.
- Every write through the API is recorded in your organisation's audit log with the key that made it.
- Donor PAN and Aadhaar are encrypted at rest and returned only as the last four characters.
- Keys only ever see their own organisation's data.
- Collect donor IDs with consent and a clear notice. See Donor data and the DPDP Act.