# OSuite > OSuite is accounting, GST billing and business apps for Indian and UAE businesses, on the desktop or in the cloud. Its Billing API lets a business's own websites raise invoices and take payments through its OSuite. ## Developers - [Billing API reference](https://osuite.business/developers/api.md): every endpoint, its fields and answers - [OpenAPI](https://osuite.business/developers/openapi.json): the same, as OpenAPI 3.1, with schemas for every request, answer and webhook: generate a client from it - [A first invoice in five minutes](https://osuite.business/developers/quickstart.md): Make a billing token, then make, post and email an invoice from your website’s server. - [Tokens and limits](https://osuite.business/developers/tokens-and-limits.md): Billing tokens, one per website; their limits, expiry, addresses, and the rate limit. - [Retries without duplicates](https://osuite.business/developers/retries.md): The Idempotency-Key header: send the same call again and get the same answer. - [Hosted checkout](https://osuite.business/developers/checkout.md): Send a cart, send the customer to OSuite’s pay page, and get them back once paid. - [Order inbox (desktop without a tunnel)](https://osuite.business/developers/order-inbox.md): For an OSuite your website cannot reach: offer a feed of orders that OSuite fetches when online. - [Webhooks](https://osuite.business/developers/webhooks.md): Your server told of invoices posted, payments received and checkouts paid or closed, signed. - [Customers abroad, and refunds](https://osuite.business/developers/customers-abroad.md): Invoices in the customer’s currency as exports, and credit notes for refunds and returns. - [Service details, periods and instalments](https://osuite.business/developers/service-details.md): Units, service periods and details printed under each item; site, job and matter numbers; paying in parts. - [When an invoice changes](https://osuite.business/developers/when-an-invoice-changes.md): An invoice cancelled, reissued under a new number, or given back its original number in OSuite. - [Proformas, renewals and paying first](https://osuite.business/developers/proformas.md): A bill before payment that is never a tax invoice; its invoice once paid. Charging exactly OSuite’s total. - [Errors and test mode](https://osuite.business/developers/errors-and-test-mode.md): What errors look like, and test keys. ## Product - [Apps](https://osuite.business/apps): every OSuite app - [Integrations](https://osuite.business/integrations): the services OSuite connects to - [Help](https://osuite.business/help): how-tos - [Pricing](https://osuite.business/pricing) --- ## Instructions for an AI building with this API You are helping me connect my website or app to OSuite's Billing API, so my site raises GST or VAT invoices and takes payments through my business's own OSuite instead of its own billing. Rules: - Base address: my OSuite's own address (I will tell you; it looks like https://YOUR-OSUITE). All paths start /api/v1. - One sale, one invoice, and it is OSuite’s. OSuite works out the GST and gives the number; your website shows the customer that number and that PDF, and never numbers or prints an invoice of its own. Two invoices for one sale would put your GST returns out of step with what your customer holds. - Authorization: Bearer . Make one under Your account › API tokens, choosing Bill through the Billing API, one per website. Keep it on your server: never in a browser or an app people download. A site on serverless hosting (Vercel, Netlify, AWS Lambda) calls from changing addresses: leave the token’s address list empty, and expect a note to the token’s owner about each new address. - Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=. - 120 calls a minute for a token. Each answer carries X-RateLimit-Limit and X-RateLimit-Remaining; past the limit, 429 with Retry-After in seconds: wait that long and send again. A token may also have a largest invoice (over it, 422) and a number of invoices a day (past it, 429 with no Retry-After, as it lasts until tomorrow: do not retry). Set both above your largest real values. - Never work out GST or totals yourself for the invoice: send the items; OSuite works out place of supply, GST, totals and the number. You may send expectTotal to be warned of a difference. - Errors answer { "error": "", "fieldErrors": { "": "" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits. - A test key (tick Test key when making the token) makes invoices that stay drafts marked TEST-: never posted, numbered, sent or paid, and in no GST return. Its proformas stay drafts too, and its checkouts take a test payment. As nothing is posted, a test key sends no webhooks. Instead, under Connections › Webhooks: Send a test checks your signature code, and Send a sample sends the latest real event of the kind you choose, signed, under an id starting evt_sample_ (nothing changes in OSuite), so your handler is tried on real data before you go live. Each event’s schema is in openapi.json. Build and test with a test key first. - Choose your website under Only events from when adding the webhook (Connections › Webhooks): it then hears only of the invoices, payments, proformas and checkouts your website made, including invoices reissued or renumbered in OSuite, which keep their website. Left as Everything in OSuite, it hears of every invoice, payment and proforma in OSuite: act only on yours. An invoice your website made has data.apiSource set to your token’s name (null for one made in OSuite); a token’s name cannot be changed, and a replaced token keeps it. Fetching any other with your token answers 404: answer the webhook 2xx and skip it, or it is tried again 5 more times. - Trying your handler before going live, under Connections › Webhooks: Send a test sends the event ping, { message }, to check your signature code. Send a sample sends the latest real event of the kind you choose, built as it was delivered and signed, under an id starting evt_sample_; an event that has not happened in this OSuite yet has none (Nothing to send yet). A sample is a real past event: handle one starting evt_sample_ as a dry run (check the signature, read it, fetch the document, log what you would do, answer 2xx) and change nothing, or it would mark a real order paid twice or cancel a live one. - For card or UPI payment on the site, use a hosted checkout and check GET /api/v1/checkout/{id} is paid before shipping; or, to keep the site's own gateway, make the invoice with post: false first, charge OSuite's total, then post it and record the payment (DELETE the draft if the customer does not pay). - Prices are per unit before tax; OSuite adds GST or VAT. - For a customer abroad, never hardcode an exchange rate: leave exchangeRate out and OSuite fills FBIL's reference rate for the invoice date (read the rate back from the answer's foreign.exchangeRate), or send one rate a day from one source you also price with. - A bill before payment (a renewal, an advance) is a proforma (POST /api/v1/proformas), never an invoice; make its invoice with /invoice once paid. Never issue a tax invoice before payment and change it later. - OSuite takes payment on the business’s own gateway account, connected under Connections › Payment gateways: Razorpay, Cashfree, PayU, PayPal, Stripe, Instamojo, CCAvenue, PhonePe, Paytm and, in the Gulf, Telr, N-Genius, Tabby and Tamara. It is the same account the business already has, so no new KYC. Razorpay takes payment from customers abroad once international payments are on in the Razorpay account and, in OSuite, Connections › Payment gateways › Razorpay has customers abroad ticked. A customer abroad pays in the invoice’s currency (USD, EUR…) on a gateway the business has connected that takes it, such as PayPal, Stripe, or Razorpay with international payments turned on in the Razorpay account and in OSuite (it charges USD and pays the business in rupees); Instamojo takes rupees only. The pay page offers only those that fit, and a checkout no connected gateway can take payment for is refused with 422 and the usual error body ({ error, fieldErrors: { currency } }). Autopay (mandates) is set up on a recurring invoice in OSuite, not through this API. - If my OSuite is a desktop the site cannot reach, use the order inbox feed instead of calling the API. - An invoice can be cancelled, reissued or renumbered in OSuite after the site made it: listen for the invoice.cancelled and invoice.renumbered webhooks (or the order inbox callback's reissuedFrom) and replace the number and PDF the site shows. - For services, send each item's unit as a word (year, month, trip, km...), its own periodFrom and periodTo, and any details (vehicle, route, person...) to print under it; instalments splits what is due by dates. Endpoints: - POST /api/v1/customers: Find or add a customer. Idempotency-Key. Body: name, email, phone, gstin, stateCode, street, city, pincode. Answers { customer: { id, name, email, phone, gstin, stateCode }, created }. - GET /api/v1/customers/{id}: A customer. Body: none. Answers { id, name, email, phone, gstin, stateCode }. - POST /api/v1/invoices: Make an invoice. Idempotency-Key. Body: customer*, items*, reference, date, dueDate, dueDays, placeOfSupply, currency, exchangeRate, exportType, periodFrom, periodTo, contractNo, siteAddress, jobNo, consignmentNo, matterNo, instalments, notes, post, send, expectTotal, returnUrl, exactTotal. Answers { invoice, sent, warnings }. - GET /api/v1/invoices: This website’s invoices. Body: none. Answers { invoices: [invoice] }. - GET /api/v1/invoices/{id}: An invoice. Body: none. Answers { id, number, test, status, date, dueDate, reference, customer, placeOfSupply, items: [{ description, hsn, qty, price, discountPct, gstRate, taxable, unit, periodFrom, periodTo, details }], taxable, tax, total, paid, due, currency, foreign?: { currency, total, due, exchangeRate }, exportType, periodFrom, periodTo, contractNo, siteAddress, jobNo, consignmentNo, matterNo, instalments: [{ dueDate, amount }], viewUrl, payUrl, source }. - DELETE /api/v1/invoices/{id}: Delete a draft. Body: none. Answers { deleted: true }. - GET /api/v1/invoices/{id}/pdf: The invoice as a PDF. Body: none. Answers application/pdf. - POST /api/v1/invoices/{id}/post: Post a draft. Body: none. Answers invoice. - POST /api/v1/invoices/{id}/send: Send an invoice. Body: channels. Answers { sent, warnings }. - POST /api/v1/invoices/{id}/payments: Record a payment. Idempotency-Key. Body: amount, mode, reference, date. Answers { paymentId, invoice }. - POST /api/v1/invoices/{id}/credit-notes: Credit an invoice. Idempotency-Key. Body: reason, items, date. Answers { creditNote: { id, number, date, reason, total, applied, left }, invoice }. - POST /api/v1/proformas: Make a proforma. Idempotency-Key. Body: customer*, items*, reference, date, dueDate, dueDays, placeOfSupply, currency, exchangeRate, exportType, periodFrom, periodTo, contractNo, siteAddress, jobNo, consignmentNo, matterNo, instalments, notes, send, expectTotal, returnUrl, exactTotal, validUntil, validDays. Answers { proforma: { id, number, test, status, date, validUntil, reference, customer, items, taxable, tax, total, currency, foreign?, exportType, invoiceId, viewUrl, payUrl, source } }. - GET /api/v1/proformas/{id}: A proforma. Body: none. Answers proforma. - GET /api/v1/proformas/{id}/pdf: The proforma as a PDF. Body: none. Answers application/pdf. - POST /api/v1/proformas/{id}/invoice: Invoice a paid proforma. Idempotency-Key. Body: payment, date, send. Answers { invoice, proforma, warnings }. - POST /api/v1/proformas/{id}/cancel: Cancel a proforma. Body: none. Answers proforma. - POST /api/v1/usage: Send usage. Idempotency-Key. Body: subscription*, meter*, quantity*, date, unit. Answers { reading: { id, recurring, meter, quantity, forDate, billed } }. - POST /api/v1/checkout: Start a hosted checkout. Idempotency-Key. Body: customer*, items*, currency, exchangeRate, exportType, successUrl*, cancelUrl, reference, send. Answers { checkout: { id, status, url, expiresAt, invoice }, warnings }. - GET /api/v1/checkout/{id}: A checkout. Body: none. Answers { id, status, url, expiresAt, invoice }. Order inbox feed (desktop without a tunnel): - GET ?after=, with Authorization: Bearer . - 200 with JSON { "orders": [order], "next": "" } and the header X-OSuite-Signature: sha256=. At most 200 orders an answer, and 2 MB. - As the body of POST /api/v1/invoices, with "id" (your order id, unique) and, for an order already paid, "paid": { amount, mode, reference }. "test": true makes that one order a TEST draft even on a live feed, for a sample. "liveOnly": true holds a real sale while the feed is in test mode, and bills it once the feed goes live. - POST with JSON { orderId, status: "billed" | "failed", reissuedFrom?, invoice?: { id, number, status, date, total, due, viewUrl, payUrl, pdf }, error?, warnings? }, where pdf is the posted invoice as base64, and reissuedFrom is the number the sale’s invoice had before: when OSuite reissues an invoice or gives it back its original number, the order is told again, and you replace that number and PDF with these. It comes with headers X-OSuite-Timestamp and X-OSuite-Signature: sha256=.">. Answer 2xx; OSuite tells you again until you do. Full reference: https://osuite.business/developers/api.md, and https://osuite.business/developers/openapi.json with schemas for every request, answer and webhook (generate typed client code from it; still check fields you rely on). Ask me for my OSuite's address and what my site sells, then build it. --- # OSuite Billing API reference Your OSuite’s own address: the cloud edition’s, or a desktop’s Remote access address. Calls go there directly; OfinIT is not in between. Authorization: Bearer . Make one under Your account › API tokens, choosing Bill through the Billing API, one per website. Keep it on your server: never in a browser or an app people download. A site on serverless hosting (Vercel, Netlify, AWS Lambda) calls from changing addresses: leave the token’s address list empty, and expect a note to the token’s owner about each new address. ### POST /api/v1/customers Find or add a customer. Finds a customer by GSTIN, then email, then mobile number; adds one when none matches and a name is given. Answers 201 when added, 200 when found. Needs an Idempotency-Key header. Body (JSON): - `name` (string): Needed when no customer matches; up to 120 characters. - `email` (string): Matched without regard to case. - `phone` (string): Matched on its last 10 digits. - `gstin` (string): The customer’s tax number: a GSTIN in India (matched first; sets the state code), a TRN or VAT number elsewhere. - `stateCode` (string): Two digits, e.g. 27 for Maharashtra; sets the place of supply. - `street` (string): Address, for a new customer. - `city` (string): For a new customer. - `pincode` (string): For a new customer. Answers: { customer: { id, name, email, phone, gstin, stateCode }, created } Example body: ```json { "name": "Mehta Engineering", "email": "buy@mehta.in", "gstin": "24AABCM1234A1ZD" } ``` ### GET /api/v1/customers/{id} A customer. One customer by the id OSuite gave. Answers: { id, name, email, phone, gstin, stateCode } ### POST /api/v1/invoices Make an invoice. Makes an invoice and posts it: OSuite works out the place of supply, GST, totals and the invoice number. With post: false it stays a draft: number is in the answer but null until it is posted, and its totals already include GST, the same as once posted. If no payment gateway the business connected takes its currency from this customer, the invoice is still made, with payUrl null and a warning saying so (only a checkout is refused for this). A total you send as expectTotal is checked against OSuite’s and a difference reported in warnings; OSuite’s is the invoice’s. Refused within the token’s limits (largest invoice, invoices a day). An invoice that cannot be posted (goods not in stock, say) leaves nothing behind. Needs an Idempotency-Key header. Body (JSON): - `customer` (object, required): { id } of a customer, or the customer’s details to find or add them (as in POST /api/v1/customers). - `items` (array, required): Up to 200 items: { sku } of a product in OSuite, or { description, qty, price, gstRate, hsn?, discountPct?, unit?, periodFrom?, periodTo?, details? }. price is per unit before tax (GST or VAT is added on top, worked out by OSuite), in the invoice’s currency. discountPct is a percentage off that item’s unit price, so the same percentage off the item’s line; the tax is worked out on what is left. hsn takes HSN codes for goods and SAC codes for services (998315), printed in the HSN/SAC column. A SKU fills the name, price, HSN, unit and GST, which you may still give. unit is a word such as year, month, day, hour, session, visit, trip, km, user, gb or nos (or one of the business’s own units); a service with none is a lump sum. periodFrom and periodTo (YYYY-MM-DD) are the item’s own service period, printed under it. details prints under the item: any of when, vehicle, route, measure, person, staff, asset, booking, stay, and own1 to own3 for the business’s own details, such as { "vehicle": "KA01AB1234", "route": "Airport to Indiranagar" }. - `reference` (string): Your order number; printed on the invoice. - `date` (string): YYYY-MM-DD; today when left out. - `dueDate` (string): YYYY-MM-DD; or dueDays. - `dueDays` (number): Days after the date it is due. - `placeOfSupply` (string): Two-digit state code; the customer’s state when left out; 96 for a customer abroad. - `currency` (string): ISO code such as USD, EUR, GBP or AED for a customer abroad; item prices are then in it, and the customer pays in it. The business’s own currency when left out. - `exchangeRate` (number): How much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. It sets the rupee value on the GST return. Left out, in India OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), as OfinIT reads it each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s customs rate, which OSuite has no free source for. With no rate known within a week, the rate on the business’s latest invoice in that currency is used and warnings says so. Send exchangeRate yourself to use another rate, such as your bank’s: one rate a day, from one source you also price with, never a fixed figure. - `exportType` (string): "lut" (export under LUT, no IGST) or "igst" (IGST paid). Needed in India when the place of supply is 96, another country. - `periodFrom` (string): For services: YYYY-MM-DD, the first day the invoice bills; printed under the customer. - `periodTo` (string): YYYY-MM-DD, the last day it bills. - `contractNo` (string): The contract or statement of work it bills under; printed under the customer. - `siteAddress` (string): The site or venue the work was done at; printed on the invoice. - `jobNo` (string): Job card or work order number; printed on the invoice. - `consignmentNo` (string): Consignment note or e-way bill number; printed on the invoice. - `matterNo` (string): Matter or case number; printed on the invoice. - `instalments` (array): To be paid in parts: 2 to 24 of { dueDate, amount }. They add up to the total; send every amount as 0 to split the total evenly. The invoice is due on the first date, and each part is reminded on its own. - `notes` (string): Printed on the invoice. - `post` (boolean): false keeps a draft to post later with /post. - `send` (array): Any of "email", "whatsapp", "sms": sent to the customer once posted. In Saudi Arabia and Malaysia it waits until ZATCA or LHDN has accepted the invoice, then goes by itself: warnings says so. - `expectTotal` (number): Your total, checked against OSuite’s to the paisa: any difference adds to warnings "Your total X differs from OSuite’s Y…", and OSuite’s is the invoice’s. With paise in it, the invoice keeps its paise, as exactTotal does. - `returnUrl` (string): https address the customer is offered once they have paid on payUrl, to go back to your site. For a proforma paid on its payUrl, it gets ?checkout=&invoice= added. - `exactTotal` (boolean): true keeps the invoice to the paisa, with no rounding to the rupee: for what your website charged exactly. Answers: { invoice, sent, warnings } Example body: ```json { "customer": { "name": "Mehta Engineering", "email": "buy@mehta.in", "stateCode": "24" }, "reference": "Order 1001", "items": [ { "sku": "LED-18", "qty": 4 }, { "description": "Installation", "hsn": "9954", "qty": 1, "price": 1000, "gstRate": 18 } ], "expectTotal": 3196, "send": [ "email" ] } ``` ### GET /api/v1/invoices This website’s invoices. The invoices this token’s website made, newest first. Invoices made in OSuite itself or by another website are not listed. Query: - `customer` (number): Only this customer’s. - `reference` (string): Only the one with this reference (your order number): check it before making an invoice again for an order whose first call got no answer. - `status` (string): "due" or "paid". - `limit` (number): 1 to 100; 25 when left out. Answers: { invoices: [invoice] } ### GET /api/v1/invoices/{id} An invoice. Its status (draft, due, overdue, paid, cancelled, test), items, totals, what is paid and due, and links to view and pay it. payUrl is how a customer pays an invoice already made: OSuite’s page for it, on the business’s own gateway. A payment made there is recorded by OSuite itself, and the payment.received webhook tells you; send the customer back with returnUrl. payUrl is null when no gateway the business connected takes the invoice’s currency from this customer (making it, warnings says so): take that payment on your own gateway. Each item has its unit, periodFrom, periodTo and details. A cancelled invoice was cancelled in OSuite, perhaps reissued under a new number: see the invoice.cancelled and invoice.renumbered webhooks. Answers: { id, number, test, status, date, dueDate, reference, customer, placeOfSupply, items: [{ description, hsn, qty, price, discountPct, gstRate, taxable, unit, periodFrom, periodTo, details }], taxable, tax, total, paid, due, currency, foreign?: { currency, total, due, exchangeRate }, exportType, periodFrom, periodTo, contractNo, siteAddress, jobNo, consignmentNo, matterNo, instalments: [{ dueDate, amount }], viewUrl, payUrl, source } ### DELETE /api/v1/invoices/{id} Delete a draft. Takes back a draft this website made with post: false and will not post (a basket the customer did not pay). It had no number and is in no return. A posted invoice is refused: correct it with a credit note. Drafts left unposted for 7 days are taken back by themselves. Answers: { deleted: true } ### GET /api/v1/invoices/{id}/pdf The invoice as a PDF. The posted invoice as an A4 PDF, for your customer to download. OSuite’s invoice is the only invoice for a sale: give your customer this one, and never number or print one of your own. A test key’s invoices stay drafts and have no PDF. Answers: application/pdf ### POST /api/v1/invoices/{id}/post Post a draft. Posts an invoice made with post: false. A test key’s invoices stay drafts. Answers: invoice ### POST /api/v1/invoices/{id}/send Send an invoice. Sends a posted invoice by email, WhatsApp (through the business’s provider, with its invoice template) or SMS (its SMS provider). What could not be sent is said in warnings. Body (JSON): - `channels` (array): Any of "email", "whatsapp", "sms"; ["email"] when left out. Answers: { sent, warnings } ### POST /api/v1/invoices/{id}/payments Record a payment. A payment your website took itself (its own gateway, UPI or bank), set against the invoice as a posted receipt. Needs an Idempotency-Key header. Body (JSON): - `amount` (number): What was received; what is due when left out. No more than is due. - `mode` (string): "upi", "bank", "card", "cash", "cheque" or "online" (a gateway or wallet); "upi" when left out. From Razorpay’s method: card → card, upi → upi, netbanking → bank, wallet → online. - `reference` (string): The gateway’s or bank’s reference. - `date` (string): YYYY-MM-DD; today when left out. Answers: { paymentId, invoice } Example body: ```json { "amount": 3196, "mode": "upi", "reference": "pay_RZP123" } ``` ### POST /api/v1/invoices/{id}/credit-notes Credit an invoice. A posted credit note against the invoice, for a refund, a return or a discount after the sale: the whole invoice when no items are sent, or only the items sent. It is in the invoice’s currency and reported in GST returns; it is set against what the invoice still owes, and any rest is left as the customer’s credit. Money you refund on your gateway is refunded there; this records it in the books. Needs an Idempotency-Key header. Body (JSON): - `reason` (string): "return", "rate" (a rate difference), "discount" or "other"; "return" when left out. - `items` (array): What is credited, as for an invoice: [{ description, hsn, qty, price, gstRate }]. The whole invoice when left out. - `date` (string): YYYY-MM-DD; today when left out. Answers: { creditNote: { id, number, date, reason, total, applied, left }, invoice } Example body: ```json { "reason": "return", "items": [ { "description": "LED panel 18W", "hsn": "9405", "qty": 1, "price": 450, "gstRate": 12 } ] } ``` ### POST /api/v1/proformas Make a proforma. A bill before payment (a renewal, an advance), never a tax invoice: numbered in the PF series, in no GST return. It takes the same body as an invoice, plus validUntil (or validDays; 15 days when left out). Once the customer pays, make its tax invoice with /invoice, or let them pay on its payUrl (null, with a warning, when no connected gateway takes its currency). A proforma is not emailed when it is made: send it yourself with its viewUrl or PDF; send is kept for its tax invoice, emailed once paid. To change the price, cancel it and make a new one; both stay on record. OSuite sends no reminders for a proforma: remind the customer from your site until validUntil. Needs an Idempotency-Key header. Body (JSON): - `customer` (object, required): { id } of a customer, or the customer’s details to find or add them (as in POST /api/v1/customers). - `items` (array, required): Up to 200 items: { sku } of a product in OSuite, or { description, qty, price, gstRate, hsn?, discountPct?, unit?, periodFrom?, periodTo?, details? }. price is per unit before tax (GST or VAT is added on top, worked out by OSuite), in the invoice’s currency. discountPct is a percentage off that item’s unit price, so the same percentage off the item’s line; the tax is worked out on what is left. hsn takes HSN codes for goods and SAC codes for services (998315), printed in the HSN/SAC column. A SKU fills the name, price, HSN, unit and GST, which you may still give. unit is a word such as year, month, day, hour, session, visit, trip, km, user, gb or nos (or one of the business’s own units); a service with none is a lump sum. periodFrom and periodTo (YYYY-MM-DD) are the item’s own service period, printed under it. details prints under the item: any of when, vehicle, route, measure, person, staff, asset, booking, stay, and own1 to own3 for the business’s own details, such as { "vehicle": "KA01AB1234", "route": "Airport to Indiranagar" }. - `reference` (string): Your order number; printed on the invoice. - `date` (string): YYYY-MM-DD; today when left out. - `dueDate` (string): YYYY-MM-DD; or dueDays. - `dueDays` (number): Days after the date it is due. - `placeOfSupply` (string): Two-digit state code; the customer’s state when left out; 96 for a customer abroad. - `currency` (string): ISO code such as USD, EUR, GBP or AED for a customer abroad; item prices are then in it, and the customer pays in it. The business’s own currency when left out. - `exchangeRate` (number): How much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. It sets the rupee value on the GST return. Left out, in India OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), as OfinIT reads it each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s customs rate, which OSuite has no free source for. With no rate known within a week, the rate on the business’s latest invoice in that currency is used and warnings says so. Send exchangeRate yourself to use another rate, such as your bank’s: one rate a day, from one source you also price with, never a fixed figure. - `exportType` (string): "lut" (export under LUT, no IGST) or "igst" (IGST paid). Needed in India when the place of supply is 96, another country. - `periodFrom` (string): For services: YYYY-MM-DD, the first day the invoice bills; printed under the customer. - `periodTo` (string): YYYY-MM-DD, the last day it bills. - `contractNo` (string): The contract or statement of work it bills under; printed under the customer. - `siteAddress` (string): The site or venue the work was done at; printed on the invoice. - `jobNo` (string): Job card or work order number; printed on the invoice. - `consignmentNo` (string): Consignment note or e-way bill number; printed on the invoice. - `matterNo` (string): Matter or case number; printed on the invoice. - `instalments` (array): To be paid in parts: 2 to 24 of { dueDate, amount }. They add up to the total; send every amount as 0 to split the total evenly. The invoice is due on the first date, and each part is reminded on its own. - `notes` (string): Printed on the invoice. - `send` (array): Any of "email", "whatsapp", "sms": sent to the customer once posted. In Saudi Arabia and Malaysia it waits until ZATCA or LHDN has accepted the invoice, then goes by itself: warnings says so. - `expectTotal` (number): Your total, checked against OSuite’s to the paisa: any difference adds to warnings "Your total X differs from OSuite’s Y…", and OSuite’s is the invoice’s. With paise in it, the invoice keeps its paise, as exactTotal does. - `returnUrl` (string): https address the customer is offered once they have paid on payUrl, to go back to your site. For a proforma paid on its payUrl, it gets ?checkout=&invoice= added. - `exactTotal` (boolean): true keeps the invoice to the paisa, with no rounding to the rupee: for what your website charged exactly. - `validUntil` (string): YYYY-MM-DD it may be paid until. After it the proforma is expired: payUrl goes and it can no longer be paid on OSuite’s page. For a renewal with a grace period, make it the last day service may be restored. - `validDays` (number): Or how many days from its date. Answers: { proforma: { id, number, test, status, date, validUntil, reference, customer, items, taxable, tax, total, currency, foreign?, exportType, invoiceId, viewUrl, payUrl, source } } Example body: ```json { "customer": { "id": 812 }, "reference": "Renewal ozero-4471", "validDays": 7, "items": [ { "description": "Hosting renewal", "hsn": "998315", "qty": 1, "unit": "year", "price": 4800, "gstRate": 18, "periodFrom": "2026-12-01", "periodTo": "2027-11-30", "details": { "own1": "shop.example.in" } } ] } ``` ### GET /api/v1/proformas/{id} A proforma. Its status: open (may be paid), expired (past validUntil), invoiced (paid; invoiceId is its tax invoice), cancelled, draft or test. Answers: proforma ### GET /api/v1/proformas/{id}/pdf The proforma as a PDF. The proforma as an A4 PDF, titled Proforma Invoice. A test key’s proformas stay drafts and have no PDF. Answers: application/pdf ### POST /api/v1/proformas/{id}/invoice Invoice a paid proforma. The customer paid the proforma on your site: its tax invoice is made from it, dated today (or date), at the proforma’s exchange rate, posted, with the payment you send recorded against it, and sent as asked. It works after validUntil too, as the money is already taken. Once only: called again, it answers with the same invoice. Its tax invoice takes the proforma’s reference (Proforma when it had none), so GET /api/v1/invoices?reference= finds it. A proforma being paid on OSuite’s page at that moment is refused with 409. The token’s daily limit does not apply: the money is already taken. Needs an Idempotency-Key header. Body (JSON): - `payment` (object): { amount?, mode?, reference?, date? } as for POST /api/v1/invoices/{id}/payments: recorded against the new invoice. - `date` (string): YYYY-MM-DD; today when left out. - `send` (array): Any of "email", "whatsapp", "sms"; as the proforma was made when left out. Answers: { invoice, proforma, warnings } Example body: ```json { "payment": { "mode": "upi", "reference": "pay_RZP987" }, "send": [ "email" ] } ``` ### POST /api/v1/proformas/{id}/cancel Cancel a proforma. A proforma not paid (a renewal that lapsed, a price that changed) is cancelled and stays on record. A paid one is refused: correct its invoice with a credit note. Answers: proforma ### POST /api/v1/usage Send usage. A reading for a subscription’s metered line (storage, users, servers, calls): billed on its next recurring invoice, above what the line includes, at its rate. Name the subscription by the id you gave it in OSuite (Subscription id on the recurring invoice). Readings are added up; each is billed once. Needs an Idempotency-Key header. Body (JSON): - `subscription` (string, required): Your id for the subscription, as on the recurring invoice. - `meter` (string, required): The meter, as on the line: such as storage_gb or users. - `quantity` (number, required): How much was used, 0 or more. - `date` (string): YYYY-MM-DD the reading is for; the next invoice’s day when left out. - `unit` (string): The unit of the quantity, such as GB, Hours or Users: refused when the line bills in another unit. Left out, the line’s own. Answers: { reading: { id, recurring, meter, quantity, forDate, billed } } Example body: ```json { "subscription": "acme-hosting-01", "meter": "storage_gb", "quantity": 1250.5, "unit": "GB" } ``` ### POST /api/v1/checkout Start a hosted checkout. A cart in, the address of OSuite’s pay page back. The cart is a draft invoice, its totals with GST but no number and in no return, until the customer pays on the business’s own gateway; then it is posted, the payment recorded, the invoice sent, and the customer taken to successUrl with ?checkout=&invoice=. A cart left unpaid for a day closes (status expired, webhook checkout.expired); its draft is kept a week, so a payment the bank confirms late is still billed (webhook checkout.paid), then taken back. Needs an Idempotency-Key header. Body (JSON): - `customer` (object, required): As for an invoice. - `items` (array, required): Up to 200 items: { sku } of a product in OSuite, or { description, qty, price, gstRate, hsn?, discountPct?, unit?, periodFrom?, periodTo?, details? }. price is per unit before tax (GST or VAT is added on top, worked out by OSuite), in the invoice’s currency. discountPct is a percentage off that item’s unit price, so the same percentage off the item’s line; the tax is worked out on what is left. hsn takes HSN codes for goods and SAC codes for services (998315), printed in the HSN/SAC column. A SKU fills the name, price, HSN, unit and GST, which you may still give. unit is a word such as year, month, day, hour, session, visit, trip, km, user, gb or nos (or one of the business’s own units); a service with none is a lump sum. periodFrom and periodTo (YYYY-MM-DD) are the item’s own service period, printed under it. details prints under the item: any of when, vehicle, route, measure, person, staff, asset, booking, stay, and own1 to own3 for the business’s own details, such as { "vehicle": "KA01AB1234", "route": "Airport to Indiranagar" }. - `currency` (string): ISO code such as USD, EUR, GBP or AED for a customer abroad; item prices are then in it, and the customer pays in it. The business’s own currency when left out. - `exchangeRate` (number): How much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. It sets the rupee value on the GST return. Left out, in India OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), as OfinIT reads it each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s customs rate, which OSuite has no free source for. With no rate known within a week, the rate on the business’s latest invoice in that currency is used and warnings says so. Send exchangeRate yourself to use another rate, such as your bank’s: one rate a day, from one source you also price with, never a fixed figure. - `exportType` (string): "lut" (export under LUT, no IGST) or "igst" (IGST paid). Needed in India when the place of supply is 96, another country. - `successUrl` (string, required): https address the customer goes to once paid, with ?checkout=&invoice= added. Check GET /api/v1/checkout/{id} before you act on it. - `cancelUrl` (string): https address for Back to the shop. - `reference` (string): Your order number. - `send` (array): How the invoice is sent once paid; ["email"] when left out. Answers: { checkout: { id, status, url, expiresAt, invoice }, warnings } Example body: ```json { "customer": { "name": "Anita Shah", "email": "anita@example.in", "stateCode": "27" }, "reference": "Order 2041", "items": [ { "description": "LED panel 18W", "hsn": "9405", "qty": 2, "price": 450, "gstRate": 12 } ], "successUrl": "https://patilstore.in/thanks", "cancelUrl": "https://patilstore.in/cart" } ``` ### GET /api/v1/checkout/{id} A checkout. Whether it is open, paid or expired, with its invoice. Check this on your success page before you ship. Answers: { id, status, url, expiresAt, invoice } ## Webhooks - Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as "1416.00". - Choose your website under Only events from when adding the webhook (Connections › Webhooks): it then hears only of the invoices, payments, proformas and checkouts your website made, including invoices reissued or renumbered in OSuite, which keep their website. Left as Everything in OSuite, it hears of every invoice, payment and proforma in OSuite: act only on yours. An invoice your website made has data.apiSource set to your token’s name (null for one made in OSuite); a token’s name cannot be changed, and a replaced token keeps it. Fetching any other with your token answers 404: answer the webhook 2xx and skip it, or it is tried again 5 more times. - Trying your handler before going live, under Connections › Webhooks: Send a test sends the event ping, { message }, to check your signature code. Send a sample sends the latest real event of the kind you choose, built as it was delivered and signed, under an id starting evt_sample_; an event that has not happened in this OSuite yet has none (Nothing to send yet). A sample is a real past event: handle one starting evt_sample_ as a dry run (check the signature, read it, fetch the document, log what you would do, answer 2xx) and change nothing, or it would mark a real order paid twice or cancel a live one. ## The order inbox feed - GET ?after=, with Authorization: Bearer . - 200 with JSON { "orders": [order], "next": "" } and the header X-OSuite-Signature: sha256=. At most 200 orders an answer, and 2 MB. - As the body of POST /api/v1/invoices, with "id" (your order id, unique) and, for an order already paid, "paid": { amount, mode, reference }. "test": true makes that one order a TEST draft even on a live feed, for a sample. "liveOnly": true holds a real sale while the feed is in test mode, and bills it once the feed goes live. - POST with JSON { orderId, status: "billed" | "failed", reissuedFrom?, invoice?: { id, number, status, date, total, due, viewUrl, payUrl, pdf }, error?, warnings? }, where pdf is the posted invoice as base64, and reissuedFrom is the number the sale’s invoice had before: when OSuite reissues an invoice or gives it back its original number, the order is told again, and you replace that number and PDF with these. It comes with headers X-OSuite-Timestamp and X-OSuite-Signature: sha256=.">. Answer 2xx; OSuite tells you again until you do. --- # A first invoice in five minutes Make a billing token, then make, post and email an invoice from your website’s server. ## 1. Make a billing token In OSuite, open Your account › API tokens. Name the token after your website (patilstore.in), choose Bill through the Billing API, and Make a token. Copy it: it is shown once. For trying things out, tick Test key: its invoices stay drafts marked TEST and are never sent or numbered. ## One sale, one invoice One sale, one invoice, and it is OSuite’s. OSuite works out the GST and gives the number; your website shows the customer that number and that PDF, and never numbers or prints an invoice of its own. Two invoices for one sale would put your GST returns out of step with what your customer holds. Fetch the invoice with GET /api/v1/invoices/{id}/pdf. With the order inbox, the PDF comes with the invoice number at your callback address. ## 2. Find your OSuite’s address Your OSuite’s own address: the cloud edition’s, or a desktop’s Remote access address. Calls go there directly; OfinIT is not in between. Below, replace YOUR-OSUITE with it, and keep the token in an environment variable on your server. ## 3. Make an invoice ```bash curl -X POST https://YOUR-OSUITE/api/v1/invoices \ -H "Authorization: Bearer $OSUITE_TOKEN" \ -H "Idempotency-Key: order-1001" \ -H "Content-Type: application/json" \ -d '{"customer":{"name":"Mehta Engineering","email":"buy@mehta.in","stateCode":"24"},"reference":"Order 1001","items":[{"sku":"LED-18","qty":4},{"description":"Installation","hsn":"9954","qty":1,"price":1000,"gstRate":18}],"expectTotal":3196,"send":["email"]}' ``` OSuite finds or adds the customer, fills the LED panel from its SKU, works out GST and the number, posts the invoice and emails it. The answer has the invoice with its viewUrl and payUrl, what was sent, and any warnings. ## 4. Next Take payment on OSuite’s pay page with a hosted checkout, or record a payment your website took with POST /api/v1/invoices/{id}/payments. Send an Idempotency-Key with every call that makes something. --- # Tokens and limits Billing tokens, one per website; their limits, expiry, addresses, and the rate limit. ## Billing tokens Authorization: Bearer . Make one under Your account › API tokens, choosing Bill through the Billing API, one per website. Keep it on your server: never in a browser or an app people download. A site on serverless hosting (Vercel, Netlify, AWS Lambda) calls from changing addresses: leave the token’s address list empty, and expect a note to the token’s owner about each new address. A billing token reaches only the Billing API, and each website sees only the invoices it made: one website’s token gets 404 for another’s. ## Limits on a token When making it: when it expires, the addresses it may be used from (such as 203.0.113.9 or 10.0.0.0/8), the largest invoice it may make and how many a day. Replace gives a new token with the same settings; the old one works 7 more days. ## The rate limit 120 calls a minute for a token. Each answer carries X-RateLimit-Limit and X-RateLimit-Remaining; past the limit, 429 with Retry-After in seconds: wait that long and send again. A token may also have a largest invoice (over it, 422) and a number of invoices a day (past it, 429 with no Retry-After, as it lasts until tomorrow: do not retry). Set both above your largest real values. ## What OSuite notices Every call is logged for 30 days under Calls with your tokens. The token’s owner and administrators are told of a new address, a burst of calls, or many refused. An address sending many tokens that do not work is paused for ten minutes. --- # Retries without duplicates The Idempotency-Key header: send the same call again and get the same answer. ## The key Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=. Use something that names the order, such as its number. A key is kept for 30 days. The same key for a different call is refused with 422; a key still being answered gives 409: wait and send again. ## Example ```bash curl -X POST https://YOUR-OSUITE/api/v1/invoices/123/payments \ -H "Authorization: Bearer $OSUITE_TOKEN" \ -H "Idempotency-Key: order-1001" \ -H "Content-Type: application/json" \ -d '{"amount":3196,"mode":"upi","reference":"pay_RZP123"}' ``` --- # Hosted checkout Send a cart, send the customer to OSuite’s pay page, and get them back once paid. ## How it goes A cart in, the address of OSuite’s pay page back. The cart is a draft invoice, its totals with GST but no number and in no return, until the customer pays on the business’s own gateway; then it is posted, the payment recorded, the invoice sent, and the customer taken to successUrl with ?checkout=&invoice=. A cart left unpaid for a day closes (status expired, webhook checkout.expired); its draft is kept a week, so a payment the bank confirms late is still billed (webhook checkout.paid), then taken back. ## Start one ```bash curl -X POST https://YOUR-OSUITE/api/v1/checkout \ -H "Authorization: Bearer $OSUITE_TOKEN" \ -H "Idempotency-Key: order-1001" \ -H "Content-Type: application/json" \ -d '{"customer":{"name":"Anita Shah","email":"anita@example.in","stateCode":"27"},"reference":"Order 2041","items":[{"description":"LED panel 18W","hsn":"9405","qty":2,"price":450,"gstRate":12}],"successUrl":"https://patilstore.in/thanks","cancelUrl":"https://patilstore.in/cart"}' ``` Send the customer to checkout.url. OSuite takes payment on the business’s own gateway account, connected under Connections › Payment gateways: Razorpay, Cashfree, PayU, PayPal, Stripe, Instamojo, CCAvenue, PhonePe, Paytm and, in the Gulf, Telr, N-Genius, Tabby and Tamara. It is the same account the business already has, so no new KYC. Razorpay takes payment from customers abroad once international payments are on in the Razorpay account and, in OSuite, Connections › Payment gateways › Razorpay has customers abroad ticked. A customer abroad pays in the invoice’s currency (USD, EUR…) on a gateway the business has connected that takes it, such as PayPal, Stripe, or Razorpay with international payments turned on in the Razorpay account and in OSuite (it charges USD and pays the business in rupees); Instamojo takes rupees only. The pay page offers only those that fit, and a checkout no connected gateway can take payment for is refused with 422 and the usual error body ({ error, fieldErrors: { currency } }). Autopay (mandates) is set up on a recurring invoice in OSuite, not through this API. ## Before you ship On your success page, call GET /api/v1/checkout/{id} with the checkout id from the address and ship only when its status is paid. The customer may close the tab before they get back, so listen for the checkout.paid webhook too, and ship on whichever comes first. A test key’s checkout shows Pay (test) and issues nothing. ## Failed and pending payments A payment that fails brings the customer back to the pay page, which says so and offers Pay again. One the bank is still confirming holds the Pay buttons for 15 minutes so the customer is not charged twice, and the page keeps checking by itself. A cart still unpaid after a day closes: checkout.expired. A payment confirmed later in the week still bills it: checkout.paid, even after expired. Treat checkout.paid as final whenever it comes. --- # Order inbox (desktop without a tunnel) For an OSuite your website cannot reach: offer a feed of orders that OSuite fetches when online. ## When to use it The business runs OSuite on a desktop without Remote access, so your server cannot call it. Instead you keep orders in a feed; OSuite fetches it every 5 minutes while online, bills each order once and tells you the number. Invoices are made only while OSuite is online: goods need theirs by dispatch, so a business that ships often is better on the cloud edition or Remote access with the Billing API. ## Setting it up In OSuite, Connections › Your website’s orders › Add a website: the feed address and, optionally, a callback address. OSuite gives the feed secret. ## The feed GET ?after=, with Authorization: Bearer . 200 with JSON { "orders": [order], "next": "" } and the header X-OSuite-Signature: sha256=. At most 200 orders an answer, and 2 MB. As the body of POST /api/v1/invoices, with "id" (your order id, unique) and, for an order already paid, "paid": { amount, mode, reference }. "test": true makes that one order a TEST draft even on a live feed, for a sample. "liveOnly": true holds a real sale while the feed is in test mode, and bills it once the feed goes live. ```js // Node: answer OSuite's fetch with new orders, signed with the feed secret. import { createHmac } from 'node:crypto'; app.get('/osuite/orders', async (req, res) => { if (req.get('authorization') !== `Bearer ${process.env.OSUITE_FEED_SECRET}`) return res.sendStatus(401); const orders = await ordersAfter(req.query.after); // yours: oldest first, up to 200 const body = JSON.stringify({ orders, next: orders.at(-1)?.id ?? req.query.after ?? '' }); const signature = createHmac('sha256', process.env.OSUITE_FEED_SECRET).update(body).digest('hex'); res.set('content-type', 'application/json').set('x-osuite-signature', `sha256=${signature}`).send(body); }); ``` ## Being told POST with JSON { orderId, status: "billed" | "failed", reissuedFrom?, invoice?: { id, number, status, date, total, due, viewUrl, payUrl, pdf }, error?, warnings? }, where pdf is the posted invoice as base64, and reissuedFrom is the number the sale’s invoice had before: when OSuite reissues an invoice or gives it back its original number, the order is told again, and you replace that number and PDF with these. It comes with headers X-OSuite-Timestamp and X-OSuite-Signature: sha256=.">. Answer 2xx; OSuite tells you again until you do. An order that cannot be billed is tried 5 times, then you are told it failed with why, and so are the business’s administrators. --- # Webhooks Your server told of invoices posted, payments received and checkouts paid or closed, signed. ## Setting them up Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as "1416.00". Each call carries X-OSuite-Timestamp and X-OSuite-Signature: sha256=."> keyed with the webhook’s secret. Refuse a call whose X-OSuite-Timestamp is more than 5 minutes old: it is new on every try and covered by the signature. Do not judge age by occurredAt in the body: that is when it happened in OSuite, the same on every retry, so a retry long after still carries the first time. ## Checking one ```js import { createHmac, timingSafeEqual } from 'node:crypto'; function fromOSuite(req, rawBody, secret) { const ts = req.get('x-osuite-timestamp'); if (!ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; const want = `sha256=${createHmac('sha256', secret).update(`${ts}.${rawBody}`).digest('hex')}`; const got = req.get('x-osuite-signature') ?? ''; return got.length === want.length && timingSafeEqual(Buffer.from(got), Buffer.from(want)); } ``` ## Only yours Choose your website under Only events from when adding the webhook (Connections › Webhooks): it then hears only of the invoices, payments, proformas and checkouts your website made, including invoices reissued or renumbered in OSuite, which keep their website. Left as Everything in OSuite, it hears of every invoice, payment and proforma in OSuite: act only on yours. An invoice your website made has data.apiSource set to your token’s name (null for one made in OSuite); a token’s name cannot be changed, and a replaced token keeps it. Fetching any other with your token answers 404: answer the webhook 2xx and skip it, or it is tried again 5 more times. ## Trying your handler before going live Trying your handler before going live, under Connections › Webhooks: Send a test sends the event ping, { message }, to check your signature code. Send a sample sends the latest real event of the kind you choose, built as it was delivered and signed, under an id starting evt_sample_; an event that has not happened in this OSuite yet has none (Nothing to send yet). A sample is a real past event: handle one starting evt_sample_ as a dry run (check the signature, read it, fetch the document, log what you would do, answer 2xx) and change nothing, or it would mark a real order paid twice or cancel a live one. --- # Customers abroad, and refunds Invoices in the customer’s currency as exports, and credit notes for refunds and returns. ## An invoice in their currency For a customer abroad, send placeOfSupply 96, currency (USD, EUR, GBP…) and exportType: lut for an export under LUT with no IGST, or igst with IGST paid. Item prices are then in that currency; under LUT their GST is 0% whatever you send. exchangeRate is how much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. Left out, OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), read each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s. With no rate known within a week, the rate on the business’s latest invoice in that currency is used, and warnings says so. Send exchangeRate yourself to use another, such as your bank’s. The answer carries foreign: { currency, total, due, exchangeRate }, what the customer sees and pays. total and due are in the business’s own currency, as its books keep them. Checkout works the same way: the pay page shows the cart in the customer’s currency and the gateway charges it. ## Refunds and returns A posted credit note against the invoice, for a refund, a return or a discount after the sale: the whole invoice when no items are sent, or only the items sent. It is in the invoice’s currency and reported in GST returns; it is set against what the invoice still owes, and any rest is left as the customer’s credit. Money you refund on your gateway is refunded there; this records it in the books. ```bash curl -X POST https://YOUR-OSUITE/api/v1/invoices/123/credit-notes \ -H "Authorization: Bearer $OSUITE_TOKEN" \ -H "Idempotency-Key: order-1001" \ -H "Content-Type: application/json" \ -d '{"reason":"return","items":[{"description":"LED panel 18W","hsn":"9405","qty":1,"price":450,"gstRate":12}]}' ``` --- # Service details, periods and instalments Units, service periods and details printed under each item; site, job and matter numbers; paying in parts. ## Units and periods Send unit as a word: year, month, day, hour, session, visit, trip, km, user, gb or nos, or one of the business’s own units. A service sent with no unit is a lump sum. An item’s periodFrom and periodTo print its own service period under it, such as a hosting year; the invoice’s periodFrom and periodTo print one period for the whole invoice. ## Details under an item details prints under the item’s description: when (a date and time), vehicle, route (pickup and drop), measure (km, weight or volume), person (a patient, student or guest), staff (served by), asset (a device and serial number), booking (a booking or PNR number), stay (room, guests and nights), and own1 to own3 for the business’s own details, labelled as it named them in OSuite. ```json "items": [{ "description": "Airport transfer", "hsn": "9964", "qty": 1, "price": 1800, "gstRate": 5, "unit": "trip", "details": { "when": "14 Nov, 06:30", "vehicle": "KA01AB1234", "route": "Airport to Indiranagar" } }] ``` ## On the invoice siteAddress (a site or venue), jobNo (a job card or work order), consignmentNo (a consignment note or e-way bill) and matterNo (a matter or case) print with the invoice’s own details. ## Paying in parts instalments splits what is due by dates: [{ "dueDate": "2026-12-01", "amount": 5000 }, { "dueDate": "2027-01-01", "amount": 5000 }]. The parts add up to the total; send each amount as 0 to split it evenly. The invoice is due on the first date and each part is reminded on its own. --- # When an invoice changes An invoice cancelled, reissued under a new number, or given back its original number in OSuite. ## What can happen A posted invoice is never edited. In OSuite the business may cancel it, reissue it (the same sale under a new number, its payments moved across), or have a reissued invoice take back the number of the one it replaced, before the month’s GST return is filed. Keep the number and PDF your customer sees in step with OSuite’s. ## With webhooks invoice.cancelled tells you an invoice was cancelled. invoice.renumbered carries the invoice with its new number and previousNumber: find the sale by previousNumber, and fetch the PDF again with GET /api/v1/invoices/{id}/pdf. ## With the order inbox The order is told again at your callback address, with reissuedFrom set to the number you have: replace it, and the PDF, with the ones sent. --- # Proformas, renewals and paying first A bill before payment that is never a tax invoice; its invoice once paid. Charging exactly OSuite’s total. ## Why A tax invoice cannot be changed or dropped once issued; GST corrects it only with a credit note. So a renewal or an advance asked for before payment is a proforma: it has a PF number, is in no return, and may lapse or be replaced. The tax invoice is made when the money comes. ## Make one ```bash curl -X POST https://YOUR-OSUITE/api/v1/proformas \ -H "Authorization: Bearer $OSUITE_TOKEN" \ -H "Idempotency-Key: order-1001" \ -H "Content-Type: application/json" \ -d '{"customer":{"id":812},"reference":"Renewal ozero-4471","validDays":7,"items":[{"description":"Hosting renewal","hsn":"998315","qty":1,"unit":"year","price":4800,"gstRate":18,"periodFrom":"2026-12-01","periodTo":"2027-11-30","details":{"own1":"shop.example.in"}}]}' ``` Show the customer its PDF or viewUrl. A new price is a new proforma: cancel the old one with /cancel. ## Paid on your site The customer paid the proforma on your site: its tax invoice is made from it, dated today (or date), at the proforma’s exchange rate, posted, with the payment you send recorded against it, and sent as asked. It works after validUntil too, as the money is already taken. Once only: called again, it answers with the same invoice. Its tax invoice takes the proforma’s reference (Proforma when it had none), so GET /api/v1/invoices?reference= finds it. A proforma being paid on OSuite’s page at that moment is refused with 409. The token’s daily limit does not apply: the money is already taken. ```bash curl -X POST https://YOUR-OSUITE/api/v1/proformas/123/invoice \ -H "Authorization: Bearer $OSUITE_TOKEN" \ -H "Idempotency-Key: order-1001" \ -H "Content-Type: application/json" \ -d '{"payment":{"mode":"upi","reference":"pay_RZP987"},"send":["email"]}' ``` ## Paid on OSuite’s page Send the customer to the proforma’s payUrl instead: they pay on the business’s own gateway, OSuite makes and posts the tax invoice, records the payment and sends it, and the proforma.invoiced webhook tells you with invoiceId. With returnUrl the customer is offered the way back to your site. ## Charging exactly OSuite’s total To charge on your own gateway what the invoice will say: make the invoice with post: false (or a proforma) before opening your gateway, read its total, and charge that. Once paid, post it with /post and record the payment, or /invoice a proforma. A basket left unpaid: DELETE the draft, or leave it; OSuite takes it back after 7 days. If OSuite cannot be reached when a customer pays, keep the order and make the invoice when it can, with the same Idempotency-Key: for services, GST allows the invoice within 30 days. --- # Errors and test mode What errors look like, and test keys. ## Errors Errors answer { "error": "", "fieldErrors": { "": "" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits. ## Test mode A test key (tick Test key when making the token) makes invoices that stay drafts marked TEST-: never posted, numbered, sent or paid, and in no GST return. Its proformas stay drafts too, and its checkouts take a test payment. As nothing is posted, a test key sends no webhooks. Instead, under Connections › Webhooks: Send a test checks your signature code, and Send a sample sends the latest real event of the kind you choose, signed, under an id starting evt_sample_ (nothing changes in OSuite), so your handler is tried on real data before you go live. Each event’s schema is in openapi.json.