Back online

Developers

Ivahi's books, from your own software.

Record sales, payments and stock in a company's Ivahi books, read its trial balance, profit and loss and balance sheet, or run Ivahi as the accounting behind your own app. Every call runs the same checks as Ivahi's own screens, so the books come out the same however a sale was made.

Two ways in

A shop already on Ivahi

The owner opens Settings, API keys, makes a key for your software and gives it to you. You call the company's own address, such as yourcompany.ivahi.com/api/v1. The owner can revoke it at any time.

Ivahi behind your own app

Sign up as an Ivahi owner and make a developer key on your account page. With it you create companies for your own customers, which you own and are billed for, and make each one's company key.

Quick start

With a company key (ivk_…), three calls take you from nothing to a sale in the books.

# 1. Which company, and which branches this key reaches
curl https://yourcompany.ivahi.com/api/v1/me \
  -H "Authorization: Bearer ivk_…"

# 2. The prices a sale can name (prices[].id)
curl "https://yourcompany.ivahi.com/api/v1/products?search=rice" \
  -H "Authorization: Bearer ivk_…"

# 3. Record a sale: Ivahi prices it, charges the company's VAT and posts the books
curl https://yourcompany.ivahi.com/api/v1/sales \
  -H "Authorization: Bearer ivk_…" \
  -H "Idempotency-Key: order-10452" \
  -H "Content-Type: application/json" \
  -d '{ "branchId": 3, "items": [{ "priceId": 17, "quantity": 2 }],
        "payment": { "method": "cash", "amountReceived": 5000 } }'

Creating companies for your app

With a developer key (ivd_…), on ivahi.com itself.

# Create a company you own (a Cloud company, billed to you)
curl https://ivahi.com/api/v1/companies \
  -H "Authorization: Bearer ivd_…" -H "Content-Type: application/json" \
  -d '{ "name": "Glow Salon", "address": "glow-salon", "category": "beauty" }'

# Ask until its status is "active" (about a minute)
curl https://ivahi.com/api/v1/companies/glow-salon -H "Authorization: Bearer ivd_…"

# Then make its company key, and use it on https://glow-salon.ivahi.com/api/v1
curl https://ivahi.com/api/v1/companies/glow-salon/keys \
  -H "Authorization: Bearer ivd_…" -H "Content-Type: application/json" \
  -d '{ "name": "Booking app" }'

The rules every call follows

Two kinds of key

A company key (ivk_…) works only on its company's address and reaches only the Cloud branches the owner chose, read only or read and write. A developer key (ivd_…) works only on ivahi.com, for /companies. Send either as Authorization: Bearer. A key is shown once and kept only as a fingerprint.

Writes are safe to retry

Every write needs an Idempotency-Key header: your own name for that one operation. Sending it again returns the first answer and records nothing twice; the same key with a different request is refused. A refused write frees its key, so you can fix the cause and send it again.

Ivahi prices, you name

A sale names a price and a number of packs, never an amount: Ivahi sells at the branch's list price and charges the company's VAT. A return refunds what the lines sold for. Your software cannot change a price.

The books' own rules

Short stock, a closed month, a credit limit, a branch on Simple accounting: each is refused in plain words, exactly as Ivahi's screens refuse it, and nothing is recorded. Branches run by an Ivahi Tab or PC are written only by that device, so a key cannot reach them.

120 calls a minute

Each key may make 120 calls a minute. Beyond that a call is refused with 429 and a Retry-After header saying how many seconds to wait, and does nothing.

Priced like a branch

There is no charge for the API itself: a Cloud branch costs ₦10,000 a month however it is used, in the browser or through the API. Companies you create are billed to you per branch.

AI assistants (MCP)

The same company key connects an AI assistant to the company's books through the Model Context Protocol. It gets 17 tools, one for each company endpoint below; a read-only key gets only the 9 that read. The same limits and rules apply, and a refusal comes back in words the assistant can act on.

# Claude Code
claude mcp add --transport http ivahi https://yourcompany.ivahi.com/api/mcp \
  --header "Authorization: Bearer ivk_…"

# Any MCP client that speaks Streamable HTTP
URL:    https://yourcompany.ivahi.com/api/mcp
Header: Authorization: Bearer ivk_…

Tools: ivahi_whoami, ivahi_list_products, ivahi_create_product, ivahi_list_categories, ivahi_list_customers, ivahi_create_customer, ivahi_list_suppliers, ivahi_record_sale, ivahi_return_sale, ivahi_void_sale, ivahi_record_customer_payment, ivahi_record_purchase, ivahi_record_expense, ivahi_trial_balance, ivahi_profit_and_loss, ivahi_balance_sheet, ivahi_journal.

Errors

Every refusal is { "error": { "code", "message" } }: branch on the code in your software, show the message to a person.

CodeStatusMeaning
no_company404The call reached no company: call the company's own address (or ivahi.com for /companies).
missing_key401No key was sent.
key_not_recognised401The key is not one Ivahi knows, or is the wrong kind for this address.
key_revoked401The owner revoked the key.
read_only_key403A read-only key tried to write.
branch_not_allowed403The key does not reach that branch.
branch_unavailable409The branch is closed, or run by its device.
payment_overdue402The company or branch is read-only until its Ivahi payment is made.
invalid_request400The request is not what the endpoint takes; the message names the field.
server_error500Ivahi could not finish the call; nothing was changed by it.
idempotency_conflict409The Idempotency-Key was used for a different request, or is still running.
key_owner_inactive403The owner who made the key is no longer an active owner.
refused422The books' own rules refused it (short stock, a closed month, a credit limit…); nothing was recorded.
not_found404No such record in the branches the key reaches (the same answer either way).
books_not_shown409The branch uses Simple accounting, so its books are not shown.
rate_limited429More than 120 calls in a minute by this key; wait Retry-After seconds.

Reference

Company calls: https://yourcompany.ivahi.com/api/v1. Company creation: https://ivahi.com/api/v1. Amounts are naira to the kobo; dates are YYYY-MM-DD, Lagos days. A field marked ? may be left out; a nested field without one is needed whenever its parent is sent.

Your key

GET/mecompany key, any

Which company and key

The company this key belongs to, what it may do, and the branches it reaches. Their ids are the branchId other calls take.

Takes nothing.

Answers 200: { company, key, branches }

Look-ups

GET/productscompany key, any

Products and prices

Products with each price a sale can name (prices[].id is the priceId a sale takes), the branches each price is for, and the units on each branch's shelf. Cost prices are never listed.

NameInTypeNotes
page?queryintegerDefault 1.
limit?queryintegerDefault 50.
search?querystring

Answers 200: { products, page, limit, total }

POST/productscompany key, read and write

Add a product

A new product with its prices, made exactly as the product form makes it. Prices go on the price lists of branches the key reaches (GET /me shows each branch's priceListId), each by the base unit or the pack; the first on each list is its default unless another is marked. The cost per base unit is a fact you state. No opening stock: record goods received with POST /purchases. No image: add one on the web.

Needs an Idempotency-Key header.

NameInTypeNotes
namebodystring
categoryIdbodyinteger
barcode?bodystring
manufacturer?bodystring
description?bodystring
baseUnitbodystring
packagingUnit?bodystring
unitsPerPack?bodyintegerDefault 1.
costPerBaseUnitbodynumber
lowStockThreshold?bodyinteger
pricesbodyobject[]At least 1. At most 20.
prices[].priceListIdbodyinteger
prices[].namebodystring
prices[].unitbodybase | pack
prices[].pricebodynumber
prices[].default?bodyboolean

Answers 201: { product } with its prices (their ids are the priceId a sale takes)

GET/categoriescompany key, any

Product categories

The company's product categories; their ids are the categoryId a new product takes.

Takes nothing.

Answers 200: { categories }

GET/customerscompany key, any

Customers and balances

Customers with what each owes, holds as credit, and may owe (their limit) at each branch the key reaches.

NameInTypeNotes
page?queryintegerDefault 1.
limit?queryintegerDefault 50.
search?querystring

Answers 200: { customers, page, limit, total }

POST/customerscompany key, read and write

Add a customer

A new customer: their details, their home branch (one the key reaches) and their credit limit there. A name already in use is refused.

Needs an Idempotency-Key header.

NameInTypeNotes
namebodystring
contactName?bodystring
phone?bodystring
email?bodystring
address?bodystring
homeBranchIdbodyinteger
creditLimit?bodynumberDefault 0.
notes?bodystring

Answers 201: { customer }

GET/supplierscompany key, any

Suppliers and balances

Suppliers with what each branch the key reaches owes them, or has paid ahead.

NameInTypeNotes
page?queryintegerDefault 1.
limit?queryintegerDefault 50.
search?querystring

Answers 200: { suppliers, page, limit, total }

Sales

POST/salescompany key, read and write

Record a sale

A sale in a Cloud branch. Lines name a priceId and a number of packs: Ivahi prices them from the branch's list and charges the company's VAT, so a sale never carries a price of its own. Payment is cash, electronic (name the branch's bank account), split, or credit (needs a customerId).

Needs an Idempotency-Key header.

NameInTypeNotes
branchIdbodyinteger
customerId?bodyinteger
customerName?bodystring
itemsbodyobject[]At least 1. At most 200.
items[].priceIdbodyinteger
items[].quantitybodyinteger
discount?bodynumberDefault 0.
paymentbodyobject
payment.methodbodycash | electronic | split | credit
payment.amountReceivedbodynumber
payment.bankAccountId?bodyinteger or null
payment.split?bodyobject[]At least 2. At most 4.
payment.split[].methodbodycash | electronic
payment.split[].amountbodynumber
payment.split[].bankAccountId?bodyinteger or null
notes?bodystring

Answers 201: { sale }: number, lines, totals, amount paid, balance

POST/sales/{saleId}/returnscompany key, read and write

Record goods returned

Goods coming back from a sale, by its line ids and packs. The refund is what those lines sold for, back through the sale's own payment or onto the customer's account; no more than is left can come back.

Needs an Idempotency-Key header.

NameInTypeNotes
itemsbodyobject[]At least 1. At most 200.
items[].lineIdbodyinteger
items[].quantitybodyinteger
items[].reasonbodystring
items[].restock?bodybooleanDefault true.
refundbodyoriginal_payment | account
returnDatebodystring
bankAccountId?bodyinteger or null
notes?bodystring
saleIdpathintegerThe sale's id, as POST /sales answered it.

Answers 201: { return, sale }

POST/sales/{saleId}/voidcompany key, read and write

Void a sale

Void a sale, with a reason. A sale that already had goods returned cannot be voided: return the rest instead.

Needs an Idempotency-Key header.

NameInTypeNotes
reasonbodystring
saleIdpathintegerThe sale's id, as POST /sales answered it.

Answers 200: { sale } now voided

Money and stock

POST/customer-paymentscompany key, read and write

Record a customer's payment

Money a customer paid at a branch. It settles their invoices there first; anything beyond is held as their credit.

Needs an Idempotency-Key header.

NameInTypeNotes
customerIdbodyinteger
branchIdbodyinteger
amountbodynumber
methodbodycash | electronic
bankAccountId?bodyinteger or null
datebodystring
reference?bodystring
notes?bodystring

Answers 201: { payment }

POST/purchasescompany key, read and write

Record goods received

Goods received from a supplier into a branch, with each line's packs, pack size, cost and expiry date as delivered. A branch on Simple accounting pays on arrival (send payment); a Full branch owes the supplier.

Needs an Idempotency-Key header.

NameInTypeNotes
branchIdbodyinteger
supplierIdbodyinteger
datebodystring
invoiceNumber?bodystring
notes?bodystring
itemsbodyobject[]At least 1. At most 200.
items[].productIdbodyinteger
items[].quantitybodyinteger
items[].unitsPerPackbodyinteger
items[].packagingUnitbodystring
items[].costPerPackbodynumber
items[].expiryDatebodystring
payment?bodyobject
payment.methodbodycash | electronic
payment.bankAccountId?bodyinteger or null

Answers 201: { purchase }

POST/expensescompany key, read and write

Record an expense

An expense a branch paid, in cash or from one of its bank accounts, posted to the account its category maps to.

Needs an Idempotency-Key header.

NameInTypeNotes
branchIdbodyinteger
categoryIdbodyinteger
descriptionbodystring
amountbodynumber
datebodystring
methodbodycash | electronic
bankAccountId?bodyinteger or null
paidTo?bodystring
reference?bodystring
notes?bodystring

Answers 201: { expense }

Reports

GET/reports/trial-balancecompany key, any

Trial balance

One branch's trial balance on a day (today if asOf is left out), exactly as the Ivahi Finance screen shows it. The branch must use Full accounting.

NameInTypeNotes
branchIdqueryinteger
asOf?querystring

Answers 200: { branchId, branch, asOf, accounts, totals }

GET/reports/profit-losscompany key, any

Profit and loss

One branch's profit and loss for a period (today if from and to are left out), exactly as the Ivahi Finance screen shows it. Full accounting only.

NameInTypeNotes
branchIdqueryinteger
from?querystring
to?querystring

Answers 200: { branchId, branch, fromDate, toDate, revenue, cogs, expenses, … }

GET/reports/balance-sheetcompany key, any

Balance sheet

One branch's balance sheet on a day, with whether it balances, exactly as the Ivahi Finance screen shows it. Full accounting only.

NameInTypeNotes
branchIdqueryinteger
asOf?querystring

Answers 200: { branchId, branch, asOfDate, assets, liabilities, equity, isBalanced, variance }

GET/journalcompany key, any

Journal entries

One branch's journal entries with their lines, newest first; filter by dates and by what made them (sourceType). Full accounting only.

NameInTypeNotes
branchIdqueryinteger
from?querystring
to?querystring
sourceType?querysale | purchase | expense | purchase_return | sale_return | payment_in | payment_out | sale_payment | order_deposit | stock_transfer | inventory_adjustment | payroll | bank_deposit | bank_withdrawal
page?queryintegerDefault 1.
limit?queryintegerDefault 50.

Answers 200: { branchId, branch, entries, total, page, totalPages }

Companies

GET/companiesdeveloper key, any

Your companies

The companies your owner account owns, newest first, with their status.

Takes nothing.

Answers 200: { companies }

POST/companiesdeveloper key, read and write

Create a company

A Cloud company you then own and are billed for, by the same rules as Add a business: email confirmed, the address free, at most 3 a day. It answers while its database is being made; asking again for an address you already own answers that company.

NameInTypeNotes
namebodystring
addressbodystring
categorybodysupermarket | pharmacy | fashion | electronics | food | beauty | hardware | other
agentCode?bodystring

Answers 202: { company } with status setting_up (200 when it already existed)

GET/companies/{address}developer key, any

One company's status

One of your companies, with its status: setting_up, active or suspended. Ask again until it is active.

NameInTypeNotes
addresspathstringThe company's address: the part before .ivahi.com.

Answers 200: { company }

POST/companies/{address}/keysdeveloper key, read and write

Make a company key

A company key (ivk_…) for one of your active companies, reaching the Cloud branches you name (all of them when left out). It is shown once; each call makes a new key.

NameInTypeNotes
namebodystring
access?bodyread | writeDefault "write".
branchIds?bodyinteger[]At least 1. At most 200.
addresspathstringThe company's address: the part before .ivahi.com.

Answers 201: { key, prefix, company, access, branches }