All Mocha apps
How the Mocha QuickBill data model fits together, and the cross-cutting rules that apply to every endpoint — before you go looking up a specific one.
What this hub is for.
Welcome to the API Information Hub — your central resource for understanding and leveraging our platform's APIs. This hub is designed for developers, technical architects, and integration partners who are building robust, secure, and scalable applications on top of our services.
The sections below explain everything the API works with — Accounts, Products, Customers, Invoices, Payments, and the pricing components, plans, addons and charges, coupons and subscriptions behind recurring billing — and how they depend on each other. Read this first; the API Docs then cover each endpoint in detail.
| Resource | What it is | Depends on |
|---|---|---|
| Account | Where money is booked — income, expense or bank. A default set comes with your tenant. | — |
| Product | Something you sell — a physical item or a service. | An income account and an expense account |
| Inventory adjustment | A change to the stock held for one or more products, with the reason it changed. | An inventory product and an account to post to |
| Customer | The business or person you bill. | — |
| Invoice | A request for payment, made up of line items. | A customer and one or more products |
| Payment | Money received against an invoice. | An invoice and a bank account |
| Pricing component | A reusable piece of pricing — a named amount you can put on any number of plans. | — |
| Pricing plan | What a customer is billed on. Built out of components, and attached to a product. | One or more pricing components |
| Addon or charge | Something sold beside a plan — an addon renews every cycle, a charge is billed once. | An income account and one or more pricing plans |
| Coupon | A discount — a percentage or a flat amount — on a subscription or an invoice. | — |
| Subscription | A customer put on a plan for a product, billed every cycle. | A customer, a product and a plan attached to it |
Where the money gets booked.
An account is a bucket the money is booked into. A sale posts to an income account, a cost to an expense account, stock value sits in an inventory account, and money you receive lands in a bank account. This is how QuickBill keeps your accounting tracked without you doing anything about it.
Every tenant starts with a default set of accounts, ready to use. There is nothing to set up, and no endpoint to create or edit one — you only read the list and pick from it.
| Kind | Used by | Example names |
|---|---|---|
| Income | A product's revenue account — where a sale of it is booked. | Sale of Product Income, Service Income |
| Expense | A product's expense account — where its cost is booked. Which ones are eligible depends on the product's type. | Supplies & Materials - COGS, Advertising |
| Inventory | An inventory product's stock value. Only needed when the product's type is inventory. | Inventory Asset |
| Bank | The account a payment is deposited into. | Checking, Savings, Undeposited Funds |
The four endpoints and their responses are in Accounts.
What you sell and bill for.
A product is anything you put on an invoice line item. Its type says what kind it is — inventory for something you hold stock of, non_inventory for a good you do not track, and service for work you deliver.
| type | Also required |
|---|---|
inventory | A quantity, an inventory account, an expense account and an income account. |
non_inventory | An expense account. An income account is optional, and there is no quantity to send. |
service | An expense account. An income account is optional, and there is no quantity to send. |
expense_account has to be set. An inventory product needs three more on top — a quantity, an inventory account and an income account. Read the available ids from Accounts.An inventory product holds a stock quantity, and that quantity changes through an inventory adjustment — not by updating the product. An adjustment moves the stock for one or more products and records why it moved, so the quantity stays tracked rather than silently overwritten.
quantity is dropped if you send it on an update. Stock is moved through Create an Inventory Adjustment instead, and read back from Get a Product's Inventory.See Create a Product for the request and response, and Inventory Adjustments for the endpoints that move stock.
Who your invoices are issued to.
A customer is the business or person you bill. Every invoice is issued against exactly one customer, so the customer record has to exist before you can raise an invoice.
See Create a Customer for the request and response.
Billing a customer for products.
An invoice brings a customer and one or more products together into a request for payment. Each line item points at a product and carries a quantity and a price, which can override the product's default.
Put a one-time plan (has_billing_period: false) on a line and the plan's price becomes the line's rate. A subscription plan can go on a line too, but it has no single price, so you send the rate yourself. When you edit the invoice later, the line keeps its rate unless you ask for a one-time plan's current price.
Send a coupon's id on a line to take it off that line, or on the invoice to take it off the whole bill after the line coupons. You send only the id; the discount is worked out for you, and a coupon that cannot be used is refused with the reason.
INV- numbers. A dedicated endpoint returns the next one in the sequence — call it, then use the value it gives you when you create the invoice. The format varies between accounts, so treat what you get back as an opaque string.See Create an Invoice for the request and response.
Settling what is owed.
A payment records money received from a customer and applies it to the invoices it settles. It is the last step in the chain: products go on an invoice, the invoice goes to a customer, and the payment closes it out.
A payment is not tied to a single invoice. When a customer sends one amount covering three invoices, you record one payment and split it across all three in the same call — you do not record it three times. Each entry names the invoice and the amount applied to it, and those amounts have to add up to what the customer actually sent.
Applying a payment reduces the invoice's balance. Pay the full balance and the invoice is settled; pay less and the remainder stays outstanding, so you can record the rest later against the same invoice. The customer's own open_balance moves with it, so you can show what a customer owes without adding up their invoices yourself.
status does not move when part of it is paid — it stays open until it is settled. To show whether money has come in, compare balance against amount instead of reading the status.Payments carry their own PMT- reference, which is not the same thing as the INV- number on the invoice being paid. One payment covering three invoices has a single payment reference and three invoice numbers behind it. Keep the two apart in your own records.
| What you need | Where it comes from |
|---|---|
| The account the money lands in | One of your bank accounts — Accounts. |
| How the money was paid | Cash, cheque, card and so on — Payment Methods. |
See Receive a Payment for the request and response.
Reusable pieces of pricing.
A pricing component is a named fixed amount — a setup fee, a platform fee, a service charge. On its own it does nothing. It becomes real once you put it on a pricing plan. A discount is not a component; it is a coupon.
A component is reusable. Create it once and put it on as many plans as you like — you do not create a separate setup fee for every plan that charges one. Change the component and every plan holding it reflects the change.
The dates live on the plan, not on the component. When you add a component to a plan you give it a start_date and an optional end_date — that is how long it is charged on that plan.
The fields, rules and error cases are in Pricing Components.
What a customer is actually billed on.
A plan is a bundle of components with a life span. A subscription plan is what a subscription charges against; an invoice plan prices a line on an invoice.
| Part | What it does |
|---|---|
| Components | One or more pricing components, each with its own start and end date on this plan. |
| Coupons | Optional. Coupons that can be used on this plan, each with its own start and end date on it. |
| Effective and expiration dates | When the plan itself starts and stops. Leave the expiration out and it runs on with no end. |
| Price | The sum of the fixed components running on the plan today. Coupons are not taken off it. You never send it — it comes back on every response. |
A plan on its own is not sellable. You attach it to a product, and a product can be on several plans at once — monthly and yearly, say. That is the list a subscription picks from.
See Pricing Plans and Attach Plans to a Product.
Billed beside a subscription's plan.
An addon or a charge is something you sell on top of a plan — extra storage, a setup fee. It is kept like a product and, like a product, it has no price of its own: its pricing plans give it one.
| Type | How it bills | Plans it takes |
|---|---|---|
| Addon | On every cycle of the subscription — or for a set number of cycles, then it stops. | Any plan; on a subscription, a plan with a price for its billing cycle. |
| Charge | Once. | One-time plans only. |
| Part | What it does |
|---|---|
| Name and code | Leave the code out and one is made for you. No two products, addons or charges share a code. |
| Income account | Where its sales are booked. An expense account only if you buy it in and resell it. |
| Pricing plans | The plans it can be sold on. |
| Cycle count | Addon only. How many cycles it bills for; leave it out and it never ends. |
| Active or not | An inactive one cannot go on a new subscription. Running subscriptions and past invoices are not touched. |
| On | How you send it |
|---|---|
| A subscription | An item in subscription_items with item_type addon or charge, its id as item_id and one of its plans as plan_id. |
| An invoice line | Its id as addon_charge_id in place of product_id, priced by one of its plans or by the rate you send. The line comes back with addon_charge_id set, so you can tell it from a product line. |
The fields, rules and error cases are in Addons & Charges.
Discounts on a subscription or an invoice.
A coupon is a discount. On a subscription, send its id as coupon_id on an item in subscription_items, or as subscription_coupon_id for the whole subscription. On an invoice, send it as coupon_id on a line, or as coupon_id on the invoice for the whole of it.
| Part | What it does |
|---|---|
| Discount type and value | percent (up to 100) or flat_amount. |
| Cycle count | How many billing cycles the discount lasts. Leave it out and it never ends. |
| Active or not | An inactive coupon cannot be applied to a subscription. |
| Start and end date | Optional. Outside these days the coupon cannot be applied. |
| Limits | Optional. How many times it can be used in all, and by one customer. |
| Plans and customers | Optional. The plans it sits on, and the customers it is kept for. No customers means anyone can use it. |
A validate call works out what a code takes off a plan, or off an amount you send, without applying it. For a subscription plan, send the billing cycle so it prices the right period. Send the customer too, or a coupon kept for certain customers is refused.
On an update, send the coupon an item already has to keep it as it is — even on a new plan. Send a different coupon and it takes the place of the one running. Leave the coupon out and it is taken off.
The fields, rules and error cases are in Coupons.
Recurring billing on a plan.
A subscription puts a customer on one of a product's plans and bills them every cycle — monthly or yearly. It is the recurring counterpart to raising invoices by hand. Addons can ride along every cycle, and one-time charges are billed once.
You send ids only — the customer, the billing cycle, and in subscription_items the product and its plan, any addons and one-time charges, each with an optional coupon, plus optionally a coupon on the whole subscription. The prices, the current plan, whether a change is an upgrade or a downgrade, and whether it applies now or at the next renewal are all resolved for you.
A subscription can start with a trial. Nothing is charged during it, and nothing is charged before the start date if you dated the subscription into the future.
| Change | When it lands |
|---|---|
| Upgrade — a dearer plan, or a new addon | Straight away. Charge the mid-term difference by asking for proration, or leave it and it is not charged. |
| Downgrade | At the next renewal — never straight away, so a customer never loses paid-for time. |
| Either, during a trial | Straight away, and nothing is charged. |
Cancel immediately, or let the subscription run to the end of the term the customer has already paid for. Either way renewal invoices stop, and a cancellation can be reversed if it was a mistake.
Every endpoint, field and behaviour is in Subscriptions.
API key based authentication.
We support API key based authentication. Use a unique key per environment. API keys must be kept confidential and should not be exposed in frontend code.
The exact headers and a worked example are covered in Getting Started → Authentication.
Mandatory and recommended practices.
We take API security seriously. Here are our mandatory and recommended practices:
What changed and when.
Track all recent updates via our Developer Changelog: