Diwaan Connect API

Build on the record every trading business runs on.

One REST API for sales, stock, customers, suppliers, payments and the books. Create a sale and Diwaan moves the stock and posts the entries, exactly as the till does.

Coming Coming
curl https://api.diwaan.app/v1/sales \
  -H "Authorization: Bearer dk_test_4f9a2c81" \
  -H "Diwaan-Version: 2026-10-01" \
  -d branch="br_main_store" \
  -d "lines[0][item]"="RC-25" \
  -d "lines[0][quantity]"=2 \
  -d "payments[0][method]"="cash" \
  -d "payments[0][amount]"=76.00
Quickstart

First sale through the API in five minutes.

1

Open a sandbox Coming

Sign up and you get a sandbox business with sample items, customers, branches and a year of sales.

2

Create a key Coming

In Settings, then Connect, create a test key. Give it only the access your app needs.

3

Make a request

Create a sale. The response includes the stock movements and the journal entry it posted.

Every write returns its record

A sale created by the API is the same as a sale at the till. The response shows exactly what it did to stock and to the books, so your system and Diwaan never disagree.

Amounts are decimal strings or numbers with two places. Currency follows the business unless you set it.

{
  "id": "sale_10484",
  "branch": "br_main_store",
  "total": 76.00,
  "status": "paid",
  "stock_movements": [
    { "item": "RC-25", "quantity": -2, "location": "Main Store" }
  ],
  "journal_entry": {
    "id": "je_30419",
    "lines": [
      { "account": "Cash, Main Store", "debit": 76.00 },
      { "account": "Sales", "credit": 76.00 },
      { "account": "Cost of goods sold", "debit": 62.40 },
      { "account": "Stock", "credit": 62.40 }
    ]
  }
}
Reference

Resources

Base address https://api.diwaan.app/v1. JSON in, JSON out. Versioned by date in the Diwaan-Version header. Coming

ResourceWhat it holdsMethods
/v1/salesSales and receipts from any till or channelGETPOST
/v1/invoicesInvoices, quotes and credit notes ComingGETPOSTPATCH
/v1/itemsItems, prices, barcodes and unitsGETPOSTPATCH
/v1/stock-movementsEvery change in quantity, by branchGET
/v1/transfersStock moved between branchesGETPOST
/v1/customersCustomers, credit limits and balancesGETPOSTPATCH
/v1/suppliersSuppliers and their billsGETPOSTPATCH
/v1/paymentsMoney received and paidGETPOST
/v1/journal-entriesThe books, line by lineGETPOST
/v1/reportsTrial balance, profit and loss, money owedGET
Webhooks

Know the moment it happens.

Subscribe to events and Diwaan sends a signed request to your address. Failed deliveries retry for 3 days.

// Verify every webhook with your signing secret
const event = diwaan.webhooks.verify(body, headers["diwaan-signature"], secret);

if (event.type === "payment.received") {
  markOrderPaid(event.data.invoice, event.data.amount);
}
EventWhen it is sent
sale.createdA sale was completed at a till or by the API
invoice.sentAn invoice was sent to a customer
payment.receivedMoney came in against an invoice or sale
stock.below_minimumAn item fell below its minimum at a branch
transfer.receivedA branch checked in a stock transfer
bill.approvedA supplier bill was approved for payment
day.closedA till closed the day, with counted and expected cash
period.lockedAn accountant locked a period
Access

Keys, apps and limits.

API keys for your own business Coming

Create keys in Settings, then Connect. Each key has its own permissions and can be revoked at once. Test keys start with dk_test_.

OAuth for partner apps Coming

Building for many Diwaan businesses? Register as an integration partner and let each business connect your app with OAuth.

600requests per minute, per key
3 daysof webhook retries
12 monthsnotice before a version is retired Coming

Official libraries Coming

JavaScriptnpm i @diwaan/node
Pythonpip install diwaan
PHPcomposer require diwaan/diwaan

Start building today.

Every developer account includes a sandbox business with a year of sample data. Coming