APIv1
API Docs

API Docs

Complete reference for the Mocha QuickBill API: every endpoint with its request fields, example bodies, response payloads and status codes.

Overview

Base URL, authentication and the endpoint index.

Every endpoint takes a JSON body and returns JSON. Authenticate with the X-Tenant and API Key headers on every request — see Authentication for the details.

Base URL

Every path on this page is relative to:

Base URL
https://services.ap.mochatechnologies.com/quickbill/api

Endpoint index

EndpointWhat it does
GET /income-accountsList the income accounts a product's revenue_account can point at.
GET /expense-accountsList the expense accounts a product's expense_account can point at, for a given product type.
GET /inventory-accountsList the accounts an inventory product's stock value can sit in.
GET /bank-accountsList the accounts a payment can be deposited into.
POST /productsCreate a product or service that invoice line items can reference.
PUT /products/:idReplace a product with how it should end up.
GET /productsList your products, a page at a time.
GET /products/:idRead a single product back by its id.
GET /products/latest-inventory-numberGet the next reference number to use on an inventory adjustment.
GET /inventory-adjustment-accountsList every account an inventory adjustment can be posted to.
GET /products/inventory-adjustment-reasonsList the reasons an inventory adjustment can carry.
POST /products/inventory-adjustmentChange the stock held for one or more products, and record why.
GET /products/inventory-adjustmentList your inventory adjustments, a page at a time.
GET /products/inventory-adjustment/:idRead a single inventory adjustment back by its id.
GET /products/:id/inventoryRead a product's current stock and the movements that got it there.
POST /customersCreate the customer an invoice is issued to, with its addresses.
PUT /customers/:idReplace a customer with how it should end up.
GET /customersList your customers, a page at a time.
GET /customers/:idRead a single customer back by its id.
GET /invoices/get-invoice-numberTake the next invoice number, before you create the invoice.
POST /invoicesBill a customer for one or more products.
PUT /invoices/:idReplace an invoice, while nothing has been paid on it.
GET /invoicesList your invoices, a page at a time.
GET /invoices/:idRead a single invoice back in full, with its addresses and payments.
GET /invoices/payment-link/:idBuild a link the customer can open to pay the invoice online.
GET /payment-methodsList the ways a payment can be taken — cash, cheque, card.
GET /payments/get-next-payment-numberTake the next payment reference, before you record the payment.
POST /paymentsRecord a payment against one or more of a customer's invoices.
PUT /payments/:idReplace a recorded payment and what it settles.
GET /paymentsList recorded payments, a page at a time.
GET /payments/:idRead one payment back, with what it was applied to.
POST /pricing-componentsCreate a fixed pricing component. A discount is a coupon.
PUT /pricing-components/:idReplace a pricing component with how it should end up.
GET /pricing-componentsList every pricing component at once, with no pagination.
GET /pricing-components/:idRead a single pricing component back by its id.
DELETE /pricing-components/:idDelete a pricing component.
PATCH /pricing-components/:id/statusActivate or deactivate a pricing component.
POST /pricing-plansBuild a pricing plan out of one or more pricing components.
PUT /pricing-plans/:idReplace a pricing plan with how it should end up.
GET /pricing-plansList every pricing plan at once, with no pagination.
GET /pricing-plans/:idRead a single pricing plan back by its id.
DELETE /pricing-plans/:idDelete a pricing plan.
PATCH /pricing-plans/:id/statusActivate or deactivate a pricing plan.
POST /products/:id/pricing-plansSet which pricing plans a product is on.
GET /products/:id/pricing-plansRead back which pricing plans a product is on.
POST /addon-chargesCreate an addon or a charge.
PUT /addon-charges/:idReplace an addon or a charge.
GET /addon-chargesList addons and charges, a page at a time.
GET /addon-charges/:idRead one addon or charge.
DELETE /addon-charges/:idDelete an addon or a charge nothing uses.
PATCH /addon-charges/:id/statusSwitch an addon or a charge on or off.
POST /couponsCreate a coupon.
PUT /coupons/:idReplace a coupon.
GET /couponsList every coupon at once, with no pagination.
GET /coupons/:idFetch one coupon.
POST /coupons/validatePreview what a code takes off a plan.
DELETE /coupons/:idDelete a coupon.
PATCH /coupons/:id/statusActivate or deactivate a coupon.
POST /subscriptionsPut a customer on a plan, with or without a trial.
GET /subscriptionsList your subscriptions, a page at a time.
POST /subscriptions/updateChange the plan, apply a coupon, or both.
POST /subscriptions/calculate-prorationPreview what a plan change will cost, without saving anything.
POST /subscriptions/cancelEnd a subscription now, or at the end of its term.
POST /subscriptions/cancel/reverseUndo a cancellation and put the subscription back in service.

Every PUT is a replace, not a patch

PUT /products/:id, PUT /customers/:id, PUT /invoices/:id, PUT /payments/:id and the two pricing ones all work the same way: send the whole record as it should end up, not only what changed. Any array you send — lines, paidAmount, tags, components — becomes the entire set, so an entry you leave out is removed. Read the record first, then send it back with your edits. The id travels in the URL; you never put it in the body as well.

Error keys

Every error response has a message. Some errors also include one of these keys:

KeyWhat it means
errorsValidation failed. Keyed by field: { "field": ["..."] }
plansLive pricing plans are blocking the change: { id, name, code }
used_onInvoices, leases or subscriptions using the plan are blocking the change: { type, id, no }
itemsItems attached to the plan are blocking the change: { type, id, name }

Different errors can share a status code. Check which key is present to tell them apart.

Authentication failures are not listed per endpoint

A missing or invalid X-Tenant or API Key is rejected before the request reaches any of the endpoints below, so the status tables on this page do not repeat it. Handle it once in the layer that adds your headers — see Getting Started → Authentication.

More endpoints on the way

This reference is being rebuilt endpoint by endpoint against the live API. Only the endpoints listed above are confirmed — anything else is not documented here yet.

Accounts

The account ids that products and payments ask for.

Accounts are what QuickBill uses to keep your accounting tracked — a sale posts to an income account, a cost to an expense account, stock value sits in an inventory account, money received lands in a bank account. You do not create or manage them here: every tenant starts with a default set, ready to use.

Full accounting is a separate product

These accounts are a feature of Mocha's accounting product. If you purchase it later, you get the whole thing — your own chart of accounts, ledgers and reporting. Until then the defaults are all you need, and these four small read endpoints are exposed for exactly one reason: so you can create a product and record a payment without owning the accounting product.
GET/income-accountsX-Tenant + API Key required
GET/expense-accounts?product_type=X-Tenant + API Key required
GET/inventory-accountsX-Tenant + API Key required
GET/bank-accountsX-Tenant + API Key required

Which one feeds which field

Call the endpoint, show the names to your user, and send back the id they picked.

EndpointFills inOn
GET /income-accountsrevenue_accountPOST /products
GET /expense-accounts?product_type=expense_accountPOST /products
GET /inventory-accountsinventory_accountPOST /products
GET /bank-accountsaccount_idPOST /payments

You only need the inventory list for an inventory product

inventory_account is required when a product's type is inventory, and not used for service or non_inventory. See what each type requires.

Never hard-code an account id

The ids differ from one tenant to the next, so a value that works in your own tenant will be wrong in your customer's. Read the list at runtime.

Only expense-accounts takes a parameter

Income, inventory and bank accounts take none. Expense accounts require product_type — see below. None of the four paginate, so there is no page, no search and no meta block anywhere.

Every entry is just an id and a name

id is what you send, name is what you show in a picker. There is nothing else on an account — no type, no balance, no currency. Only active accounts come back.

Income accounts

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/income-accounts' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"
200 OK
{
  "data": [
    { "id": 412, "name": "Sale of Product Income" },
    { "id": 418, "name": "Service Income" },
    { "id": 423, "name": "Discounts given" },
    { "id": 431, "name": "Other Income" }
  ]
}

Inventory accounts

Same shape, no parameters — swap the path for /inventory-accounts.

200 OK
{
  "data": [
    { "id": 340, "name": "Inventory Asset" }
  ]
}

Bank accounts

Same again, with /bank-accounts.

200 OK
{
  "data": [
    { "id": 301, "name": "Checking" },
    { "id": 305, "name": "Savings" },
    { "id": 312, "name": "Undeposited Funds" }
  ]
}

Expense accounts

This one is different: it needs to know what kind of product the cost belongs to, because that decides which accounts are even eligible.

FieldTypeRequiredDescription
product_typestringRequiredinventory, non_inventory or service — the type of the product you are about to create.

What the product type changes

product_typeWhich accounts come back
inventoryCost of goods sold only.
non_inventoryAny expense account.
serviceAny expense account.

Why inventory is narrower

An inventory product's stock is held until it sells, so its cost belongs in cost of goods sold. A service or a non-inventory good holds nothing, so its cost can go to any expense account.

Example: an inventory product

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/expense-accounts' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'product_type=inventory'
200 OK
{
  "data": [
    { "id": 502, "name": "Supplies & Materials - COGS" }
  ]
}

Example: a service or non-inventory product

Send product_type=service or product_type=non_inventory and the whole list comes back.

200 OK
{
  "data": [
    { "id": 502, "name": "Supplies & Materials - COGS" },
    { "id": 509, "name": "Advertising" },
    { "id": 514, "name": "Rent or Lease" },
    { "id": 521, "name": "Office Expenses" }
  ]
}

Ask with the type you are actually creating

Fetch the list with the same type you will send on POST /products. Fetch it as service, let your user pick Advertising, then create the product as inventory — and you will be sending an account that type is not allowed to use.

Errors

A missing or unrecognised product_type is a 422:

422 Unprocessable
{
  "message": "The product type is required.",
  "errors": {
    "product_type": ["The product type is required."]
  }
}

Status codes

StatusMeaning
200The accounts are returned.
422product_type was missing, or was not one of the three values. Expense accounts only.
500Unexpected error.

Create a Product

Add a product or service your invoices can bill against.

POST/productsX-Tenant + API Key required

Creates a product or service on your account. Once created it can be referenced on any invoice line item. The response returns the full product record, including the fields the server filled in for you.

Body parameters

FieldTypeRequiredDescription
typestringRequiredinventory, non_inventory or service. It decides which of the fields below are required — see What each type requires.
namestringRequiredDisplay name shown on invoices and in your catalog.
skustringOptionalYour own identifier for the product. Optional — omit it and the field comes back null.
descriptionstringOptionalLonger text about the product, for your own reference and on the invoice line.
pricenumberOptionalThe selling price, 0 or more. Left out, it is 0. An invoice line still sends its own rate, or takes it from a pricing plan.
tagsarrayOptionalLabels you can group and filter products by. Each entry is an object carrying a label and nothing else — send [{ "label": "Earphone" }].
quantityintegerOptionalHow many units you hold. Required when type is inventory, ignored otherwise.
revenue_accountintegerOptionalId of the account that sales of this product post to. Required for inventory, optional for the other two. Take it from GET /income-accounts and send the one your user picked.
inventory_accountintegerOptionalId of the account that holds this product's stock value. Required when type is inventory, and not used otherwise. Take it from GET /inventory-accounts.
expense_accountintegerRequiredId of the account that the cost of this product posts to. Required whichever type you send. Take it from GET /expense-accounts, passing the same type as product_type — the eligible accounts differ by type.

What each type requires

The type you send decides what else has to be in the body.

typequantityinventory_accountexpense_accountrevenue_account
inventoryRequiredRequiredRequiredRequired
non_inventoryNot neededNot usedRequiredOptional
serviceNot neededNot usedRequiredOptional

An inventory product needs all four

Send type: "inventory" and you must also send quantity, inventory_account, expense_account and revenue_account. Miss any of them and the create is refused.

A service or non-inventory product needs far less

No quantity and no inventory_account — there is no stock to track. expense_account is still required; revenue_account is optional.

Never hard-code an account id

All the account ids come from Accounts, and they differ per tenant. Read the lists at runtime and send what your user picked.

Example: a service

JSON body
{
    "type": "service",
    "name": "Wireless Earbuds",
    "sku": "EAR-001",
    "description": "True wireless earbuds with noise isolation.",
    "price": 1500,
    "tags": [
        {
            "label": "Earphone"
        }
    ],
    "revenue_account": 17,
    "expense_account": 9
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/products' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "service",
    "name": "Wireless Earbuds",
    "sku": "EAR-001",
    "description": "True wireless earbuds with noise isolation.",
    "price": 1500,
    "tags": [
      { "label": "Earphone" }
    ],
    "revenue_account": 17,
    "expense_account": 9
  }'

Example: an inventory item

The same product tracked as stock — quantity and inventory_account appear, and revenue_account stops being optional.

JSON body
{
    "type": "inventory",
    "name": "Wireless Earbuds",
    "sku": "EAR-001",
    "description": "True wireless earbuds with noise isolation.",
    "tags": [
        {
            "label": "Earphone"
        }
    ],
    "quantity": 50,
    "revenue_account": 412,
    "expense_account": 502,
    "inventory_account": 340
}

Example response

The response echoes what you sent, plus two fields the server adds: the generated id — which is what you reference on invoice line items — and is_active, which starts as true. The account ids you sent are not echoed back.

200 OK
{
  "id": 3210,
  "name": "Wireless Earbuds",
  "sku": "EAR-001",
  "type": "service",
  "description": "True wireless earbuds with noise isolation.",
  "price": 1500,
  "tags": [{ "label": "Earphone", "value": "Earphone" }],
  "is_active": true
}

Store the id

This is the only place the new product's id is handed to you. Save it against your own record — you need it for every invoice line that bills this product.

Tags come back with an extra key

You send { "label": "Earphone" }; the response returns { "label": "Earphone", "value": "Earphone" }. The server fills value in from the label — do not send it yourself, and do not be surprised when the response does not match your request field for field.

Status codes

StatusMeaning
200Product created. The record is returned.
422Validation failed — a required field is missing or a value is not acceptable.
403You do not have permission for this product.
500Unexpected error.

Errors

Every error on the product endpoints comes back in the same shape — a single message. Show it, log it, and branch on the status code rather than on the text.

404 Not Found
{
  "message": "Product not found"
}

Validation errors add one key. message holds the first problem, and errors maps each rejected field to a list of messages — which is what you want if you are highlighting fields in a form:

422 Unprocessable
{
  "message": "The name field is required.",
  "errors": {
    "name": ["The name field is required."]
  }
}

Read errors, not message, when a form is involved

message is only the first failure. If two fields are invalid, the second one appears in errors and nowhere else — so a client that shows only message will have the user fix one field, resubmit, and hit the next error one at a time. Also note each value in errors is an array, since a single field can fail more than one rule.

Retry 500, never retry 4xx

A 500 may be temporary — your request could be fine, so retrying after a short backoff is reasonable. 422, 403 and 404 will fail identically every time; retrying them just wastes calls.

Authentication failures are handled once, not per endpoint

A bad or missing X-Tenant or API Key is rejected before the request reaches the product — so it is not listed above. Handle it centrally, as covered in Getting Started → Authentication.

Update a Product

Replace a product with how it should end up.

PUT/products/:idX-Tenant + API Key required

Replaces a product. Send the whole product as it should end up, not only the fields that changed.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe product's id, as returned by POST /products. The example updates product 90.

Body parameters

FieldTypeRequiredDescription
namestringRequiredDisplay name shown on invoices and in your catalog. Max 255.
revenue_accountintegerRequiredId of the account that sales of this product post to — from GET /income-accounts.
expense_accountintegerRequiredId of the account the cost posts to — from GET /expense-accounts.
inventory_accountintegerRequiredId of the stock account — from GET /inventory-accounts. Required here whatever the product's type — see the warning below.
skustringOptionalYour own identifier for the product. Max 100.
descriptionstringOptionalLonger text about the product.
pricenumberOptionalThe selling price, 0 or more. Left out, it becomes 0 — send the current price back to keep it.
tagsarrayOptionalLabels you can group and filter by, each an object with a label.

All four are required, even on a service

name, revenue_account, expense_account and inventory_account must all be in the body. This is stricter than create, where inventory_account is only wanted for an inventory product and revenue_account is optional for the other two.

Fields that are not accepted

These are dropped if sent:

  • type
  • quantity

You cannot change a product's type

type is fixed at creation. Sending a different one here does not fail — it is simply ignored, and the response comes back with the type the product already had. The same goes for quantity.

Stock quantity is changed elsewhere

Because quantity is dropped here, this is not the endpoint for moving stock. Stock has to stay tracked, so a change in quantity goes through POST /products/inventory-adjustment, which records the reason and the account the movement posts to — see Inventory Adjustments.

Example request

JSON body
{
  "name": "On-Site Repair Service",
  "sku": "SERV-003",
  "description": "Engineer visit and on-site repair.",
  "price": 800,
  "revenue_account": 17,
  "expense_account": 9,
  "inventory_account": 10,
  "tags": [{ "label": "Repair" }]
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/90' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "On-Site Repair Service",
    "sku": "SERV-003",
    "description": "Engineer visit and on-site repair.",
    "price": 800,
    "revenue_account": 17,
    "expense_account": 9,
    "inventory_account": 10,
    "tags": [{ "label": "Repair" }]
  }'

Example response

200 OK
{
  "id": 90,
  "name": "On-Site Repair Service",
  "sku": "SERV-003",
  "type": "service",
  "description": "Engineer visit and on-site repair.",
  "price": 800,
  "revenue_account": 17,
  "expense_account": 9,
  "inventory_account": null,
  "tags": [{ "label": "Repair", "value": "Repair" }],
  "is_active": true
}

An account that is not set comes back null

In the example inventory_account was sent as 10 but comes back null — the product is a service, so there is no stock for it to hold. Read the response rather than assuming what you sent was kept.

Unlike create, this response does echo the accounts

revenue_account, expense_account and inventory_account are all in the body above. POST /products does not return them, and neither do the two reads — so this is the one place the API tells you what a product's accounts actually are.

Status codes

StatusMeaning
200The product is updated and returned.
404No product with that id.
422A required field is missing, or the name or SKU already belongs to another product.

Errors

404 Not Found
{
  "message": "Product not found"
}

name and sku are both unique within a tenant, so a clash is a 422:

422 Unprocessable
{
  "message": "A product with this name already exists.",
  "errors": { "name": ["A product with this name already exists."] }
}

A 422 is as likely to be a clash as a missing field

The message names the field either way, so branch on errors rather than assuming the user left something blank. A missing field carries the same shape — see create.

List Products

Read your products back, a page at a time.

GET/productsX-Tenant + API Key required

Returns your products in pages, newest first. Use this to populate a product picker in your own UI, or to find the id you need for an invoice line item.

Query parameters

FieldTypeRequiredDescription
pageintegerRequiredWhich page to return, starting at 1.
page_lengthintegerRequiredHow many products per page. Comes back as per_page in the response.
searchstringRequiredA JSON object, sent as a string, holding your filters. Send {} for no filter — that is what the example does.

search filters are not documented yet

Only the empty object {} has been confirmed here. List Contacts takes the same search parameter and does accept a key inside it, so this one probably accepts keys too — but which ones has not been supplied. Filter on your side for now.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/products' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=10' \
  --data-urlencode 'search={}'

Example response

Two keys: the products in data, and the paging in meta. Each entry is the same seven-field record that Create a Product and Get a Product return, so one parser covers all three.

meta

FieldWhat it is
totalHow many products exist in total, across every page — 6 in the example.
current_pageThe page you are on, echoing the page you asked for.
last_pageThe highest page number available. Stop paging when current_page reaches it.
per_pagePage size in effect, echoing page_length.
from / toPosition of the first and last item on this page within the full set — 1 and 6 here.

This envelope is not the one the other lists use

Products put their paging inside meta. The contact, invoice and payment lists put the same values at the top level next to data, and add links and URL fields that are not here. So response.meta.last_page on this endpoint is response.last_page on the others — write the paging helper to take the envelope it is given rather than assuming one shape.

No paging URLs to worry about

Unlike the other lists, this response contains no next_page_url, links or path — so none of the internal-host and malformed-query problems those carry apply here. Page with current_page against last_page.

Fields worth knowing

FieldWhat it tells you
typeinventory, non_inventory or service — whichever you created it as.
description / tagsWhat you sent when you created the product. tags is an empty array when you did not send any.
is_activeWhether the product is still in use. Every product on the example page is active.
skuYour own identifier, or null if you did not send one.

The account ids are not in the list

revenue_account and expense_account are required when you create a product, but they do not come back on any read — not here and not on GET /products/:id. Keep your own copy if you need them.

One thing to confirm

Whether inactive products are included in the list or filtered out of it. Every product in the example is active, so there is nothing to tell from it.
200 OK (data trimmed to one of six products)
{
  "data": [
    {
      "id": 6,
      "name": "Premium Monthly",
      "sku": "PRECNBRHWH",
      "type": "service",
      "description": "A Premium Monthly",
      "price": 499,
      "tags": [],
      "is_active": true
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "last_page": 1,
    "total": 6,
    "from": 1,
    "to": 6
  }
}

Status codes

StatusMeaning
200The page is returned, even when data is empty.
403You do not have permission for this product.
500Unexpected error.

Error shape

Errors carry a single message, the same as everywhere else on the product endpoints — see Errors under Create a Product. An empty page is a 200 with an empty data array, not an error.

Get a Product

Read a single product back by its id.

GET/products/:idX-Tenant + API Key required

Returns one product. Use it to refresh a product you already hold the id for — after creating it, or after picking it out of List Products.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe product's id, as returned by POST /products or found in the list. The example reads product 3210 — the one created above.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/3210' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

The product on its own — no wrapper, no paging fields — and the same seven fields POST /products returns.

200 OK
{
  "id": 3210,
  "name": "Wireless Earbuds",
  "sku": "EAR-001",
  "type": "service",
  "description": "True wireless earbuds with noise isolation.",
  "price": 1500,
  "tags": [{ "label": "Earphone", "value": "Earphone" }],
  "is_active": true
}

No envelope on this one

The product sits at the top level of the response rather than under a data or product key. Read the fields straight off the response body.

Same shape everywhere

These seven fields are exactly what you get from POST /products and from each entry in GET /products. One product model in your code covers all three calls.

The account ids are not returned

The account ids you sent when creating the product are not on this response. If you need them, keep your own copy.

Status codes

StatusMeaning
200The product is returned.
404No product with that id.
403The product exists but you do not have permission to see it.
500Unexpected error.

Errors

404 Not Found
{
  "message": "Product not found"
}

404 and 403 mean different things — handle both

404 is “no such product”; 403 is “it exists, but not for you”. Treating both as “missing” will quietly hide a permissions problem from whoever is trying to use your integration. The full error shapes are under Errors on Create a Product.

Inventory Adjustments

Change the stock held for a product, and record why.

An inventory adjustment changes the stock held for one or more products, and records why it changed. It is the only way to move a product's quantity through the API.

Quantity does not change through Update a Product

PUT /products/:id drops quantity if you send it — see Update a Product. Stock has to stay tracked, so every movement goes through POST /products/inventory-adjustment instead, which records the reason and the account the movement posts to and leaves a history you can read back from GET /products/:id/inventory.

The flow

  1. 1

    Fetch a reference number

    GET /products/latest-inventory-number gives you the next ref_no to put on the adjustment.
  2. 2

    Fetch the accounts it can post to

    GET /inventory-adjustment-accounts returns every account the adjustment can be posted to. Send the id your user picked as adjustment_account.
  3. 3

    Fetch the list of reasons

    GET /products/inventory-adjustment-reasons returns the seven reasons. Send the value, show the label.
  4. 4

    Post the adjustment

    POST /products/inventory-adjustment with the reference number, the date, the account, the reason and the items to move.

End to end: adding 20 to a product's stock

The three reads first — the reference number, the accounts and the reasons:

cURL — steps 1 to 3
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/latest-inventory-number' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/inventory-adjustment-accounts' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/inventory-adjustment-reasons' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Then the adjustment itself. The product holds 50; adjusted_quantity of 20 moves it by 20, not to 20:

cURL — step 4
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/inventory-adjustment' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "ref_no": "00088",
    "adjustment_date": "2026-09-17",
    "adjustment_account": 20,
    "reason": "other",
    "items": [
      { "product_id": 85, "adjusted_quantity": 20 }
    ]
  }'

The response carries the stored adjustment, and product.available_stock shows the product now holds 70:

201 Created
{
  "id": 106,
  "ref_no": "00088",
  "adjustment_date": "2026-09-17",
  "adjustment_account": 20,
  "reason": "other",
  "items": [
    {
      "id": 134,
      "inventory_adjustment_id": 106,
      "product_id": 85,
      "adjusted_quantity": 20,
      "product": {
        "name": "Retail Lite Test",
        "available_stock": 70
      }
    }
  ]
}

Authentication is handled once, not per endpoint

Every call below takes the same X-Tenant and API Key headers as the rest of the API, and a bad or missing one is rejected before the request reaches the adjustment — so it is not listed on each endpoint. See Getting Started → Authentication.

Get an Adjustment Reference Number

The next reference number to use on an adjustment.

GET/products/latest-inventory-numberX-Tenant + API Key required

Returns the next reference number to use on an adjustment. Call it before you post one and send what comes back as ref_no.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/latest-inventory-number' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "data": {
    "ref_no": "00002"
  }
}

Response fields

FieldTypeWhat it is
data.ref_nostringThe next reference number.

ref_no is a string

It is returned as a string so the leading zeros survive — "00002", not 2. Keep it a string on your side and send it back as one.

Status codes

StatusMeaning
200The reference number is returned.
500Unexpected error.

List Adjustment Accounts

Every active account an adjustment can be posted to.

GET/inventory-adjustment-accountsX-Tenant + API Key required

Returns every active account an adjustment can be posted to. This is a wider list than the inventory accounts — an adjustment can land almost anywhere in the chart: COGS, Expenses, Income, Equity, Assets, Bank and Liabilities.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/inventory-adjustment-accounts' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "data": [
    {
      "id": 3321,
      "name": "Cost of Goods Sold"
    }
  ]
}

Response fields

FieldTypeWhat it is
data[].idintegerThe account id. This is what you send as adjustment_account.
data[].namestringThe account name, for showing in your picker.

No paging on this one

The whole list comes back in data, so there is no meta and no page parameter.

Status codes

StatusMeaning
200The accounts are returned.
500Unexpected error.

List Adjustment Reasons

The seven reasons an adjustment can carry.

GET/products/inventory-adjustment-reasonsX-Tenant + API Key required

Returns the reasons an adjustment can carry. The list is fixed and does not vary by tenant.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/inventory-adjustment-reasons' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "data": [
    { "label": "Stock on Fire",         "value": "stock_on_fire" },
    { "label": "Stolen Goods",          "value": "stolen_goods" },
    { "label": "Damaged Goods",         "value": "damaged_goods" },
    { "label": "Stock Written Off",     "value": "stock_written_off" },
    { "label": "Stocktaking Results",   "value": "stocktaking_results" },
    { "label": "Inventory Revaluation", "value": "inventory_revaluation" },
    { "label": "Other",                 "value": "other" }
  ]
}

Response fields

FieldTypeWhat it is
data[].labelstringThe reason as it should be shown to a user.
data[].valuestringThe reason as it is sent — this is what goes in the reason field of an adjustment.

No paging on this one

The whole list comes back in data, so there is no meta.

Status codes

StatusMeaning
200The reasons are returned.
500Unexpected error.

Create an Inventory Adjustment

Move the stock held for one or more products.

POST/products/inventory-adjustmentX-Tenant + API Key required

Creates an adjustment. Each entry in items moves one product's stock, and the whole adjustment is stored against the account and reason you send.

Body parameters

FieldTypeRequiredDescription
ref_nostringRequiredThe reference number, max 50 characters. Take it from GET /products/latest-inventory-number.
adjustment_datestringRequiredThe date of the adjustment, in YYYY-MM-DD format exactly.
adjustment_accountintegerRequiredId of the account the adjustment posts to — from GET /inventory-adjustment-accounts.
reasonstringRequiredWhy the stock changed. One of the seven values from GET /products/inventory-adjustment-reasons.
itemsarrayRequiredThe products to adjust. At least one entry.
items[].product_idintegerRequiredId of the product to adjust. A product cannot appear twice in one request.
items[].adjusted_quantitynumericRequiredHow far to move the stock. Cannot be 0.

adjusted_quantity is a movement, not a new total

It is how far to move the stock, not what the stock should end up at. A negative value takes stock away, a positive value adds it. You never send the current stock level or the resulting level — the API reads the current level off the product and works out the rest.

Example request

JSON body
{
  "ref_no": "00002",
  "adjustment_date": "2026-09-17",
  "adjustment_account": 3321,
  "reason": "other",
  "items": [
    {
      "product_id": 3180,
      "adjusted_quantity": 20
    }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/inventory-adjustment' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "ref_no": "00002",
    "adjustment_date": "2026-09-17",
    "adjustment_account": 3321,
    "reason": "other",
    "items": [
      { "product_id": 3180, "adjusted_quantity": 20 }
    ]
  }'

Example response

201 Created
{
  "id": 106,
  "ref_no": "00088",
  "adjustment_date": "2026-09-17",
  "adjustment_account": 20,
  "reason": "other",
  "items": [
    {
      "id": 134,
      "inventory_adjustment_id": 106,
      "product_id": 85,
      "adjusted_quantity": 20,
      "product": {
        "name": "Retail Lite Test",
        "available_stock": 70
      }
    }
  ]
}

Response fields

FieldTypeWhat it is
idintegerId of the stored adjustment.
ref_nostringThe reference number it was stored under.
adjustment_datestringThe date the adjustment was made for.
adjustment_accountintegerId of the account it posted to.
reasonstringThe reason value sent.
items[].idintegerId of the adjustment line.
items[].inventory_adjustment_idintegerId of the adjustment the line belongs to.
items[].product_idintegerId of the product that was adjusted.
items[].adjusted_quantitynumberHow far the stock was moved.
items[].product.namestringName of the product that was adjusted.
items[].product.available_stocknumberWhat the product holds after the adjustment.

Status codes

StatusMeaning
201The adjustment is stored and returned.
422Validation failed — see the table below.
500Unexpected error.

Validation errors

CauseMessage
Product is a service or non-inventory productProduct 3180 is not an inventory product, so its stock cannot be adjusted.
Product carries no stock quantityProduct 3180 does not hold a stock quantity, so it cannot be adjusted.
Reduction exceeds stock heldProduct 3180 holds 50 in stock, so it cannot be reduced by 60.
Reason not in the listThe reason must be one of those listed by /products/inventory-adjustment-reasons.
Quantity is zeroThe adjusted quantity cannot be zero.
Same product twiceThe same product cannot be adjusted twice in one adjustment.
Bad date formatThe adjustment date must be in YYYY-MM-DD format.
422 Unprocessable
{
  "message": "Product 3180 holds 50 in stock, so it cannot be reduced by 60.",
  "errors": {
    "items.0.adjusted_quantity": [
      "Product 3180 holds 50 in stock, so it cannot be reduced by 60."
    ]
  }
}

Nothing is written until every check passes

All the checks above run before anything is written, so one failing item means nothing is adjusted at all. There is never a partial adjustment — a 422 leaves every product exactly as it was.

List Inventory Adjustments

Read your adjustments back, a page at a time.

GET/products/inventory-adjustmentX-Tenant + API Key required

Returns your adjustments in pages. Each entry is the same adjustment object that POST /products/inventory-adjustment returns.

Query parameters

FieldTypeRequiredDescription
pageintegerOptionalWhich page to return. Defaults to 1.
page_lengthintegerOptionalHow many adjustments per page. Defaults to 10, and comes back as per_page.
searchstringOptionalA JSON object, sent as a string, holding your filters. Send {} for no filter.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/inventory-adjustment' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=10' \
  --data-urlencode 'search={}'

Example response

200 OK
{
  "data": [
    {
      "id": 106,
      "ref_no": "00088",
      "adjustment_date": "2026-09-17",
      "adjustment_account": 20,
      "reason": "other",
      "items": [
        {
          "id": 134,
          "inventory_adjustment_id": 106,
          "product_id": 85,
          "adjusted_quantity": 20,
          "product": {
            "name": "Retail Lite Test",
            "available_stock": 70
          }
        }
      ]
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "last_page": 1,
    "total": 1,
    "from": 1,
    "to": 1
  }
}

meta

FieldWhat it is
current_pageThe page you are on, echoing the page you asked for.
per_pagePage size in effect, echoing page_length.
last_pageThe highest page number available. Stop paging when current_page reaches it.
totalHow many adjustments exist in total, across every page.
from / toPosition of the first and last adjustment on this page within the full set.

Status codes

StatusMeaning
200The page is returned, even when data is empty.
500Unexpected error.

Get an Inventory Adjustment

Read a single adjustment back by its id.

GET/products/inventory-adjustment/:idX-Tenant + API Key required

Returns one adjustment — the same object POST /products/inventory-adjustment returns, on its own with no data wrapper.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe adjustment's id, as returned when it was created. The example reads adjustment 106.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/inventory-adjustment/106' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "id": 106,
  "ref_no": "00088",
  "adjustment_date": "2026-09-17",
  "adjustment_account": 20,
  "reason": "other",
  "items": [
    {
      "id": 134,
      "inventory_adjustment_id": 106,
      "product_id": 85,
      "adjusted_quantity": 20,
      "product": {
        "name": "Retail Lite Test",
        "available_stock": 70
      }
    }
  ]
}

Status codes

StatusMeaning
200The adjustment is returned.
404No adjustment with that id.
500Unexpected error.

Errors

404 Not Found
{
  "message": "Inventory adjustment not found"
}

Get a Product's Inventory

A product and the stock movements that got it to where it stands.

GET/products/:id/inventoryX-Tenant + API Key required

Returns a product together with the stock movements that got it to where it stands.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe product's id. The example reads product 3520.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/3520/inventory' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "id": 3520,
  "code": "GEN-000001",
  "name": "Cards",
  "sku": "GEN-000001",
  "type": "inventory",
  "is_active": true,
  "available_stock": 20,
  "revenue_account": 17,
  "expense_account": 9,
  "inventory_account": 10,
  "stock_list": [
    {
      "entry_from": "Product",
      "detail": {
        "id": 3520,
        "name": "Cards"
      },
      "quantity": 20,
      "as_of_qty": 20
    }
  ]
}

Response fields

FieldTypeWhat it is
idintegerThe product id.
codestringThe product code.
namestringThe product name.
skustringYour own identifier.
typestringinventory, non_inventory or service.
is_activebooleanWhether the product is still in use.
available_stocknumberWhat the product holds right now.
revenue_account / expense_account / inventory_accountintegerThe product's account ids.
stock_listarrayThe movement history — see below.

stock_list

Each entry is one movement, and maps to a row of a stock history table like this:

ColumnField
Transaction Typeentry_from + detail.name
Qty Inquantity
Qty on Handas_of_qty
FieldTypeWhat it is
entry_fromstringWhat caused the movement — "Product" for opening stock, for example.
detailobjectThe record that caused the movement, carrying its id and name.
quantitynumberHow far this movement moved the stock.
as_of_qtynumberWhat the product held after this movement.

Status codes

StatusMeaning
200The product and its movements are returned.
404No product with that id.
500Unexpected error.

Conventions on these endpoints

ConventionWhat it means
QuantitiesNumbers, not strings. A whole value carries no trailing .0.
IdsIntegers, or null when unset.
Single resourcesReturned bare, with no data wrapper — the one exception is GET /products/latest-inventory-number.
CollectionsWrapped in data, with meta only when the endpoint is paginated.

Create a Customer

Add the person or business your invoices are issued to.

POST/customersX-Tenant + API Key required

Creates a customer along with its billing and shipping addresses in the same call. The body has two parts: contact_infos for the person or business, and addresses for where they are billed and shipped to.

What is actually required

email always, plus a name — first_name in contact_infos, or company_name in additional_infos. Send company_name and first_name stops being required. Everything else, including the whole addresses array, is optional.

The two choices you are giving your user

Whatever form you build on top of this endpoint has two independent decisions in it, and every combination is valid:

ChoiceOption AOption B
Company nameLeft out — a person. first_name is then required.Sent in additional_infos — a business. first_name becomes optional, and if you do send it, it is the contact person at that business.
AddressTyped by hand — is_google_address: false, and you send only the plain fields.Picked from Google Places — is_google_address: true, and you pass the Places fields through as well.

There is no flag saying which one it is

Nothing in the body declares a person or a business. What makes a record a business is simply the presence of company_name — so an accidental empty string there turns a person into a nameless business. Omit the key rather than sending "".

There is no type field to send

The create body does not take one, and the create response does not return one. You will see "type": "customer" on the list and read-by-id responses further down this page — the server sets it there. Leave it out of anything you send.

contact_infos

FieldTypeRequiredDescription
emailstringRequiredWhere invoices are emailed. Required for both a person and a company.
first_namestringRequiredGiven name of the person. Required only when you are not sending company_name — on a business it is optional, and names the contact person rather than the business itself.
last_namestringOptionalFamily name of the person.
titlestringOptionalSalutation such as Mr or Ms.
phone_numberstringOptionalContact number including country code, digits only — for example 919685745259.

company_name is what makes it a company

There is no type flag to set. Send company_name and you get a company; leave it out and you get a person. So an accidental empty company_name on a person record is a real risk — omit the key rather than sending "".

additional_infos

A separate object, and the only place the business name goes. Leave the whole object out when you are creating a person.

FieldTypeRequiredDescription
company_namestringOptionalThe business name. Sending it makes the record a business and releases you from sending first_name. It is also what display_name is derived from.

It is additional_infos going in, add_infos coming back

You send the object as additional_infos; every read response returns it as add_infos, and as an array rather than an object. Do not reuse one field name for both directions.

Only company_name is confirmed here

Read responses show add_infos also carrying gst_treatment, term_id, is_tax_exempt, customer_type, website and more. Whether this endpoint accepts them on creation has not been supplied, so only company_name is documented as settable. The rest come back with defaults.

addresses

An array. Send one entry per address, each tagged with its type. Billing and shipping can be the same address — repeat the same values under both types, as in the first example below.

FieldTypeRequiredDescription
typestringRequiredbilling or shipping.
formatted_addressstringRequiredThe whole address as a single line, exactly as it should appear on the invoice.
countrystringRequiredTwo-letter ISO country code — for example IN.
administrative_area_level_1stringOptionalState or province code — for example MH, HR.
localitystringOptionalCity or town.
postal_codestringOptionalPostal or PIN code.
is_google_addressbooleanRequiredtrue if the address came from Google Places, false if it was typed in by hand. This decides which of the fields below apply.
is_primarybooleanOptionalMarks this as the default address for its type.

Addresses from Google Places

Both examples below type the address in by hand, so they set is_google_address: false and stop at the fields above. When the address came out of a Google Places lookup instead, set it to true and add these — pass them through from the Places result unchanged:

FieldTypeRequiredDescription
google_place_idstringOptionalThe Places identifier for the selected address.
routestringOptionalStreet name component.
street_numberstringOptionalBuilding or house number. Send an empty string when Google did not return one.
administrative_area_level_2stringOptionalDistrict or division — for example Pune Division.
latitudenumberOptionalLatitude of the place.
longitudenumberOptionalLongitude of the place.
One address, Google-sourced
{
  "type": "billing",
  "formatted_address": "A-5, Block A, Sector 26A, Gurugram, Haryana 122002, India",
  "country": "IN",
  "administrative_area_level_1": "HR",
  "administrative_area_level_2": "Gurgaon Division",
  "locality": "Gurugram",
  "postal_code": "122002",
  "route": "A-5",
  "street_number": "",
  "latitude": 28.4728561,
  "longitude": 77.0995667,
  "google_place_id": "EjlBLTUsIEJsb2NrIEEsIFNlY3RvciAyNkEsIEd1cnVncmFtLCBIYXJ5YW5hIDEyMjAwMiwgSW5kaWEiLi4...",
  "is_google_address": true,
  "is_primary": true
}

null or empty string on the unfilled Google fields?

Google does not always return a street number or a postal code. Two captures disagree on what to send when it does not: one used "" for street_number, the other used null for street_number, route and postal_code. Both appear to be accepted. Pick one and use it everywhere rather than mixing, and expect either to read back as null.

Example: a person, address typed by hand

No additional_infos, so this is a person and first_name is required. Billing and shipping are the same address, so the same values appear twice with different type values.

Person, manual address
{
  "contact_infos": {
    "title": "Ms",
    "first_name": "Priya",
    "last_name": "Sharma",
    "email": "priya.sharma@example.com",
    "phone_number": "919685745259"
  },
  "addresses": [
    {
      "type": "billing",
      "formatted_address": "21 MG Road",
      "country": "IN",
      "administrative_area_level_1": "MH",
      "locality": "Mumbai",
      "postal_code": "425360",
      "is_google_address": false,
      "is_primary": true
    },
    {
      "type": "shipping",
      "formatted_address": "21 MG Road",
      "country": "IN",
      "administrative_area_level_1": "MH",
      "locality": "Mumbai",
      "postal_code": "425360",
      "is_google_address": false,
      "is_primary": true
    }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/customers' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "contact_infos": {
      "title": "Ms",
      "first_name": "Priya",
      "last_name": "Sharma",
      "email": "priya.sharma@example.com",
      "phone_number": "919685745259"
    },
    "addresses": [
      {
        "type": "billing",
        "formatted_address": "21 MG Road",
        "country": "IN",
        "administrative_area_level_1": "MH",
        "locality": "Mumbai",
        "postal_code": "425360",
        "is_google_address": false,
        "is_primary": true
      },
      {
        "type": "shipping",
        "formatted_address": "21 MG Road",
        "country": "IN",
        "administrative_area_level_1": "MH",
        "locality": "Mumbai",
        "postal_code": "425360",
        "is_google_address": false,
        "is_primary": true
      }
    ]
  }'

Example: a business

company_name sits in additional_infos, which is what makes this a business — so first_name is no longer required. It is sent anyway here, because it names the person to deal with at that business.

This example carries no addresses, only to show that the array is optional. You can send addresses on a business exactly as the person example does — add the same addresses array, typed by hand or picked from Google Places. Nothing about a business changes how addresses work.

Business
{
  "contact_infos": {
    "first_name": "Rohan",
    "last_name": "Verma",
    "title": "Mr",
    "email": "rohan.verma@example.com",
    "phone_number": "919685745259"
  },
  "additional_infos": {
    "company_name": "Verma Enterprises"
  }
}

Example response

The created customer. Store the id — it is what you pass as customer_id when you raise an invoice.

200 OK — person
{
  "id": 16908,
  "title": null,
  "first_name": "Priya",
  "last_name": "Sharma",
  "display_name": "Priya Sharma",
  "email": "priya.sharma@example.com",
  "phone_number": "919685745259",
  "addresses": [
    {
      "id": "14893",
      "type": "billing",
      "formatted_address": "A-5, Block A, Sector 26A, Gurugram, Haryana 122002, India",
      "administrative_area_level_1": "HR",
      "administrative_area_level_2": "Gurgaon Division",
      "country": "IN",
      "locality": "Gurugram",
      "postal_code": "122002",
      "route": "A-5",
      "street_number": null,
      "google_place_id": "EjlBLTUsIEJsb2NrIEEsIFNlY3RvciAyNkE...",
      "latitude": 28.4728561,
      "longitude": 77.0995667,
      "is_google_address": true,
      "address_line_1": null,
      "address_line_2": null,
      "is_primary": true
    }
  ],
  "open_balance": 0,
  "over_due": 0,
  "is_active": true
}

What the server adds

FieldYou sentComes back as
idNothingThe customer id. This is the only place you get it.
display_nameNothing — it is not a request fieldDerived. Priya Sharma from the first and last name; on a business it is derived from company_name instead.
open_balance / over_dueNothing0 on a new customer. They move as invoices and payments are recorded.
is_activeNothingtrue.

What happens to the addresses you sent

FieldBehaviour
idEach address is assigned one — and it is a string, "14893", not a number.
address_line_1 / address_line_2Added to every address as null. They are not request fields.
street_numberComes back null when Google did not supply one, whether you sent null or an empty string.
Everything elseReturned as you sent it — formatted_address, locality, postal_code, the Places fields, is_google_address and is_primary all pass through.

One address in, one address out

The array is returned with the same entries you sent, each keeping its type. Send billing and shipping and you get both back; send one and you get one. Nothing is invented for you.

A business returns one extra key

Everything above is identical. The only difference is an add_infos array, placed after addresses, holding the company name you sent:

Extra key on a business
  "add_infos": [
    { "id": 618, "company_name": "Verma Enterprises" }
  ],

company_name changes name and nesting on the way back

You send it as additional_infos.company_name — an object. It returns as add_infos[0].company_name — an array, under a shortened key. Three things to get right at once, so read it from add_infos[0] rather than reusing the request path.

add_infos is absent, not empty, on a person

The person response above has no add_infos key at all — it is not an empty array. Check the key exists before indexing into it, or a person record will throw.

Where the rest of the business details live

The other business fields — website, gst_treatment, payment terms, tax exemption — live on the same add_infos record, but the create response returns only id and company_name. How to set or read the rest has not been supplied.

Status codes

StatusMeaning
200Customer created. The record is returned.
422A required field is missing or an address entry is invalid.

Update a Customer

Replace a customer with how it should end up.

PUT/customers/:idX-Tenant + API Key required

Replaces a customer. Send the whole customer as it should end up, not only the fields that changed.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe customer's id, as returned by POST /customers. The example updates customer 16908.

Body parameters

The same payload as Create a Customer — same fields, same rules, same address shapes. Nothing extra and nothing removed; the id travels in the URL, not in the body.

Example request

JSON body
{
  "contact_infos": {
    "title": "Ms",
    "first_name": "Priya",
    "last_name": "Sharma",
    "email": "priya.sharma@example.com",
    "phone_number": "919685745259"
  },
  "addresses": [
    {
      "type": "billing",
      "formatted_address": "21 MG Road",
      "country": "IN",
      "administrative_area_level_1": "MH",
      "locality": "Mumbai",
      "postal_code": "425360",
      "is_google_address": false,
      "is_primary": true
    },
    {
      "type": "shipping",
      "formatted_address": "21 MG Road",
      "country": "IN",
      "administrative_area_level_1": "MH",
      "locality": "Mumbai",
      "postal_code": "425360",
      "is_google_address": false,
      "is_primary": true
    }
  ]
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/customers/16908' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "contact_infos": {
      "title": "Ms",
      "first_name": "Priya",
      "last_name": "Sharma",
      "email": "priya.sharma@example.com",
      "phone_number": "919685745259"
    },
    "addresses": [
      {
        "type": "billing",
        "formatted_address": "21 MG Road",
        "country": "IN",
        "administrative_area_level_1": "MH",
        "locality": "Mumbai",
        "postal_code": "425360",
        "is_google_address": false,
        "is_primary": true
      },
      {
        "type": "shipping",
        "formatted_address": "21 MG Road",
        "country": "IN",
        "administrative_area_level_1": "MH",
        "locality": "Mumbai",
        "postal_code": "425360",
        "is_google_address": false,
        "is_primary": true
      }
    ]
  }'

Example response

The same record you get back from create, so both can share one model on your side.

200 OK
{
  "id": 16908,
  "title": null,
  "first_name": "Priya",
  "last_name": "Sharma",
  "display_name": "Priya Sharma",
  "email": "priya.sharma@example.com",
  "phone_number": "919685745259",
  "addresses": [
    {
      "id": "14893",
      "type": "billing",
      "formatted_address": "A-5, Block A, Sector 26A, Gurugram, Haryana 122002, India",
      "administrative_area_level_1": "HR",
      "administrative_area_level_2": "Gurgaon Division",
      "country": "IN",
      "locality": "Gurugram",
      "postal_code": "122002",
      "route": "A-5",
      "street_number": null,
      "google_place_id": "EjlBLTUsIEJsb2NrIEEsIFNlY3RvciAyNkE...",
      "latitude": 28.4728561,
      "longitude": 77.0995667,
      "is_google_address": true,
      "address_line_1": null,
      "address_line_2": null,
      "is_primary": true
    }
  ],
  "open_balance": 0,
  "over_due": 0,
  "is_active": true
}

Errors

404 Not Found
{
  "message": "Customer not found"
}

Status codes

StatusMeaning
200Customer updated. The record is returned.
404No customer with that id.
422A required field is missing or an address entry is invalid.

List Customers

Read your customers back, a page at a time.

GET/customersX-Tenant + API Key required

Returns your customers in pages. Use the id of the one you want when you raise an invoice. Each entry carries the customer's addresses and outstanding balance, so a customer list in your own UI does not need a second call per row.

Query parameters

FieldTypeRequiredDescription
pageintegerRequiredWhich page to return, starting at 1.
page_lengthintegerRequiredHow many customers per page. See the warning below — the example did not get back the size it asked for.
typestringRequiredWhich kind of contact to return — customer in the capture. Probably redundant now that the path itself says customers; see the note below.
sortstringRequiredA JSON object, sent as a string, with sort_by and sort_order. Both empty strings in the example, which gives you the default order.
searchstringRequiredA JSON object, sent as a string, holding your filters. The example sends {"bothActiveInactive":2}.

Both JSON parameters must be URL-encoded

sort and search carry braces and quotes, so encode them before putting them in the query string — --data-urlencode in cURL, or your HTTP client's own parameter handling. Pasting the raw JSON into a URL will not work.

search and sort values are only partly known

  • bothActiveInactive with the value 2 is the one filter confirmed to work. Judging by the name it controls whether inactive customers are included, but what 1 and 0 do has not been supplied — so this is the only value you can rely on today.
  • Which other keys search accepts — by name, by email, by balance — is not documented.
  • Which column names sort_by takes, and whether sort_order wants asc/desc, has not been supplied. Send both empty for the default order.

type is probably no longer needed

The capture below was taken when this endpoint was /contacts — a shared endpoint for every kind of contact, where type=customer was what narrowed it to customers. Now that the path is /customers, that filter has nothing left to do. Confirm whether it can be dropped.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/customers' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=10' \
  --data-urlencode 'type=customer' \
  --data-urlencode 'sort={"sort_by":"","sort_order":""}' \
  --data-urlencode 'search={"bothActiveInactive":2}'

Example response

The customers are in data, with the paging fields around it. Build your paging from current_page, last_page and total, not from the URLs in the response.

This capture predates the current shape

It was taken from /contacts, before GET /products and GET /invoices moved to a data plus meta envelope with slimmer entries. Expect this endpoint to have changed the same way — read the response below for the field names, not as the current shape.

page_length did not take effect

The example asked for page_length=10 against 6 total customers, which should be a single page. What came back was per_page: 1 and last_page: 6 — one customer per page. Either page_length is ignored on this endpoint or it is read from somewhere else. Do not assume the page size you ask for is the page size you get: read per_page and last_page off the response and page until current_page reaches last_page.

Fields worth knowing

FieldWhat it tells you
display_nameWhat to show in your UI. It is the company name for a business and the person's own name for an individual, so you never have to assemble it from the name parts.
open_balance / over_dueWhat the customer owes in total, and how much of that is past its due date. Both 600 in the example, meaning the whole balance is overdue.
addressesThe billing and shipping addresses, each tagged with its type — the same shape you sent when you created the customer.
add_infosThe extra customer record — payment term, GST treatment, delivery method, classification. Always an array, with one entry per contact.
typeThe contact kind, echoing the type you filtered on.
transactionsPresent on the list but empty in the example. What populates it has not been confirmed.

Ignore the fields that are not about billing

add_infos carries pets, resident_access and occupants, and the contact carries renter_insurance and tds_config. These belong to other products built on the same contact record and mean nothing for invoicing — leave them alone.
200 OK
{
    "current_page": 1,
    "data": [
        {
            "id": 5,
            "shopify_id": null,
            "uuid": "107cacec-53d3-407b-8bb2-cca2f9bb14ce",
            "title": null,
            "first_name": "David",
            "middle_name": "Kwan",
            "last_name": "Chen",
            "display_name": "David Kwan Chen",
            "name_on_checks": null,
            "email": "david.chen@example.com",
            "phone_number": "+918746145263",
            "mobile_number": null,
            "type": "customer",
            "created_at": "2026-03-09T13:15:34.000000Z",
            "updated_at": "2026-03-09T13:15:34.000000Z",
            "deleted_at": null,
            "is_active": 1,
            "open_balance": 600,
            "over_due": 600,
            "transactions": [],
            "notes": [],
            "attachments": [],
            "addresses": [
                {
                    "id": "5",
                    "administrative_area_level_1": "Bengkulu",
                    "administrative_area_level_2": "Bengkulu City",
                    "country": "ID",
                    "formatted_address": "Bengkulu",
                    "google_place_id": "ChIJeZLjNx6wNi4R6qaQ53a1eaA",
                    "locality": "Bengkulu",
                    "postal_code": null,
                    "route": null,
                    "street_number": null,
                    "latitude": -3.7928451,
                    "longitude": 102.2607641,
                    "type": "shipping",
                    "is_google_address": true,
                    "address_line_1": null,
                    "address_line_2": null,
                    "is_primary": false
                },
                {
                    "id": "5",
                    "administrative_area_level_1": "Bengkulu",
                    "administrative_area_level_2": "Bengkulu City",
                    "country": "ID",
                    "formatted_address": "Bengkulu",
                    "google_place_id": "ChIJeZLjNx6wNi4R6qaQ53a1eaA",
                    "locality": "Bengkulu",
                    "postal_code": null,
                    "route": null,
                    "street_number": null,
                    "latitude": -3.7928451,
                    "longitude": 102.2607641,
                    "type": "billing",
                    "is_google_address": true,
                    "address_line_1": null,
                    "address_line_2": null,
                    "is_primary": false
                }
            ],
            "tax_rates": [],
            "add_infos": [
                {
                    "id": 7,
                    "parent_id": null,
                    "customer_type": 1,
                    "company_name": null,
                    "suffix": null,
                    "fax": null,
                    "website": null,
                    "other": null,
                    "exemption_id": null,
                    "exemption_details": null,
                    "opening_balance": null,
                    "as_of_balance": null,
                    "payment_method_id": null,
                    "delivery_method": "none",
                    "term_id": 4,
                    "is_tax_exempt": false,
                    "tax_number": null,
                    "gst_treatment": "Unregistered Business",
                    "customer_classification": "regular",
                    "sez_supply_mode": null,
                    "lut_reference": null,
                    "pets": false,
                    "resident_access": false,
                    "occupants": null,
                    "user_id": null
                }
            ],
            "tds_config": null,
            "renter_insurance": null
        }
    ],
    "first_page_url": "https://services.ap.mochatechnologies.com/quickbill/api/customers?page=1",
    "from": 1,
    "last_page": 6,
    "last_page_url": "https://services.ap.mochatechnologies.com/quickbill/api/customers?page=6",
    "links": [
        {
            "url": null,
            "label": "« Previous",
            "active": false
        },
        {
            "url": "https://services.ap.mochatechnologies.com/quickbill/api/customers?page=1",
            "label": "1",
            "active": true
        },
        {
            "url": "https://services.ap.mochatechnologies.com/quickbill/api/customers?page=2",
            "label": "2",
            "active": false
        },
        {
            "url": "https://services.ap.mochatechnologies.com/quickbill/api/customers?page=2",
            "label": "Next »",
            "active": false
        }
    ],
    "next_page_url": "https://services.ap.mochatechnologies.com/quickbill/api/customers?page=2",
    "path": "https://services.ap.mochatechnologies.com/quickbill/api/customers",
    "per_page": 1,
    "prev_page_url": null,
    "to": 1,
    "total": 6
}

Status codes

StatusMeaning
200The page is returned, even when data is empty.

Get a Customer

Read a single customer back by its id.

GET/customers/:idX-Tenant + API Key required

Returns one customer, with no paging envelope around it. This is the call to make before raising an invoice: it gives you the billing and shipping addresses to pass through, and the term_id that decides the due date.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe customer's id, as returned by POST /customers or found in the list. The example reads customer 5.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/customers/5' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

Mostly the same record you get inside data when you list customers — but not identically. Three differences matter if you write one piece of code to read both:

FieldIn the listHere
is_active1 — an integertrue — a boolean
The uuiduuiduser_id — same value, different field name
Timestampscreated_at, updated_at, deleted_atNot returned

Do not share one parser between the two

Because of the differences above, code that reads is_active as a boolean will misread the list, and code that reads uuid will find nothing here. Normalise both shapes into your own model as soon as you receive them.

Fields only this endpoint returns

FieldWhat it is
contact_personsAdditional people to deal with at the customer. Empty in the example.
custom_fieldsYour own fields on the contact. Empty in the example.
home_no, business_no, other_contactExtra phone numbers beyond phone_number and mobile_number.
tax_profileTax profile attached to the contact. Null in the example.

Both addresses come back with the same id

The shipping and billing entries are two different addresses, but both carry "id": "5" — the same value as the contact's own id, and a string rather than a number. Whatever that field is, it does not identify the address, so key your UI on type instead. This needs checking on the API side.
200 OK
{
    "id": 5,
    "user_id": "107cacec-53d3-407b-8bb2-cca2f9bb14ce",
    "title": null,
    "first_name": "David",
    "middle_name": "Kwan",
    "last_name": "Chen",
    "display_name": "David Kwan Chen",
    "name_on_checks": null,
    "email": "david.chen@example.com",
    "phone_number": "+918746145263",
    "mobile_number": null,
    "type": "customer",
    "shopify_id": null,
    "tax_number": null,
    "tax_profile": null,
    "notes": [],
    "attachments": [],
    "addresses": [
        {
            "id": "5",
            "administrative_area_level_1": "Bengkulu",
            "administrative_area_level_2": "Bengkulu City",
            "country": "ID",
            "formatted_address": "Bengkulu",
            "google_place_id": "ChIJeZLjNx6wNi4R6qaQ53a1eaA",
            "locality": "Bengkulu",
            "postal_code": null,
            "route": null,
            "street_number": null,
            "latitude": -3.7928451,
            "longitude": 102.2607641,
            "type": "shipping",
            "is_google_address": true,
            "address_line_1": null,
            "address_line_2": null,
            "is_primary": false
        },
        {
            "id": "5",
            "administrative_area_level_1": "Bengkulu",
            "administrative_area_level_2": "Bengkulu City",
            "country": "ID",
            "formatted_address": "Bengkulu",
            "google_place_id": "ChIJeZLjNx6wNi4R6qaQ53a1eaA",
            "locality": "Bengkulu",
            "postal_code": null,
            "route": null,
            "street_number": null,
            "latitude": -3.7928451,
            "longitude": 102.2607641,
            "type": "billing",
            "is_google_address": true,
            "address_line_1": null,
            "address_line_2": null,
            "is_primary": false
        }
    ],
    "tax_rates": [],
    "add_infos": [
        {
            "id": 7,
            "parent_id": null,
            "customer_type": 1,
            "company_name": null,
            "suffix": null,
            "fax": null,
            "website": null,
            "other": null,
            "exemption_id": null,
            "exemption_details": null,
            "opening_balance": null,
            "as_of_balance": null,
            "payment_method_id": null,
            "delivery_method": "none",
            "term_id": 4,
            "is_tax_exempt": false,
            "tax_number": null,
            "gst_treatment": "Unregistered Business",
            "customer_classification": "regular",
            "sez_supply_mode": null,
            "lut_reference": null,
            "pets": false,
            "resident_access": false,
            "occupants": null,
            "user_id": null
        }
    ],
    "open_balance": 600,
    "over_due": 600,
    "is_active": true,
    "custom_fields": [],
    "contact_persons": [],
    "home_no": null,
    "business_no": null,
    "other_contact": null,
    "tds_config": null,
    "association_due": 0
}

Status codes

StatusMeaning
200The contact is returned.
404No contact with that id on your account. Not verified — the response for an unknown id has not been supplied.

Get an Invoice Number

Take the next number in your sequence.

GET/invoices/get-invoice-numberX-Tenant + API Key required

Returns the next invoice number for your account. Call this before creating an invoice and use what it gives you — the numbering is the server's to keep, not yours to generate.

Parameters

None. No query string, no body — just the two authentication headers.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/invoices/get-invoice-number' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

One field, data, and it is the number itself:

200 OK
{
  "data": "INV-2025-001"
}

Where the value goes

Into invoice_no on the create body, and nowhere else. The server copies it into unique_no, reference_no and tracking_no for you — you will see all four come back on the response.

Never parse or predict the format

Three different formats have been seen from this API — INV-2025-001 here, INV-00016 in the create example, and INVOICE-387 on another account. The prefix, the padding and whether a year appears all vary. Treat the value as an opaque string: do not split it, do not increment it, and do not build the next one from the last one you saw.

Two things to confirm

  • Whether calling this reserves the number or only previews it. If it is a preview, two requests in parallel can both be handed the same number and the second invoice will collide — so until this is confirmed, take the number and create the invoice straight away rather than holding it.
  • What happens if you create an invoice with a number you did not get from here, or reuse one. Whether the API rejects the duplicate or accepts it has not been supplied.

Status codes

StatusMeaning
200The next number is returned.

Create an Invoice

Bill a customer for one or more products.

POST/invoicesX-Tenant + API Key required

Creates an invoice against an existing customer. Every line points at a product, so the customer and the products have to exist first. The server works out the totals — you do not send them.

Four things are required, and that is all

customer_id, invoice_date, invoice_no and at least one entry in lines. Everything else — due date, shipping date, the message, the whole addresses array — is optional.

Body parameters

FieldTypeRequiredDescription
customer_idintegerRequiredThe id returned when you created the customer via POST /customers.
invoice_datestringRequiredDate the invoice is raised, as YYYY-MM-DD.
invoice_nostringRequiredThe invoice number, up to 100 characters. Take it from GET /invoices/get-invoice-number rather than generating your own.
linesarrayRequiredThe products being billed. At least one entry. See the table below.
due_datestringOptionalDate payment is due, as YYYY-MM-DD.
shipping_datestringOptionalDate the goods ship, as YYYY-MM-DD.
message_on_invoicestring | nullOptionalA note to the customer, shown on the invoice. Send null or leave it out for none.
coupon_idintegerOptionalA coupon on the whole invoice. See Applying a coupon below.
addressesarrayOptionalBilling and shipping addresses. Optional as a whole — see the table below.

Do not send the totals

amount, balance and the per-line amount are not request fields — the server calculates them. Same for unique_no, reference_no and tracking_no, which are all filled in from invoice_no. Send only what is in the table above.

lines

One entry per thing being billed — a product, or an addon or charge. Send exactly one of product_id and addon_charge_id on each line.

FieldTypeRequiredDescription
product_idintegerOptionalThe id returned when you created the product via POST /products. Required unless the line has an addon_charge_id.
addon_charge_idintegerOptionalAn addon or charge from /addon-charges, billed on a line of its own. It has no price of its own, so give it one of its plans in pricing_plan_id or send a rate.
ratenumberOptionalPrice per unit, as a plain number, zero or more. Overrides the product's own price. Leave it out on a product line with no pricing_plan_id and the line takes the product's price. Required on a subscription plan line, and on an addon or charge line with no plan. Ignored on a one-time plan line, which takes the plan's price.
quantitynumberRequiredHow many units. Must be a whole number greater than zero — fractional quantities are rejected.
pricing_plan_idintegerOptionalBill this line on a pricing plan. A one-time plan (has_billing_period: false) sets the line's rate to its price. A subscription plan (has_billing_period: true) is only recorded on the line, and you send the rate.
coupon_idintegerOptionalA coupon on this line. It comes off the line's rate × quantity. See Applying a coupon below.

Billing a line on a pricing plan

Every line is one of three kinds. What you send for the price depends on which kind it is:

The line is onSendThe line's rate becomes
No planproduct_id, quantity, and rate if you want your ownThe rate you send — or, left out, the product's price. An addon or charge line has no price of its own, so it must send a rate.
A one-time plan (has_billing_period: false)product_id, quantity, pricing_plan_idThe plan's price. A rate sent on the same line is ignored.
A subscription plan (has_billing_period: true)product_id, quantity, pricing_plan_id, rateThe rate you send. A subscription plan has a price per billing period, not one price, so the plan does not price the line.

To find a plan's id and kind, read the product's plans with GET /products/:id/pricing-plans. has_billing_period tells you the kind, and price is a number for a one-time plan and one amount per billing period for a subscription plan.

Example: one line of each kind

Plan 5 is a one-time plan priced at 500. Plan 9 is a subscription plan.

JSON body
{
  "customer_id": 16909,
  "invoice_date": "2026-08-13",
  "invoice_no": "INV-00017",
  "lines": [
    { "product_id": 3204, "rate": 120, "quantity": 1 },
    { "product_id": 3205, "pricing_plan_id": 5, "quantity": 2 },
    { "product_id": 3206, "pricing_plan_id": 9, "rate": 799, "quantity": 1 }
  ]
}

The lines on the invoice that comes back:

200 OK (lines only)
"lines": [
  { "product_id": 3204, "pricing_plan_id": null, "quantity": 1, "rate": 120, "amount": 120 },
  { "product_id": 3205, "pricing_plan_id": 5, "quantity": 2, "rate": 500, "amount": 1000 },
  { "product_id": 3206, "pricing_plan_id": 9, "quantity": 1, "rate": 799, "amount": 799 }
],
"amount": 1919
  • Line 1 has no plan, so it keeps the rate of 120. Had it sent no rate, it would take the product's price.
  • Line 2 has no rate. It takes plan 5's price of 500, and the amount is 500 × 2 = 1000.
  • Line 3 keeps the rate of 799 you sent. Leave the rate out on a subscription plan line and the request returns 422:
422 Unprocessable
{
  "message": "The rate is required on a subscription plan line.",
  "errors": {
    "lines.2.rate": ["The rate is required on a subscription plan line."]
  }
}
  • A plan that cannot be found returns 422 on that line — "The selected pricing plan does not exist."
  • Whether the plan is attached to the line's item, and whether the item is active, are not checked.
  • The response carries pricing_plan_id and pricing_plan on every line, the plan in its current shape. A plan since removed from the product still shows; a plan that has been deleted comes back as pricing_plan: null.

Applying a coupon

Send a coupon's id (from GET /coupons) in one of two places. You send only the id; the discount is worked out for you.

WhereWhat it comes off
lines[].coupon_idThat line's rate × quantity (after a one-time plan has set the rate).
coupon_idThe whole invoice: what the lines come to after their own coupons, before tax.

A percent coupon takes that percent off. A flat coupon takes its value off, but never more than the amount it comes off.

Example: a line coupon and an invoice coupon

Coupon 7 is 10% off. Coupon 4 is 50 off.

JSON body
{
  "customer_id": 16909,
  "invoice_date": "2026-11-20",
  "invoice_no": "INV-00018",
  "coupon_id": 4,
  "lines": [
    { "product_id": 3205, "rate": 500, "quantity": 2, "coupon_id": 7 },
    { "product_id": 3204, "rate": 120, "quantity": 1 }
  ]
}
200 OK (totals and lines only)
"lines": [
  { "product_id": 3205, "quantity": 2, "rate": 500, "amount": 1000, "coupon_id": 7, "coupon_code": "SAVE10", "discount_amount": 100 },
  { "product_id": 3204, "quantity": 1, "rate": 120, "amount": 120, "coupon_id": null, "coupon_code": null, "discount_amount": null }
],
"coupon_id": 4,
"coupon_code": "FLAT50",
"discount_amount": 150,
"amount": 970,
"balance": 970
  • Line 1 comes to 500 × 2 = 1000. Coupon 7 takes 10% off it, so its discount_amount is 100.
  • The lines then come to 900 + 120 = 1020. Coupon 4 takes 50 off that.
  • The invoice's discount_amount is everything the coupons took off, 100 + 50 = 150, and amount is 1120 − 150 = 970. A line's amount stays before its coupon.

When a coupon is refused

The invoice is not created and the request returns 422 with the reason:

WhenMessage
No coupon has that idThe selected coupon does not exist.
The coupon is switched off, not started, expired or used upCoupon {code} is switched off. / has not started yet. / has expired. / has reached its redemption limit.
The coupon is only for certain customers, and this is not oneCoupon {code} is not available for this customer.
Its uses would go past the limit (each line and the invoice count as one use)Coupon {code} does not have enough uses left for this.
This customer has used it as many times as allowedThis customer has already used coupon {code} the maximum number of times.
422 Unprocessable
{
  "message": "Coupon SAVE10 has expired."
}

Plain numbers, not strings

rate and quantity are numbers — 120 and 1, not "120.00" or "1.0000000000". The response returns them as numbers too.

addresses

Optional. When you do send it, each entry is tagged billing or shipping — those are the only two values accepted. An entry comes in one of two shapes depending on where the address came from.

Typed by hand

FieldTypeRequiredDescription
typestringRequiredbilling or shipping.
addressstringOptionalStreet line — for example Plot 23, MG Road.
citystringOptionalCity name.
statestringOptionalState, spelled out — Maharashtra, not MH, in the example.
zip_codestringOptionalPostal or PIN code, as a string.
countrystringOptionalCountry, spelled out — India, not IN, in the example.

From Google Places

FieldTypeRequiredDescription
is_google_addressintegerRequired1 on a Google-sourced address. Note this is the integer 1, not true.
google_place_idstringOptionalThe Places identifier for the selected address.
addressstringOptionalThe address as Google returned it.
latitudestringOptionalLatitude, as a string — "19.0760", not a number.
longitudestringOptionalLongitude, as a string.

These are not the field names the customer endpoint uses

An invoice address takes address, city, state, zip_code and country. The same address on POST /customers takes formatted_address, locality, administrative_area_level_1, postal_code and a two-letter country. You cannot read an address off a customer and post it straight onto an invoice — map the fields across, and note the invoice wants full names (Maharashtra, India) where the customer wants codes (MH, IN).

is_google_address flips type between the two endpoints too

Here it is the integer 1. On POST /customers it is the boolean true. Latitude and longitude are strings here and numbers there. Convert rather than copying.

What the server works out for you

FieldHow it is derived
unique_no, reference_no, tracking_noAll three copied from invoice_no.
lines[].amountrate × quantity. In the example: 120 × 1 = 120, and 500 × 3 = 1500.
amountThe sum of every line amount — 120 + 1500 = 1620 — less what any coupons took off.
balanceEqual to amount, since nothing has been paid on a new invoice.
lines[].idEach line is assigned its own id.

Validation

FieldRuleMessage
customer_idrequired, integerThe customer field is required.
invoice_daterequired, dateThe invoice date field is required.
invoice_norequired, max 100 charactersThe invoice number field is required.
linesrequired, at least one entryThe line items field is required.
lines[].product_idrequired unless the line has an addon_charge_id, integer; not both, and not an addon or chargeEach line needs a product_id or an addon_charge_id. / Send product_id or addon_charge_id on a line, not both. / This is an addon or charge. Send it as addon_charge_id.
lines[].addon_charge_idoptional, an addon or charge that existsThe selected addon or charge does not exist.
lines[].rateoptional on a product line with no plan (the product's price is used); required on a subscription plan line and on an addon or charge line with no plan; numeric, zero or moreThe rate is required on a subscription plan line. / The rate is required on an addon or charge line without a pricing plan.
lines[].pricing_plan_idoptional, a plan that existsThe selected pricing plan does not exist.
lines[].coupon_idoptional, a coupon that existsThe selected coupon does not exist.
coupon_idoptional, a coupon that existsThe selected coupon does not exist.
lines[].quantityrequired, numeric, greater than zero, whole numberThe quantity must be a whole number.
message_on_invoiceoptional, string or null—
addresses[].typebilling or shipping, when an address is sent—

Quantity has to be whole

Fractional quantities are rejected. If you bill in halves or hours, put the fraction into rate and keep quantity at a whole number — 1 × 750 rather than 1.5 × 500.

The messages name the field differently to the payload

The validation text says “the customer field” for customer_id, “the line items field” for lines, “the product field” for product_id. These are written for people, not for your code — match on the field key you sent, not on the message text.

Example request

JSON body
{
  "customer_id": 16909,
  "invoice_date": "2026-08-13",
  "invoice_no": "INV-00016",
  "due_date": "2026-08-28",
  "shipping_date": "2026-08-20",
  "message_on_invoice": "Thanks for your business",
  "lines": [
    { "product_id": 3204, "rate": 120, "quantity": 1 },
    { "product_id": 3205, "rate": 500, "quantity": 3 }
  ],
  "addresses": [
    {
      "type": "billing",
      "address": "Plot 23, MG Road",
      "city": "Mumbai",
      "state": "Maharashtra",
      "zip_code": "400001",
      "country": "India"
    },
    {
      "type": "shipping",
      "is_google_address": 1,
      "google_place_id": "ChIJ...",
      "address": "...",
      "latitude": "19.0760",
      "longitude": "72.8777"
    }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/invoices' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "customer_id": 16909,
    "invoice_date": "2026-08-13",
    "invoice_no": "INV-00016",
    "due_date": "2026-08-28",
    "shipping_date": "2026-08-20",
    "message_on_invoice": "Thanks for your business",
    "lines": [
      { "product_id": 3204, "rate": 120, "quantity": 1 },
      { "product_id": 3205, "rate": 500, "quantity": 3 }
    ],
    "addresses": [
      {
        "type": "billing",
        "address": "Plot 23, MG Road",
        "city": "Mumbai",
        "state": "Maharashtra",
        "zip_code": "400001",
        "country": "India"
      },
      {
        "type": "shipping",
        "is_google_address": 1,
        "google_place_id": "ChIJ...",
        "address": "...",
        "latitude": "19.0760",
        "longitude": "72.8777"
      }
    ]
  }'

Example: the minimum

Four fields, one line, no addresses. Everything else is filled in by the server:

Minimum body
{
  "customer_id": 16909,
  "invoice_date": "2026-08-13",
  "invoice_no": "INV-00016",
  "lines": [
    { "product_id": 3204, "rate": 120, "quantity": 1 }
  ]
}

Example response

The created invoice, with the customer expanded inline and the totals calculated. Store the id — it is what you pass in paidAmount when you record a payment.

200 OK
{
  "id": 1185,
  "customer_id": 16909,
  "customer": {
    "id": 16909,
    "title": "Mr",
    "first_name": "Aarav",
    "last_name": "Mehta",
    "display_name": "Aarav Mehta",
    "email": "aarav.mehta@example.com",
    "phone_number": "+91-9876543210",
    "addresses": [ { "...": "as stored" } ],
    "add_infos": [ { "id": 88, "company_name": "Mehta Traders" } ],
    "open_balance": 1620,
    "over_due": 0,
    "is_active": true
  },
  "invoice_date": "2026-08-13",
  "due_date": "2026-08-28",
  "shipping_date": "2026-08-20",
  "unique_no": "INV-00016",
  "reference_no": "INV-00016",
  "tracking_no": "INV-00016",
  "message_on_invoice": "Thanks for your business",
  "status": "open",
  "payment_state": null,
  "overdue_days": null,
  "lines": [
    { "id": 1492, "product_id": 3204, "addon_charge_id": null, "text": "Setup", "quantity": 1, "rate": 120, "amount": 120, "pricing_plan_id": null, "pricing_plan": null, "coupon_id": null, "coupon_code": null, "discount_amount": null },
    { "id": 1493, "product_id": 3205, "addon_charge_id": null, "text": "Monthly service", "quantity": 3, "rate": 500, "amount": 1500, "pricing_plan_id": null, "pricing_plan": null, "coupon_id": null, "coupon_code": null, "discount_amount": null }
  ],
  "addresses": [ { "...": "as stored" } ],
  "coupon_id": null,
  "coupon_code": null,
  "discount_amount": 0,
  "amount": 1620,
  "balance": 1620
}

Reading the response

FieldWhat it is
idThe invoice id — 1185 here. Use it to read the invoice back, and to apply payments to it.
customerThe customer expanded inline, with its addresses and add_infos, so an invoice screen needs no second call.
customer.open_balanceAlready includes this invoice — 1620 in the example, matching its balance.
amount / balanceBoth 1620 on a fresh invoice. balance drops as payments are applied.
linesYour lines with an id and the calculated amount added. rate and quantity come back as you sent them, except a line on a plan, whose rate is the plan's price.
lines[].product_id / lines[].addon_charge_idWhat the line bills. One is set and the other is null — product_id for a product, addon_charge_id for an addon or charge. Every invoice endpoint reports lines this way.
lines[].pricing_plan_id / lines[].pricing_planThe line's plan, in the same shape as Get a Pricing Plan. pricing_plan is null if the plan has been deleted.
lines[].textThe line's description.
lines[].coupon_id / lines[].coupon_code / lines[].discount_amountThe line's coupon, its code, and what it took off. null when the line has no coupon.
coupon_id / coupon_code / discount_amountThe invoice's coupon and its code, and everything the coupons took off — line coupons and the invoice coupon together. amount is already less this.
statusThe invoice's status as stored — open on a new invoice.
payment_state / overdue_daysnull here. They are worked out only when an invoice is read back — see GET /invoices/:id.
addressesThe addresses as stored.

The embedded customer balance is live here

customer.open_balance on this response already reflects the invoice you just created. That is worth knowing because the same field comes back null inside GET /invoices — so trust it here, not there.

Status codes

StatusMeaning
200Invoice created. The record is returned.
404The customer or one of the products on this invoice was not found.
422Validation failed, a line's plan cannot be found, a subscription plan line has no rate, a coupon cannot be used, or the invoice could not be created with the details provided.

404 covers two different mistakes

A bad customer_id and a bad product_id both return “The customer or one of the products on this invoice was not found”, and the message does not say which. With several lines you will not be told which product is the problem either — check the ids yourself before blaming the invoice.

Update an Invoice

Replace an invoice — only while nothing has been paid on it.

PUT/invoices/:idX-Tenant + API Key required

Replaces an invoice. Send the whole invoice as it should end up, not only the fields that changed.

A paid invoice cannot be edited at all

An invoice is editable only while nothing has been received against it. The moment its balance drops below its amount — by any amount at all — this endpoint refuses. See the table below.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe invoice's id, as returned by POST /invoices. It travels into the body for you — you do not send it twice.

Body parameters

FieldTypeRequiredDescription
customer_idintegerRequiredThe customer the invoice is issued to.
invoice_datedateRequiredThe date on the invoice.
invoice_nostringRequiredThe customer-facing number. Max 100.
message_on_invoicestringOptionalFree text printed on the invoice.
linesarrayRequiredAt least one line. See the table below.
coupon_idintegerOptionalA coupon on the whole invoice, as on create. Leave it out to take the coupon off.
addressesarrayOptionalEach entry needs a type — billing, location, shipping or ship_via.

lines[]

FieldTypeRequiredDescription
product_idintegerRequiredThe product this line bills for. Required unless the line has an addon_charge_id.
addon_charge_idintegerOptionalThe addon or charge this line bills for, as on create. Send it back as it came in the invoice's lines.
ratenumberOptionalPrice per unit. Cannot be negative. Required on every line, and kept as sent, unless use_plan_price is true.
quantityintegerRequiredA whole number, greater than zero.
pricing_plan_idintegerOptionalThe plan the line is on — a one-time plan or a subscription plan. On an update the plan does not change the rate by itself. The plan is not checked against the item, and the item's active status is not checked.
use_plan_pricebooleanOptionalOne-time plans only. true sets the line's rate to the plan's current price. Leave it out and the rate you send is kept. On a subscription plan it returns 422.
coupon_idintegerOptionalA coupon on this line, as on create. Leave it out to take the coupon off the line.

Coupons on an update

Send every coupon you want to keep, the same as the lines — a coupon_id left out is taken off. A coupon already on the invoice is not counted again, so re-sending it does not use up another redemption. The discount is worked out again on the line's new amount.

Plan prices on an update

A saved line keeps the rate it was billed at, even after its plan's price changes. So on an update every line sends its rate, and the plan's new price is used only when you ask for it.

Say plan 5 was 500 when the invoice was made and now costs 600. Plan 9 is a subscription plan:

JSON body (lines only)
"lines": [
  { "product_id": 3205, "pricing_plan_id": 5, "rate": 500, "quantity": 2 },
  { "product_id": 3205, "pricing_plan_id": 5, "use_plan_price": true, "quantity": 1 },
  { "product_id": 3206, "pricing_plan_id": 9, "rate": 799, "quantity": 1 }
]
  • Line 1 sends rate: 500, so it stays at 500.
  • Line 2 sends use_plan_price: true and no rate, so it takes plan 5's current price of 600.
  • Line 3 is on a subscription plan, so it always sends its rate. Sending use_plan_price: true on it returns 422:
422 Unprocessable
{
  "message": "A subscription plan has no single price to use. Send the rate instead.",
  "errors": {
    "lines.2.use_plan_price": ["A subscription plan has no single price to use. Send the rate instead."]
  }
}

Showing the price change to your user

Each line on the invoice response carries its pricing_plan. When a one-time plan's price differs from the line's rate, the plan's price has changed since the line was saved. Offer the new price, and send use_plan_price: true only if your user picks it.

What the server fills in

FieldHow it is worked out
unique_no, tracking_no, reference_noAll three from invoice_no, if you did not send them.
lines[].amountrate × quantity, per line.
amountThe total of every line.

The lines you send become the whole invoice

lines is a full replacement, not an append. A line you leave out is removed from the invoice — so read the invoice first, and send back every line you want to keep.

When an edit is allowed

amountbalanceEditable?
500500Yes — nothing has been received.
500499.99No
5000No
422 Unprocessable
{
  "message": "This invoice cannot be edited because a payment has already been received against it."
}

Check before you offer an edit

Read the invoice with GET /invoices/:id and compare balance against amount. Equal means editable; anything less means grey the button out rather than letting your user fill in a form that will be refused.

Example request

JSON body
{
  "customer_id": 1125,
  "invoice_date": "2026-09-08",
  "invoice_no": "INVOICE-400",
  "message_on_invoice": "Thanks for your business.",
  "lines": [
    { "product_id": 90, "rate": 500, "quantity": 2 }
  ],
  "addresses": [
    { "type": "billing", "locality": "Mumbai" }
  ]
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/invoices/1185' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "customer_id": 1125,
    "invoice_date": "2026-09-08",
    "invoice_no": "INVOICE-400",
    "message_on_invoice": "Thanks for your business.",
    "lines": [
      { "product_id": 90, "rate": 500, "quantity": 2 }
    ],
    "addresses": [
      { "type": "billing", "locality": "Mumbai" }
    ]
  }'

Example response

The whole invoice, in the same shape create returns.

200 OK
{
  "id": 1185,
  "customer_id": 16909,
  "customer": {
    "id": 16909,
    "title": "Mr",
    "first_name": "Aarav",
    "last_name": "Mehta",
    "display_name": "Aarav Mehta",
    "email": "aarav.mehta@example.com",
    "phone_number": "+91-9876543210",
    "addresses": [ { "...": "as stored" } ],
    "add_infos": [ { "id": 88, "company_name": "Mehta Traders" } ],
    "open_balance": 1620,
    "over_due": 0,
    "is_active": true
  },
  "invoice_date": "2026-08-13",
  "due_date": "2026-08-28",
  "shipping_date": "2026-08-20",
  "unique_no": "INV-00016",
  "reference_no": "INV-00016",
  "tracking_no": "INV-00016",
  "message_on_invoice": "Thanks for your business",
  "status": "open",
  "payment_state": null,
  "overdue_days": null,
  "lines": [
    { "id": 1492, "product_id": 3204, "addon_charge_id": null, "text": "Setup", "quantity": 1, "rate": 120, "amount": 120, "pricing_plan_id": null, "pricing_plan": null, "coupon_id": null, "coupon_code": null, "discount_amount": null },
    { "id": 1493, "product_id": 3205, "addon_charge_id": null, "text": "Monthly service", "quantity": 3, "rate": 500, "amount": 1500, "pricing_plan_id": null, "pricing_plan": null, "coupon_id": null, "coupon_code": null, "discount_amount": null }
  ],
  "addresses": [ { "...": "as stored" } ],
  "coupon_id": null,
  "coupon_code": null,
  "discount_amount": 0,
  "amount": 1620,
  "balance": 1620
}

Status codes

StatusMeaning
200The invoice is updated and returned.
404The invoice, the customer, or one of the products was not found.
422Validation failed, a line's plan cannot be found, use_plan_price is sent on a subscription plan line, a coupon cannot be used, or a payment has already been received against the invoice.

404 covers three different things

The invoice, the customer you named, or any product on a line. The message does not say which, so validate the ids you are about to send rather than working backwards from the status.

List Invoices

Read your invoices back, a page at a time.

GET/invoicesX-Tenant + API Key required

Returns your invoices in pages. Each entry is the full invoice record — the customer expanded inline, the lines with their amounts, and the totals — so an invoice list screen needs no extra call per row.

Query parameters

FieldTypeRequiredDescription
pageintegerRequiredWhich page to return, starting at 1.
page_lengthintegerRequiredHow many invoices per page. Comes back as meta.per_page.
searchstringRequiredA JSON object, sent as a string, holding your filters. Send {} for no filter, and URL-encode it. Which keys it accepts has not been supplied.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/invoices' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=1' \
  --data-urlencode 'search={}'

Example response

Two keys: the invoices in data, and the paging in meta — the same envelope GET /products uses. Each entry is the same record POST /invoices and GET /invoices/:id return, so one invoice model in your code covers all three.

meta

FieldWhat it is
totalHow many invoices exist in total, across every page — 8 in the example.
current_pageThe page you are on, echoing the page you asked for.
last_pageThe highest page number available. Stop paging when current_page reaches it.
per_pagePage size in effect, echoing page_length.
from / toPosition of the first and last item on this page within the full set.

No paging URLs to worry about

Nothing in this response points anywhere — no next_page_url, links or path. Page with current_page against last_page.

Fields worth knowing

FieldWhat it tells you
amount / balanceWhat the invoice is for, and what is still owed. Equal on an invoice nothing has been paid against.
customerThe customer expanded inline, so a list screen needs no extra call per row.
linesThe lines in full, each with its id and calculated amount.
lines[].pricing_plan_idThe line's plan id only. The plan itself is not included in the list.
status / payment_state / overdue_daysThe invoice's status, where it stands on payment, and how many days overdue it is.
coupon_id, coupon_code, discount_amountAlways null here, on the invoice and on its lines — the list does not carry coupons. Read the invoice with GET /invoices/:id to see them.
unique_no, reference_no, tracking_noAll three carry the invoice number.

Whether anything has been paid

Read payment_state — open, partially_paid, overdue, paid, payment_processing, payment_failed, refunded, partially_refunded, written_off or voided.
200 OK (data trimmed to one of eight invoices)
{
  "data": [
    {
      "id": 1185,
      "customer_id": 16909,
      "customer": { "...": "as stored" },
      "invoice_date": "2026-08-13",
      "due_date": "2026-08-28",
      "shipping_date": "2026-08-20",
      "unique_no": "INV-00016",
      "reference_no": "INV-00016",
      "tracking_no": "INV-00016",
      "message_on_invoice": "Thanks for your business",
      "status": "open",
      "payment_state": "open",
      "overdue_days": 0,
      "lines": [
        { "id": 1492, "product_id": 3204, "text": "Setup", "quantity": 1, "rate": 120, "amount": 120, "coupon_id": null, "coupon_code": null, "discount_amount": null },
        { "id": 1493, "product_id": 3205, "text": "Monthly service", "quantity": 3, "rate": 500, "amount": 1500, "coupon_id": null, "coupon_code": null, "discount_amount": null }
      ],
      "addresses": [ { "...": "as stored" } ],
      "amount": 1620,
      "balance": 1620
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "last_page": 1,
    "total": 8,
    "from": 1,
    "to": 8
  }
}

Status codes

StatusMeaning
200The page is returned, even when data is empty.

Get an Invoice

Read one invoice back in full.

GET/invoices/:idX-Tenant + API Key required

Returns one invoice — the same record POST /invoices hands back when it creates one, with the customer expanded inline, the lines with their calculated amounts, and the addresses as stored. This is the call for an invoice detail screen, and the way to check a balance after a payment.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe invoice's id, as returned by POST /invoices or found in the list. The example reads invoice 1185.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/invoices/7' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

Identical in shape to the create response, so one invoice model in your code covers both calls:

200 OK
{
  "id": 1185,
  "customer_id": 16909,
  "customer": {
    "id": 16909,
    "title": "Mr",
    "first_name": "Aarav",
    "last_name": "Mehta",
    "display_name": "Aarav Mehta",
    "email": "aarav.mehta@example.com",
    "phone_number": "+91-9876543210",
    "addresses": [ { "...": "as stored" } ],
    "add_infos": [ { "id": 88, "company_name": "Mehta Traders" } ],
    "open_balance": 1620,
    "over_due": 0,
    "is_active": true
  },
  "invoice_date": "2026-08-13",
  "due_date": "2026-08-28",
  "shipping_date": "2026-08-20",
  "unique_no": "INV-00016",
  "reference_no": "INV-00016",
  "tracking_no": "INV-00016",
  "message_on_invoice": "Thanks for your business",
  "status": "open",
  "payment_state": null,
  "overdue_days": null,
  "lines": [
    { "id": 1492, "product_id": 3204, "addon_charge_id": null, "text": "Setup", "quantity": 1, "rate": 120, "amount": 120, "pricing_plan_id": null, "pricing_plan": null, "coupon_id": null, "coupon_code": null, "discount_amount": null },
    { "id": 1493, "product_id": 3205, "addon_charge_id": null, "text": "Monthly service", "quantity": 3, "rate": 500, "amount": 1500, "pricing_plan_id": null, "pricing_plan": null, "coupon_id": null, "coupon_code": null, "discount_amount": null }
  ],
  "addresses": [ { "...": "as stored" } ],
  "coupon_id": null,
  "coupon_code": null,
  "discount_amount": 0,
  "amount": 1620,
  "balance": 1620
}

Reading the response

FieldWhat it is
balanceWhat is still owed. This is the field to read after recording a payment — it is the only place the new figure appears.
amountThe invoice total. Compare it against balance to tell whether anything has been paid.
customerThe customer expanded inline, with its addresses, add_infos and open_balance — no second call needed.
linesEach line with its own id, the product_id, its text, quantity, rate, the calculated amount, and its coupon if it has one.
status / payment_state / overdue_daysThe invoice's status, where it stands on payment (open, partially_paid, overdue, paid, payment_processing, payment_failed, refunded, partially_refunded, written_off or voided), and how many days overdue it is.
coupon_id / coupon_code / discount_amountThe invoice's coupon, and everything the coupons took off.
addressesThe addresses as stored on the invoice. The list endpoint returns this empty, so this is where to read them.
unique_no, reference_no, tracking_noAll three carry the invoice number. There is no separate invoice_no on the response.

This is how you check whether an invoice is settled

Recording a payment does not return the new balance, so read the invoice back with this call afterwards. payment_state says it straight out — paid, partially_paid, open and so on — and balance is what is still owed.

message_on_invoice can contain HTML

The example shows plain text, but the field holds whatever was written into it — invoices created through the web app come back with markup (<p> tags and the like). If you render it, sanitise it first and never inject it straight into the DOM; if you only need text, strip the tags rather than escaping the whole string.

Status codes

StatusMeaning
200The invoice is returned.
404No invoice with that id — "Invoice not found".

Payment Methods

How the money was paid — the ids a payment can use.

GET/payment-methodsX-Tenant + API Key required

Returns the ways a payment can be taken. Call it to populate a “how did they pay” picker, then send the chosen id as payment_method on POST /payments.

Query parameters

None. Every method comes back in one call — no page, no search, and no meta block.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/payment-methods' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "data": [
    { "id": 1, "name": "Cash" },
    { "id": 2, "name": "Cheque" },
    { "id": 3, "name": "Credit Card" }
  ]
}

An id and a name, nothing more

id is what you send, name is what you show. There is no flag telling you which method needs extra details — a cheque number, a card reference — so collect that on your side if you need it.

Do not hard-code the ids

The list is per tenant, so 1 meaning Cash in your own tenant is no guarantee it means Cash in your customer's. Read it at runtime.

Status codes

StatusMeaning
200The methods are returned.
500Unexpected error.

Get a Payment Number

Take the next reference in your payment sequence.

GET/payments/get-next-payment-numberX-Tenant + API Key required

Returns the next payment reference for your account. Call this before recording a payment and send what it gives you as reference_no.

Parameters

None. No query string, no body — just the two authentication headers.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/payments/get-next-payment-number' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

One field, data, and it is the reference itself — the same shape as the invoice number:

200 OK
{
  "data": "PMT-00417"
}

Never parse or predict the format

Treat the value as an opaque string. Do not split the PMT- prefix off, do not increment the digits, and do not build the next reference from the last one you saw — the format varies between accounts, exactly as invoice numbers do.

One thing to confirm

Whether calling this reserves the reference or only previews it. If it is a preview, two requests in parallel can both be handed PMT-00417 — so take the reference and record the payment straight away rather than holding it.

Status codes

StatusMeaning
200The next reference is returned.

Receive a Payment

Record a payment against a customer's open invoices.

POST/paymentsX-Tenant + API Key required

Records money received from a customer and applies it to the invoices you name. One call can settle several invoices at once — list each of them in paidAmount with the amount going to it. The invoice has to exist first, so create it with POST /invoices before you call this.

Body parameters

All six are required.

FieldTypeRequiredDescription
customer_idintegerRequiredThe customer the money came from — the id from POST /customers. Every invoice in paidAmount must belong to this customer.
account_idintegerRequiredId of the account the money is deposited into. Take it from GET /bank-accounts and send the one your user picked.
payment_methodintegerRequiredHow the money was paid. Take the id from GET /payment-methods and send the one your user picked.
payment_datestringRequiredDate the money was received, as YYYY-MM-DD.
reference_nostringRequiredThe payment's own reference — PMT-00004 in the example. Take it from GET /payments/get-next-payment-number rather than generating it yourself.
paidAmountarrayRequiredWhich invoices the money is applied to, and how much goes to each. See the table below.

paidAmount is camelCase

Every other field on this endpoint is snake_case, but this one is paidAmount. Sending paid_amount will not work.

payment_method is an integer

Send 1, not "1". The ids and what each one means come from GET /payment-methods.

Two lookups before you record a payment

account_id comes from GET /bank-accounts and payment_method from GET /payment-methods. Both sets of ids differ per tenant, so read them at runtime rather than hard-coding a value that happens to work in your own.

paidAmount

One entry per invoice the payment is applied to.

FieldTypeRequiredDescription
idintegerRequiredThe invoice's id, as returned by POST /invoices. Invoice 8 in the example is the one that comes back as INV-00008.
paymentstringRequiredAmount applied to that invoice, as a string with two decimal places. Must be greater than zero.

Two decimal places, as a string, on the way in

"1500.00" — a string here, even though every money value in a response comes back as a plain number. Send it as shown.

Partial payments work

Send less than the outstanding balance and the rest stays owed. Read the invoice back with GET /invoices/:id afterwards and its balance will show the remainder. Record the rest later against the same invoice id.

Example request

JSON body
{
  "customer_id": 5,
  "account_id": 21,
  "payment_method": 1,
  "payment_date": "2026-08-10",
  "reference_no": "PMT-00004",
  "paidAmount": [
    { "id": 8, "payment": "1500.00" }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/payments' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "customer_id": 5,
    "account_id": 21,
    "payment_method": 1,
    "payment_date": "2026-08-10",
    "reference_no": "PMT-00004",
    "paidAmount": [
      { "id": 8, "payment": "1500.00" }
    ]
  }'

Example response

Unlike the other endpoints on this page, this one does not return the record it created — just two fields:

FieldWhat it is
payment_idId of the payment record that was created. Store it against your own transaction — this is the only place you get it, and it is what you pass to GET /payments/:id.
invoice_numbersThe customer-facing numbers of the invoices the payment was applied to — INV-00008 here.
201 Created
{
  "invoice_numbers": "INV-00008",
  "payment_id": 6
}

201, not 200

This is the only endpoint on the page that answers with 201. Creating a product, a customer or an invoice all return 200. If your client treats anything other than 200 as a failure, a payment that was recorded perfectly well will look like an error.

There is no success flag to check

The body carries no success field, so the status code is all you have. Treat 201 as recorded and anything else as not recorded.

Re-fetch the invoice to see the new balance

The response does not include the amount applied or the remaining balance. If you need to know whether the invoice is now settled, read it back with GET /invoices/:id after the call and check its balance.

invoice_numbers is a single string

The field is plural, but the example only ever paid one invoice, so it came back as one number. How several are joined when paidAmount has more than one entry has not been confirmed — do not parse it until it has.

Validation errors

A 422 carries a message and an errors object keyed by field:

422 Unprocessable
{
  "message": "The invoice field is required.",
  "errors": {
    "paidAmount.0.id": ["The invoice field is required."]
  }
}

The error keys are dotted paths into the array

A problem inside paidAmount is reported as paidAmount.0.id — the array index is part of the key. To highlight the right row in a form, split the key on dots rather than looking for a plain field name. And as elsewhere, the message text names the field for people (“the invoice field”), not by its key.

Status codes

StatusMeaning
201Payment recorded.
422Validation failed — a required field is missing, or a value is not acceptable.
500Unexpected error.

Update a Payment

Replace a recorded payment and what it settles.

PUT/payments/:idX-Tenant + API Key required

Replaces a payment. Send the whole payment as it should end up, not only the fields that changed.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe payment_id that POST /payments returned. It travels into the body for you — you do not send it twice.

Body parameters

FieldTypeRequiredDescription
customer_idintegerRequiredThe customer the money came from.
account_idintegerRequiredThe account the money is deposited into — from GET /bank-accounts.
payment_methodintegerRequiredHow the money was paid — from GET /payment-methods.
payment_datedateRequiredThe date the money was received.
reference_nostringRequiredThe payment's own reference. Max 100.
paidAmountarrayRequiredAt least one entry. See the table below.

paidAmount[]

FieldTypeRequiredDescription
idintegerRequiredThe invoice's id.
paymentnumberRequiredThe amount applied to it. Greater than zero.

Fields that pass straight through

memo, paidCredit, send_email and attachments are forwarded exactly as you send them.

What the server fills in

FieldWhat happens to it
payment_methodThe id you send is turned into its text form.
paidAmount[].typeSet to "invoice" on every row if you did not send it.

The rows you send become everything this payment settles

paidAmount is a full replacement. Leave a row out and that invoice is no longer settled by this payment — its balance goes back up. Read the payment first and send back every row you want to keep.

Example request

JSON body
{
  "customer_id": 1125,
  "account_id": 24,
  "payment_method": 2,
  "payment_date": "2026-09-08",
  "reference_no": "PMT-00467",
  "memo": "",
  "paidAmount": [
    { "id": 1048, "payment": "80.00" }
  ],
  "paidCredit": [],
  "send_email": false,
  "attachments": []
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/payments/6' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "customer_id": 1125,
    "account_id": 24,
    "payment_method": 2,
    "payment_date": "2026-09-08",
    "reference_no": "PMT-00467",
    "paidAmount": [
      { "id": 1048, "payment": "80.00" }
    ]
  }'

Example response

200 OK
{
  "invoice_numbers": "INVOICE-400"
}

No payment_id here, unlike create

The response carries only invoice_numbers — the invoices this payment now settles. POST /payments returns payment_id because you do not have it yet; here you already do, it is in the URL.

Errors

422 Unprocessable
{
  "message": "The payment date field is required.",
  "errors": { "payment_date": ["The payment date field is required."] }
}
404 Not Found
{
  "message": "Payment not found"
}

Status codes

StatusMeaning
200The payment is updated.
404No payment with that id.
422Validation failed.

List Payments

Read recorded payments back, a page at a time.

GET/paymentsX-Tenant + API Key required

Returns the payments recorded on your account, in pages. Each entry is a summary row — enough for a payments list screen, with the customer flattened onto it so no extra call is needed per row.

Query parameters

All optional. Send none of them and you get the first ten payments, unfiltered.

ParameterTypeDefault
pageinteger1
page_lengthinteger10
searchstring (JSON){}

URL-encode search when you do send it

The value is a JSON object sent as a string, so its braces and quotes have to be encoded — --data-urlencode in cURL. Which keys it accepts has not been supplied.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/payments' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=10' \
  --data-urlencode 'search={"type":"payment"}'

Example response

The payments in data, the paging in meta — the same envelope the product and invoice lists use.

200 OK
{
  "data": [
    {
      "id": 6,
      "type": "payment",
      "amount": -1500,
      "date": "2026-08-10",
      "no": "PMT-00004",
      "customer_id": 5,
      "customer_name": "David Kwan Chen",
      "email": "david.chen@example.com",
      "due_date": null,
      "balance": null
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "last_page": 1,
    "total": 1,
    "from": null,
    "to": null
  }
}

Fields on a payment row

FieldWhat it is
idThe payment id. Use it to read the payment back by id.
typeAlways "payment" on this endpoint.
amountWhat was received — negative, because a payment reduces what the customer owes. See the warning below.
dateThe date the money was received.
noThe payment reference — PMT-00004. Note the field is called no here, not reference_no.
customer_id, customer_name, emailWho the money came from, flattened onto the row.
due_date / balanceAlways null. They do not apply to a payment — the row shape is shared with other kinds of sales transaction.

amount is negative

A payment of 1500 comes back as -1500, because in the sales ledger it reduces the receivable. Take the absolute value before you show it, or your users will see a minus sign against money they received.

A plain number, not a string

The amount is returned as -1500, not "-1500.0000000000". You do not have to parse a decimal string.

meta.from and meta.to are always null

The paging block keeps the same five-plus-two shape as the product and customer lists so one paging helper works everywhere, but from and to are never filled in here. Use current_page, last_page and total; do not compute a “showing 1–10 of 50” label from from and to on this endpoint.

You cannot tell which invoice a payment settled

There is no invoice_id on the row, and a single payment can cover several invoices anyway. Go the other way round: read the invoice with GET /invoices/:id and check its balance, or read the payment by id.

No payments yet

An empty account is a 200 with an empty data array — not an error, and not a 404:

200 OK — empty
{
  "data": [],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "last_page": 1,
    "total": 0,
    "from": null,
    "to": null
  }
}

Errors

A single message, whatever went wrong:

Error
{
  "message": "Failed to fetch payments"
}

Status codes

StatusMeaning
200The page is returned, even when data is empty.
500Unexpected error.

Get a Payment

Read one payment back, with what it was applied to.

GET/payments/:idX-Tenant + API Key required

Returns one payment. The response is not a single record — it is three objects at the top level, each answering a different question about the same payment.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe payment_id that POST /payments returned. The example reads payment 520. This is not the transaction id — in the example the transaction is 1738, and that value will not work here.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/payments/520' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

The three objects

KeyWhat it holdsUse it for
paymentThe payment record — amount, date, method, deposit account, reference, and one allocation row per invoice.Everything about the payment itself.
receivePayment.invoicesThe invoices this payment settled, each in full.Showing what was paid, and each invoice's remaining balance.
transactionThe ledger entry the payment produced.Tying the payment to your books.

The invoices are the same shape as everywhere else

Each entry in receivePayment.invoices is exactly what GET /invoices/:id returns — same fields, same lines, same addresses. Your existing invoice model reads them without changes. In the example the invoice comes back with balance: 0, so this payment settled it in full.

payment

FieldWhat it is
payment_amountThe total received — a positive number, unlike the negative amount the list endpoint returns.
payment_method / account_idThe two values you sent when recording it.
reference_noThe PMT- reference. Repeated on every allocation row.
invoice_receive_paymentOne row per invoice the payment was applied to — invoice_id and the amount that went to it.

Read the allocations from payment, not from the invoices

payment.invoice_receive_payment is what tells you how much of this payment went to which invoice. The invoices under receivePayment show their own totals and balances, which is not the same thing — an invoice with a 29.99 balance cleared could have been settled by two payments.

transaction

FieldWhat it is
idThe ledger transaction's own id — 1738 here. Not the payment id.
transaction_type_idThe payment id — 520 here. Despite the name, this is the link back to the payment.
transaction_refThe PMT- reference again.
totalThe payment amount, positive.
contact_idThe customer. Note it is contact_id here and customer_id on the payment object.

Three ids in one response, and the names do not help

payment.id is 520, transaction.id is 1738, and transaction.transaction_type_id is 520 again — the payment id under a name that reads like a type. Only payment.id works in this endpoint's URL.

Money comes back as numbers

Every amount here is a plain number — 29.99, not "29.9900000000". The underlying store keeps ten-decimal strings and this endpoint converts them, so you do not have to parse anything.

invoice_receive_payment is spelled correctly here

The field is invoice_receive_payment. The underlying service misspells it (paymnet); this API corrects it before returning. Use the correct spelling — and if you have code written against the misspelling from an earlier version, it will read undefined now.
200 OK
{
  "receivePayment": {
    "invoices": [
      {
        "id": 995,
        "customer_id": 1108,
        "customer": { "...": "customer object" },
        "invoice_date": "2026-07-01",
        "due_date": "2026-07-16",
        "shipping_date": null,
        "unique_no": "INV-00995",
        "reference_no": "INV-00995",
        "tracking_no": "INV-00995",
        "message_on_invoice": null,
        "lines": [
          { "id": 3001, "product_id": 44, "addon_charge_id": null, "quantity": 1, "rate": 29.99, "amount": 29.99 }
        ],
        "addresses": [ { "...": "as stored" } ],
        "amount": 29.99,
        "balance": 0
      }
    ]
  },
  "transaction": {
    "id": 1738,
    "contact_id": 1108,
    "date": "2026-07-09",
    "transaction_type": "payment",
    "balance": 0,
    "due_date": null,
    "transaction_type_id": 520,
    "transaction_ref": "PMT-00462",
    "payee": null,
    "total": 29.99
  },
  "payment": {
    "id": 520,
    "customer_id": 1108,
    "payment_amount": 29.99,
    "payment_date": "2026-07-09",
    "payment_method": 4,
    "account_id": 29,
    "reference_no": "PMT-00462",
    "invoice_receive_payment": [
      {
        "id": 520,
        "payment_id": 520,
        "payment": 29.99,
        "invoice_id": 995,
        "payment_date": "2026-07-09",
        "payment_method_id": 4,
        "account_id": 29,
        "reference_no": "PMT-00462"
      }
    ]
  }
}

Errors

404 Not Found
{
  "message": "Payment not found"
}

Status codes

StatusMeaning
200The payment is returned.
404No payment with that id.
500Unexpected error.

Errors look the same on all three payment endpoints

Every failure returns a single message, with errors added on a 422. Only the text differs — Payment not found here, Failed to fetch payments on the list. Branch on the status code, not the wording.

Create a Pricing Component

Add a fixed pricing component.

POST/pricing-componentsX-Tenant + API Key required

Creates a pricing component. A new component is switched on.

A discount is a coupon

A component is always a fixed amount. To take something off a price, create a coupon instead.

Body parameters

FieldTypeRequiredDescription
component_namestringRequiredmax 255
component_codestringRequiredmax 50, must be unique
calculation_typestringOptionalOnly fixed, which is also the default.
has_billing_periodbooleanOptionalDefaults to false. See below.
base_amountnumberOptionalRequired when has_billing_period is false. min 0.
billing_amountsarrayOptionalRequired when has_billing_period is true. One monthly row and one yearly row, each with an amount of 0 or more.

How a component is priced: has_billing_period

has_billing_periodPrice sent in
false (the default)One price, in base_amount.
trueSeparate monthly and yearly prices, in billing_amounts. Both are required.
JSON body — monthly and yearly prices
{
  "component_name": "Platform Fee",
  "component_code": "PLAT",
  "calculation_type": "fixed",
  "has_billing_period": true,
  "billing_amounts": [
    { "billing_period": "monthly", "amount": 500 },
    { "billing_period": "yearly", "amount": 5000 }
  ]
}

Example request

JSON body
{
  "component_name": "Setup Fee",
  "component_code": "SETUP",
  "base_amount": 2500
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-components' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "component_name": "Setup Fee",
    "component_code": "SETUP",
    "base_amount": 2500
  }'

Example response

Each component returns exactly one of base_amount or billing_amounts, depending on how it is priced.

201 Created — one price
{
  "id": 10,
  "component_code": "SETUP",
  "component_name": "Setup Fee",
  "calculation_type": "fixed",
  "has_billing_period": false,
  "is_active": true,
  "pricing_plans": [],
  "base_amount": 2500
}
201 Created — monthly and yearly prices
{
  "id": 6,
  "component_code": "PLAT",
  "component_name": "Platform Fee",
  "calculation_type": "fixed",
  "has_billing_period": true,
  "is_active": true,
  "pricing_plans": [],
  "billing_amounts": [
    { "billing_period": "monthly", "amount": 500 },
    { "billing_period": "yearly", "amount": 5000 }
  ]
}

pricing_plans

Every component response carries pricing_plans — the plans this component is part of. It is a response-only field; you never send it. Each entry has two fields:

FieldWhat it is
idThe plan's id.
nameThe plan's name.
pricing_plans, populated
"pricing_plans": [
  { "id": 5, "name": "Standard Monthly Plan" },
  { "id": 6, "name": "Yearly Plan" }
]

Empty on a component you just created

A new component is not on any plan yet, so pricing_plans comes back as []. It fills in once the component is put on a plan with POST /pricing-plans. Read it back with GET /pricing-components/:id to see the plans it ended up on.

It is not there inside a plan

A component reported inside a pricing plan response has no pricing_plans key at all — it would point back at the plan you are already reading. Do not expect the field there.

A component has no dates of its own

There is no start_date or end_date on this endpoint, and none on the other component endpoints either. A component on its own is not something that starts or stops.

The dates belong to the component on a plan

You set them when you put the component on a plan, in POST /pricing-plans — components[].start_date and components[].end_date. They are that component's lifetime on that plan, so the same component can run for different dates on two different plans. That is also why they come back inside a plan response and never on a component response.

Status codes

StatusMeaning
201The component is created.
400The component code is already in use.
422Validation failed.
500Unexpected error.
502The service could not be reached.

The bodies for each of those are in Pricing Component Errors.

Update a Pricing Component

Replace a pricing component with how it should end up.

PUT/pricing-components/:idX-Tenant + API Key required

Updates a pricing component. Send the whole component as it should end up, not only the fields that changed. The payload is the same as create; the id goes in the path.

Changing has_billing_period is blocked while the component is in live plans

The response is 400 + items. You can still change a component's name, amounts and other details while it is in use. Only switching how it is priced is blocked.

Example request

JSON body
{
  "component_name": "Setup Fee",
  "component_code": "SETUP",
  "calculation_type": "fixed",
  "has_billing_period": false,
  "base_amount": 3000
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-components/10' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "component_name": "Setup Fee",
    "component_code": "SETUP",
    "calculation_type": "fixed",
    "has_billing_period": false,
    "base_amount": 3000
  }'

Example response

Same shape as the create response.

Status codes

StatusMeaning
200The component is updated.
400The component code is already in use, or has_billing_period was changed while the component is used in live pricing plans.
404No pricing component with that id.
422Validation failed.
500Unexpected error.
502The service could not be reached.

List Pricing Components

Every component at once, with no pagination.

GET/pricing-componentsX-Tenant + API Key required

Returns all pricing components in one call — there is no pagination on this endpoint. Coupons are not listed here; they have their own endpoint.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-components' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

The components come back inside data. Each item is the same shape as the create and update responses — all four endpoints pass through the same mapper.

200 OK
{
  "data": [
    {
      "id": 10,
      "component_code": "SETUP",
      "component_name": "Setup Fee",
      "calculation_type": "fixed",
      "has_billing_period": false,
      "is_active": true,
      "pricing_plans": [],
      "base_amount": 2500
    },
    {
      "id": 6,
      "component_code": "PLAT",
      "component_name": "Platform Fee",
      "calculation_type": "fixed",
      "has_billing_period": true,
      "is_active": true,
      "pricing_plans": [
        { "id": 5, "name": "Standard Monthly Plan" },
        { "id": 6, "name": "Yearly Plan" }
      ],
      "billing_amounts": [
        { "billing_period": "monthly", "amount": 500 },
        { "billing_period": "yearly", "amount": 5000 }
      ]
    }
  ]
}

Status codes

StatusMeaning
200The components are returned.
500Unexpected error.
502The service could not be reached.

Get a Pricing Component

Read one component back by its id.

GET/pricing-components/:idX-Tenant + API Key required

Returns one pricing component as a plain object — no wrapper. The list endpoint puts its items inside data; this one does not.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe component's id, as returned by POST /pricing-components. The example reads component 6.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-components/6' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "id": 6,
  "component_code": "PLAT",
  "component_name": "Platform Fee",
  "calculation_type": "fixed",
  "has_billing_period": true,
  "is_active": true,
  "pricing_plans": [
    { "id": 5, "name": "Standard Monthly Plan" },
    { "id": 6, "name": "Yearly Plan" }
  ],
  "billing_amounts": [
    { "billing_period": "monthly", "amount": 500 },
    { "billing_period": "yearly", "amount": 5000 }
  ]
}

Errors

404 Not Found
{
  "message": "Pricing component not found"
}

Status codes

StatusMeaning
200The component is returned.
404No pricing component with that id.
500Unexpected error.
502The service could not be reached.

Delete a Pricing Component

Remove a component.

DELETE/pricing-components/:idX-Tenant + API Key required

An active component used in live pricing plans cannot be deleted. The response is 422 + items. An inactive component can always be deleted.

Example request

cURL
curl -X DELETE \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-components/10' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "deleted": true
}

Status codes

StatusMeaning
200The component is deleted.
404No pricing component with that id.
422The component is active and used in live pricing plans.
500Unexpected error.
502The service could not be reached.

Change a Pricing Component's Status

Activate or deactivate a component.

PATCH/pricing-components/:id/statusX-Tenant + API Key required

Body parameters

FieldTypeRequiredDescription
is_activebooleanRequired

A component used in live pricing plans cannot be activated or deactivated. The response is 422 + items.

Example request

JSON body
{
  "is_active": false
}
cURL
curl -X PATCH \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-components/10/status' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{ "is_active": false }'

Example response

The component, in the same shape as a get.

Status codes

StatusMeaning
200The status is changed.
404No pricing component with that id.
422Validation failed, or the component is used in live pricing plans.
500Unexpected error.
502The service could not be reached.

Pricing Component Errors

What comes back when a component request is refused.

When a change is blocked

ActionBlocked whenResponse
Changing has_billing_periodThe component is used in live pricing plans400 + items
DeleteThe component is active and used in live pricing plans422 + items
Activate / deactivateThe component is used in live pricing plans422 + items

items lists one { type, id, name } entry per live plan, with type always pricing_plan. A live plan is one that is switched on and inside its own dates, with the component on it for today. Detach the component from each listed plan, then try again.

400 — changing has_billing_period
{
  "message": "This component is priced into live pricing plans. Changing how it is priced will change what those plans cost. Detach it from them first.",
  "items": [
    { "type": "pricing_plan", "id": 12, "name": "Starter Plan" }
  ]
}
422 — delete
{
  "message": "This component is priced into live pricing plans. Removing it will change what those plans cost. Detach it from them first.",
  "items": [
    { "type": "pricing_plan", "id": 12, "name": "Starter Plan" }
  ]
}
422 — activate / deactivate
{
  "message": "This component is priced into live pricing plans. Changing its status will change what those plans cost. Detach it from them first.",
  "items": [
    { "type": "pricing_plan", "id": 12, "name": "Starter Plan" }
  ]
}

Errors

StatusWhenResponse
422validation failed
422 Unprocessable
{
  "message": "The billing amounts are required when the component has billing periods.",
  "errors": {
    "billing_amounts": ["The billing amounts are required when the component has billing periods."]
  }
}
400code already in use (create, update)
400 Bad Request
{
  "message": "Pricing component with same code already exists"
}
404component not found
404 Not Found
{
  "message": "Pricing component not found"
}
500unexpected error
500 Server Error
{
  "message": "<server error>"
}

Validation messages

WhenMessage
calculation_type is not fixedThe calculation type must be fixed. A discount is a coupon, made through POST /coupons.
no base_amount when has_billing_period is falseThe base amount is required when the component has no billing periods.
no billing_amounts when has_billing_period is trueThe billing amounts are required when the component has billing periods.
fewer than two rows in billing_amountsBoth a monthly and a yearly amount are required.
a billing_period other than monthly or yearlyThe billing period must be either monthly or yearly.
the same billing period twiceEach billing period can only be priced once.

Fields that are not accepted

These are dropped if sent:

  • cost_amount
  • min_amount
  • max_amount
  • quantity
  • display_order
  • item_type_id
  • is_taxable
  • is_active — use the status endpoint instead

Create a Pricing Plan

Build a plan out of pricing components.

POST/pricing-plansX-Tenant + API Key required

A plan is built from one or more pricing components, and can carry coupons. A new plan is switched on.

At least one component must be fixed

A plan needs at least one fixed component, or it is rejected.

You do not send the price

price is worked out from the components the plan holds, and it comes back on every response. It is never sent in.

The type of price depends on the plan

Planprice
has_billing_period: falsenumber — 2500
has_billing_period: trueobject — { "monthly": 500, "yearly": 5000 }

This applies to every pricing plan response: list, get, create, update and status.

Check has_billing_period before showing price

If you render it directly, a subscription plan's price shows up as [object Object].

How the price is worked out

  • It is the sum of the plan's fixed components that are switched on and running on the plan today. For a subscription plan, each billing period uses that period's amount.
  • Coupons are never taken off price. A coupon comes off where it is applied, such as on a subscription.

Dates

Every date is sent and returned as YYYY-MM-DD — no time, no timezone.

A timestamp is rejected

2027-03-30T18:30:00.000Z will not be accepted. It has to be rejected, because that value is 30 March in UTC and 31 March in India — the day it means depends on where it is read. 2027-03-31 means the same day everywhere.

Body parameters

FieldTypeRequiredDescription
namestringRequiredmax 255
codestringRequiredmax 50, must be unique
plan_typestringRequiredstandard
has_billing_periodbooleanOptionalfalse = invoice plan (default), true = subscription plan. Every fixed component on the plan must have the same value.
effective_datedateRequiredYYYY-MM-DD, the day the plan starts.
descriptionstringOptionalFree text.
expiration_datedateOptionalYYYY-MM-DD, on or after effective_date — the same day is allowed.
componentsarrayRequiredAt least one, and at least one of them must be a fixed component.
couponsarrayOptionalThe coupons on the plan, each with its dates on this plan. This list replaces the plan's coupons — see below.

What a plan is for: has_billing_period

has_billing_periodPlan
false (the default)invoice — used on an invoice line via lines[].pricing_plan_id
truesubscription

An invoice plan cannot be used for a subscription, and a subscription plan cannot be used on an invoice. Either one returns 422.

Tip

When listing plans in a dropdown, show only true plans for subscriptions and only false plans for invoices.

Fixed components must match the plan

The plan's has_billing_period must match the has_billing_period of every fixed component on it. A subscription plan can only use fixed components priced per billing period (billing_amounts). An invoice plan can only use fixed components priced with a single amount (base_amount). This applies on create and update. The error names the components that do not match.

Always send has_billing_period: true for a subscription plan

Left out, it is taken as false. A plan built from components priced per billing period is then refused with A one-time plan can only use components priced with a single amount...
422 — fixed components do not match the plan
{
  "message": "A subscription plan can only use components priced per billing period. These are not: Platform Fee, Setup Charge.",
  "errors": {
    "components": ["A subscription plan can only use components priced per billing period. These are not: Platform Fee, Setup Charge."]
  }
}

components[]

FieldTypeRequiredDescription
idintegerRequiredId of an existing pricing component.
start_datedateRequiredYYYY-MM-DD, when it starts being charged. Must fall within the plan's dates.
end_datedateOptionalYYYY-MM-DD, on or after start_date (the same day is allowed) and within the plan's dates. Required when the plan has an expiration_date.

coupons[]

FieldTypeRequiredDescription
idintegerRequiredId of an existing coupon, from POST /coupons.
start_datedateRequiredYYYY-MM-DD, when the coupon starts applying on this plan. Must fall within the plan's dates.
end_datedateOptionalYYYY-MM-DD, on or after start_date (the same day is allowed) and within the plan's dates. Required when the plan has an expiration_date.

These dates are when the coupon applies on this plan. The coupon's own dates, limits and switch still apply on top of them.

Component and coupon dates have to sit inside the plan's dates

A component's or coupon's start_date and end_date must both fall between the plan's effective_date and expiration_date. Neither date can be before the plan's effective_date, and neither can be after its expiration_date.

Leaving a date out

  • No expiration_date — the plan runs on with no end.
  • No end_date on a component or coupon — only allowed when the plan has no expiration_date. It then stays for as long as the plan does.

Example request

JSON body
{
  "name": "Yearly Plan",
  "code": "YRLY",
  "plan_type": "standard",
  "has_billing_period": true,
  "description": "Covers the yearly subscription fee.",
  "effective_date": "2026-08-31",
  "expiration_date": "2027-03-31",
  "components": [
    {
      "id": 6,
      "start_date": "2026-08-31",
      "end_date": "2027-03-31"
    }
  ],
  "coupons": [
    {
      "id": 7,
      "start_date": "2026-08-31",
      "end_date": "2026-12-31"
    }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-plans' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Yearly Plan",
    "code": "YRLY",
    "plan_type": "standard",
    "has_billing_period": true,
    "description": "Covers the yearly subscription fee.",
    "effective_date": "2026-08-31",
    "expiration_date": "2027-03-31",
    "components": [
      { "id": 6, "start_date": "2026-08-31", "end_date": "2027-03-31" }
    ],
    "coupons": [
      { "id": 7, "start_date": "2026-08-31", "end_date": "2026-12-31" }
    ]
  }'

Example response

The whole plan, with each component and coupon reported in full and the two dates it runs for on this plan. price is worked out from the components.

201 Created
{
  "id": 6,
  "name": "Yearly Plan",
  "code": "YRLY",
  "description": "Covers the yearly subscription fee.",
  "plan_type": "standard",
  "has_billing_period": true,
  "effective_date": "2026-08-31",
  "expiration_date": "2027-03-31",
  "price": { "monthly": 500, "yearly": 5000 },
  "is_active": true,
  "components": [
    {
      "id": 6,
      "component_code": "PLAT",
      "component_name": "Platform Fee",
      "calculation_type": "fixed",
      "has_billing_period": true,
      "is_active": true,
      "billing_amounts": [
        { "billing_period": "monthly", "amount": 500 },
        { "billing_period": "yearly", "amount": 5000 }
      ],
      "start_date": "2026-08-31",
      "end_date": "2027-03-31"
    }
  ],
  "coupons": [
    {
      "id": 7,
      "coupon_code": "WELCOME20",
      "coupon_name": "Welcome offer",
      "discount_type": "percent",
      "discount_value": 20,
      "cycle_count": 3,
      "is_active": true,
      "start_date": "2026-08-31",
      "end_date": "2026-12-31",
      "max_redemptions": 100,
      "max_per_customer": 1,
      "redemptions_count": 0,
      "status": "active",
      "customer_ids": null
    }
  ]
}

Components keep their own shape inside a plan

A component inside a plan carries the same fields it does on its own endpoints — has_billing_period, and exactly one of base_amount or billing_amounts. See Pricing Components for that shape.

Two differences from the component endpoints

start_date and end_date are added — those are the dates the component runs for on this plan. And pricing_plans is not there: on its own endpoints a component lists the plans it is on, but inside a plan that would point back at the plan you are already reading.

Coupons inside a plan

A coupon inside a plan is the coupon object with three differences: start_date and end_date are its dates on this plan, not its own; pricing_plan_ids is not there; and customer_ids is always null. Its status is the coupon's own. Read the coupon itself from GET /coupons/:id. Every coupon on the plan is listed, whatever its dates.

Status codes

StatusMeaning
201The plan is created.
400The plan code is already in use.
422Validation failed, a component or coupon id does not exist, or the plan has no fixed component.
500Unexpected error.
502The service could not be reached.

The bodies for each of those are in Pricing Plan Errors.

Update a Pricing Plan

Replace a plan with how it should end up.

PUT/pricing-plans/:idX-Tenant + API Key required

Updates a plan. Send the whole plan as it should end up, not only the fields that changed. The payload is the same as create; the id goes in the path.

Send the coupons to keep, every time

An update replaces the plan's components and its coupons together. Leave coupons out, or send [], and every coupon is taken off the plan. To keep a coupon, send it again with its dates.

The same date rules apply

YYYY-MM-DD only — a timestamp is rejected here too. expiration_date must be on or after effective_date, and every component's and coupon's dates must sit inside the plan's. They are spelled out under Create a Pricing Plan → Dates.

has_billing_period cannot change once the plan is used

If the plan has already been used on an invoice, lease or subscription, changing has_billing_period returns 400 + items. Create a new plan instead.

is_active is not part of the body. An update leaves it as it is — use the status endpoint to switch a plan on or off.

Example request

JSON body
{
  "name": "Yearly Plan",
  "code": "YRLY",
  "plan_type": "standard",
  "has_billing_period": true,
  "description": "Covers the yearly subscription fee.",
  "effective_date": "2026-08-31",
  "expiration_date": "2027-03-31",
  "components": [
    {
      "id": 6,
      "start_date": "2026-08-31",
      "end_date": "2027-03-31"
    }
  ],
  "coupons": [
    {
      "id": 7,
      "start_date": "2026-08-31",
      "end_date": "2026-12-31"
    }
  ]
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-plans/6' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Yearly Plan",
    "code": "YRLY",
    "plan_type": "standard",
    "has_billing_period": true,
    "description": "Covers the yearly subscription fee.",
    "effective_date": "2026-08-31",
    "expiration_date": "2027-03-31",
    "components": [
      { "id": 6, "start_date": "2026-08-31", "end_date": "2027-03-31" }
    ],
    "coupons": [
      { "id": 7, "start_date": "2026-08-31", "end_date": "2026-12-31" }
    ]
  }'

Example response

Same shape as the create response.

Status codes

StatusMeaning
200The plan is updated.
400The plan code is already in use, or has_billing_period was changed on a plan that has already been used on an invoice, lease or subscription.
404No pricing plan with that id. The message is The pricing plan or one of its components was not found.
422Validation failed, a component or coupon id does not exist, or the plan has no fixed component.
500Unexpected error.
502The service could not be reached.

List Pricing Plans

Every standard plan at once, with no pagination.

GET/pricing-plansX-Tenant + API Key required

Returns every plan whose plan_type is standard, in one go — switched on or off, current or not. There is no pagination on this endpoint.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-plans' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

The plans come back inside data, each with its components and coupons expanded.

200 OK
{
  "data": [
    {
      "id": 5,
      "name": "Standard Monthly Plan",
      "code": "STDMON",
      "description": null,
      "plan_type": "standard",
      "has_billing_period": true,
      "effective_date": "2026-08-31",
      "expiration_date": null,
      "price": { "monthly": 500, "yearly": 5000 },
      "is_active": true,
      "components": [
        {
          "id": 6,
          "component_code": "PLAT",
          "component_name": "Platform Fee",
          "calculation_type": "fixed",
          "has_billing_period": true,
          "is_active": true,
          "billing_amounts": [
            { "billing_period": "monthly", "amount": 500 },
            { "billing_period": "yearly", "amount": 5000 }
          ],
          "start_date": "2026-08-31",
          "end_date": null
        }
      ],
      "coupons": []
    }
  ]
}

Status codes

StatusMeaning
200The plans are returned.
500Unexpected error.
502The service could not be reached.

Get a Pricing Plan

Read one plan back by its id.

GET/pricing-plans/:idX-Tenant + API Key required

Returns one plan — the same shape as a list item, without the data wrapper.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe plan's id, as returned by POST /pricing-plans. The example reads plan 5.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-plans/5' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "id": 5,
  "name": "Standard Monthly Plan",
  "code": "STDMON",
  "description": null,
  "plan_type": "standard",
  "has_billing_period": true,
  "effective_date": "2026-08-31",
  "expiration_date": null,
  "price": { "monthly": 500, "yearly": 5000 },
  "is_active": true,
  "components": [
    {
      "id": 6,
      "component_code": "PLAT",
      "component_name": "Platform Fee",
      "calculation_type": "fixed",
      "has_billing_period": true,
      "is_active": true,
      "billing_amounts": [
        { "billing_period": "monthly", "amount": 500 },
        { "billing_period": "yearly", "amount": 5000 }
      ],
      "start_date": "2026-08-31",
      "end_date": null
    }
  ],
  "coupons": []
}

Errors

404 Not Found
{
  "message": "Pricing plan not found"
}

Status codes

StatusMeaning
200The plan is returned.
404No pricing plan with that id.
500Unexpected error.
502The service could not be reached.

Delete a Pricing Plan

Remove a plan.

DELETE/pricing-plans/:idX-Tenant + API Key required

When a delete is blocked

Blocked whenResponse
The plan has been used on invoices, leases or subscriptions422 + items. Switch it off instead.
The plan is live and attached to items422 + items. Detach it first.

A live plan is one that is switched on and inside its own dates.

Example request

cURL
curl -X DELETE \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-plans/6' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "deleted": true
}

Status codes

StatusMeaning
200The plan is deleted.
404No pricing plan with that id.
422The plan has been used on invoices, leases or subscriptions, or is live and attached to items.
500Unexpected error.
502The service could not be reached.

Change a Pricing Plan's Status

Activate or deactivate a plan.

PATCH/pricing-plans/:id/statusX-Tenant + API Key required

Body parameters

FieldTypeRequiredDescription
is_activebooleanRequired

Activating or deactivating a plan is never blocked.

Example request

JSON body
{
  "is_active": false
}
cURL
curl -X PATCH \
  'https://services.ap.mochatechnologies.com/quickbill/api/pricing-plans/6/status' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{ "is_active": false }'

Example response

The plan, in the same shape as a get.

Status codes

StatusMeaning
200The status is changed.
404No pricing plan with that id.
422Validation failed.
500Unexpected error.
502The service could not be reached.

Pricing Plan Errors

What comes back when a plan is refused.

When a change is blocked

ActionBlocked whenResponse
Changing has_billing_periodThe plan has already been used on an invoice, lease or subscription400 + items. Create a new plan instead.
DeleteThe plan has been used on invoices, leases or subscriptions422 + items. Switch it off instead.
DeleteThe plan is live and attached to items422 + items. Detach it first.
Activate / deactivateNever blockedn/a
400 — changing has_billing_period
{
  "message": "This plan is already in use, so its billing type can no longer be changed. Create a new plan instead.",
  "items": [
    { "type": "invoice", "id": 101, "name": "INV-00042" },
    { "type": "subscription", "id": 9, "name": "SUB-000009" }
  ]
}
422 — delete, plan in use
{
  "message": "This plan is already in use, so it cannot be deleted. Switch it off instead.",
  "items": [
    { "type": "lease", "id": 14, "name": "LS-00014" }
  ]
}
422 — delete, attached to items
{
  "message": "This plan is attached to items. Detach it from them before deleting.",
  "items": [
    { "type": "product", "id": 3210, "name": "Screening Kit" }
  ]
}

Every entry in items is { type, id, name }:

Refusaltypename
plan in use (update or delete)invoice, lease or subscriptionThe invoice or lease number, or the subscription code.
attached to items (delete)The item type, such as productThe item's name. Can be null.

Errors

StatusWhenResponse
422validation failed
422 Unprocessable
{
  "message": "At least one component with a fixed calculation type is required. The component end date must be on or before the plan expiration date (2027-03-31).",
  "errors": {
    "components": ["At least one component with a fixed calculation type is required."],
    "components.0.end_date": ["The component end date must be on or before the plan expiration date (2027-03-31)."]
  }
}
400code already in use (create, update)
400 Bad Request
{
  "message": "Pricing plan with same name code exists"
}
404plan not found (get, delete, status)
404 Not Found
{
  "message": "Pricing plan not found"
}
404plan not found (update)
404 Not Found
{
  "message": "The pricing plan or one of its components was not found"
}
502the service is down
502 Bad Gateway
{
  "message": "Failed to create pricing plan"
}

A component or coupon id that does not exist is a 422, not a 404.

Validation messages

WhenMessage
no fixed component on the planAt least one component with a fixed calculation type is required.
subscription plan with a fixed component priced with a single amountA subscription plan can only use components priced per billing period. These are not: {component names}.
invoice plan with a fixed component priced per billing periodA one-time plan can only use components priced with a single amount. These are not: {component names}.
a component id that does not existThe selected components.{index}.id is invalid.
a coupon id that does not existThe selected coupon does not exist.
component end_date before its start_dateA component end date cannot be before its start date.
coupon end_date before its start_dateA coupon end date cannot be before its start date.
component or coupon has no end_date on a plan that expiresThe {component|coupon} end date is required because the plan expires on {date}.
component or coupon date before the plan's effective_dateThe {component|coupon} {start date|end date} must be on or after the plan effective date ({date}).
component or coupon date after the plan's expiration_dateThe {component|coupon} {start date|end date} must be on or before the plan expiration date ({date}).
expiration_date before effective_dateThe expiration date cannot be before the effective date.
timestamp instead of a dateThe effective date field must match the format Y-m-d.
no componentsThe components field is required.

Attach Plans to a Product

Set which pricing plans a product is on.

POST/products/:id/pricing-plansX-Tenant + API Key required

Sets which pricing plans a product is on.

This replaces, it does not add

Send the full list the product should end up with. Any plan already on the product but left out of the list is removed, and an empty list takes them all off.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredId of the product — the id from POST /products.

Body parameters

FieldTypeRequiredDescription
pricing_plan_idsarray of integersRequiredThe plans the product should end up on — ids from POST /pricing-plans. May be empty. Each id may appear only once.

Example request

JSON body
{
  "pricing_plan_ids": [6]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/3210/pricing-plans' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "pricing_plan_ids": [6]
  }'

Several plans

JSON body
{
  "pricing_plan_ids": [5, 6]
}

Take every plan off the product

JSON body
{
  "pricing_plan_ids": []
}

An empty list has to be sent on purpose

Leaving the field out altogether is a 422, so a forgotten field can never unlink everything by accident.

Example response

200 OK
{
  "message": "Pricing plans linked successfully"
}

Status codes

StatusMeaning
200The plans are linked.
422The field is missing or the wrong type, a plan id is listed twice or does not exist, or the product does not exist.
500Unexpected error.

The bodies for each of those are in Attach Plan Errors.

Read the plans back to confirm

The response carries a message and nothing else, so to see what the product ended up on, call GET /products/:id/pricing-plans afterwards.

Get a Product's Pricing Plans

Which plans a product is on.

GET/products/:id/pricing-plansX-Tenant + API Key required

Returns the pricing plans a product is on that are in effect today. This is how you check what POST /products/:id/pricing-plans left the product with.

Only plans in effect today are listed

A plan on the product that is switched off, has not started yet, or has expired is left out — even though it is still linked.

Path parameters

FieldTypeRequiredDescription
idintegerRequiredId of the product — the id from POST /products.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/products/3210/pricing-plans' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

The plans come back inside data. Each one carries id, name, code, plan_type, has_billing_period, effective_date, expiration_date and price. Every plan listed is switched on and inside its dates today.

200 OK
{
  "data": [
    {
      "id": 6,
      "name": "Yearly Plan",
      "code": "YRLY",
      "plan_type": "standard",
      "has_billing_period": true,
      "effective_date": "2026-08-31",
      "expiration_date": "2027-03-31",
      "price": { "monthly": 500, "yearly": 5000 }
    }
  ]
}

Read a plan in full from its own endpoint

For a plan's description, components and coupons, call GET /pricing-plans/:id with its id.

Errors

403 Forbidden
{
  "message": "You are not allowed to view this product"
}
404 Not Found
{
  "message": "Product not found"
}

Status codes

StatusMeaning
200The plans are returned. A product on no plans is an empty data array, not an error.
403You are not allowed to view this product.
404No product with that id.
500Unexpected error.

Attach Plan Errors

What comes back when a link is refused.

Errors

StatusWhenResponse
422field missing or wrong typeSee Request validation below.
422a plan id does not existSee A plan id that does not exist below.
422the product does not existSee A product id that does not exist below.
422a plan id is listed twiceSee A plan id listed twice below.
500unexpected error
500 Server Error
{
  "message": "Failed to link the pricing plans"
}

Request validation

WhenResponse
pricing_plan_ids left out
422 Unprocessable
{
  "message": "...",
  "errors": {
    "pricing_plan_ids": ["The pricing plans field must be present."]
  }
}
not an array
422 Unprocessable
{
  "message": "...",
  "errors": {
    "pricing_plan_ids": ["The pricing plans field must be an array."]
  }
}
an entry is not an integer
422 Unprocessable
{
  "message": "...",
  "errors": {
    "pricing_plan_ids.0": ["The pricing plan field must be an integer."]
  }
}

A plan id that does not exist

422 Unprocessable
{
  "message": "The selected pricing plan (574) is invalid.",
  "errors": {
    "pricing_plan_ids.0": ["The selected pricing plan (574) is invalid."]
  }
}

A plan id listed twice

Every copy of the repeated id is reported.

422 Unprocessable
{
  "message": "The pricing plan ids.0 field has a duplicate value. The pricing plan ids.1 field has a duplicate value.",
  "errors": {
    "pricing_plan_ids.0": ["The pricing plan ids.0 field has a duplicate value."],
    "pricing_plan_ids.1": ["The pricing plan ids.1 field has a duplicate value."]
  }
}

A product id that does not exist

422 Unprocessable
{
  "message": "The product does not exist."
}

There is no errors here because the product id is not a field you send — it is in the path. Naming it would point you at something you never wrote.

More than one thing wrong

The messages are run together — the product first, then the plans — and errors names each field it can.

422 Unprocessable
{
  "message": "The product does not exist. The selected pricing plan (574) is invalid.",
  "errors": {
    "pricing_plan_ids.0": ["The selected pricing plan (574) is invalid."]
  }
}

Create an Addon or Charge

Something billed beside a subscription's plan.

POST/addon-chargesX-Tenant + API Key required

An addon or charge is sold on top of a subscription's plan. Like a product, it is priced by pricing plans, and its sales go to an income account.

TypeBillsPlans it takes
addonOn every cycle of the subscription — or for cycle_count cycles.Any plan.
chargeOnce.One-time plans (has_billing_period: false) only.

Body parameters

FieldTypeRequiredDescription
typestringRequiredaddon bills on every cycle of a subscription; charge bills once. It cannot change once the item is used on an invoice or subscription.
namestringRequiredMax 191 characters.
codestringOptionalMust not be used by another product, addon or charge. Leave it empty and one is made for you on create (ADN-000001, CHG-000001); on update an empty code keeps the current one.
descriptionstringOptionalFree text.
revenue_accountintegerRequiredThe income account its sales are booked to — an id from GET /income-accounts.
expense_accountintegerOptionalAn id from GET /expense-accounts. Only when you buy it from a vendor and resell it.
pricing_plan_idsinteger[]OptionalThe pricing plans it is priced by. An addon takes any plan. A charge takes one-time plans (has_billing_period: false) only. On update, leave it out to keep the plans it has; an empty list takes them all off.
cycle_countintegerOptionalAddon only, 1 or more: how many cycles it bills for. null or left out means every cycle with no end. Refused on a charge.
is_activebooleanOptionalLeft out, it is active — on update too, so send false to keep an inactive one inactive.

Example: an addon

JSON body
{
  "type": "addon",
  "name": "Extra Storage",
  "description": "50 GB more storage",
  "revenue_account": 12,
  "pricing_plan_ids": [6],
  "cycle_count": null
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/addon-charges' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "addon",
    "name": "Extra Storage",
    "revenue_account": 12,
    "pricing_plan_ids": [6]
  }'

Example: a charge

JSON body
{
  "type": "charge",
  "name": "Setup Fee",
  "revenue_account": 12,
  "pricing_plan_ids": [7]
}

Example response

201 Created
{
  "id": 101,
  "type": "addon",
  "name": "Extra Storage",
  "code": "ADN-000001",
  "description": "50 GB more storage",
  "revenue_account": 12,
  "expense_account": null,
  "cycle_count": null,
  "pricing_plan": [
    {
      "id": 6,
      "name": "Storage Monthly",
      "code": "STGMON",
      "plan_type": "standard",
      "has_billing_period": true,
      "effective_date": "2026-11-01",
      "expiration_date": null,
      "price": { "monthly": 199, "yearly": 1990 }
    }
  ],
  "is_active": true
}
  • pricing_plan lists the plans it is on, each in the same shape as a product's plans.
  • cycle_count is always null on a charge.

Putting it on a subscription

Send its id as item_id and one of its plans as plan_id, in subscription_items:

subscription_items
"subscription_items": [
  { "item_type": "plan",   "item_id": 3205, "plan_id": 5 },
  { "item_type": "addon",  "item_id": 101,  "plan_id": 6 },
  { "item_type": "charge", "item_id": 102,  "plan_id": 7 }
]

Billing it on an invoice

Send its id as addon_charge_id on an invoice line, in place of product_id:

lines
"lines": [
  { "addon_charge_id": 102, "pricing_plan_id": 7, "quantity": 1 }
]

Status codes

StatusMeaning
201Created. The addon or charge is returned.
400The code is already used — "This code is already used by another product, addon or charge. Choose a different code."
422Validation failed — for example "An income account is required.", "A cycle count is only for an addon. A charge is billed once." or "A charge can only use one-time plans."

Update an Addon or Charge

Replace one — send it whole.

PUT/addon-charges/:idX-Tenant + API Key required

Takes the same fields as create. Send it as it should end up, not only what changed.

Three things an update does on its own

  • is_active left out makes it active.
  • pricing_plan_ids left out keeps its plans; an empty list takes them all off.
  • An empty code keeps the current one.

Status codes

StatusMeaning
200Updated. The addon or charge is returned.
400The code is already used.
404No addon or charge with that id.
422Validation failed, or the type was changed on one already used — "This addon/charge is already used in transactions, so its type cannot be changed."

List Addons and Charges

Newest first, a page at a time.

GET/addon-chargesX-Tenant + API Key required
FieldTypeRequiredDescription
pageintegerOptionalDefaults to 1.
page_lengthintegerOptionalDefaults to 10.
searchJSON stringOptionaldata matches the name or code; type is addon or charge; status is 1 (active) or 0 (inactive). Leave a key out to not filter on it.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/addon-charges' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=10' \
  --data-urlencode 'search={"type":"addon","status":1}'

Example response

200 OK
{
  "data": [
    { "id": 101, "type": "addon", "name": "Extra Storage", "code": "ADN-000001", "...": "as above" }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "last_page": 1,
    "total": 1,
    "from": 1,
    "to": 1
  }
}

Get an Addon or Charge

Read one back.

GET/addon-charges/:idX-Tenant + API Key required

Returns one addon or charge, in the same shape create returns. An id that does not exist returns 404.

Delete an Addon or Charge

Only while nothing uses it.

DELETE/addon-charges/:idX-Tenant + API Key required
  • Used on an invoice or subscription: refused with 422 — "This addon/charge is already used in transactions, so it cannot be deleted. Make it inactive instead."
  • On live pricing plans: refused with 422 and items, the plans it is on. Take it off them (update with those plans left out of pricing_plan_ids), then delete.
422 Unprocessable
{
  "message": "This addon/charge is attached to live pricing plans. Detach it from them before deleting.",
  "items": [
    { "type": "pricing_plan", "id": 6, "name": "Storage Monthly" }
  ]
}

Status codes

StatusMeaning
200Deleted — { "deleted": true }.
404No addon or charge with that id.
422Already used, or on live pricing plans.

Change an Addon or Charge's Status

Switch it on or off.

PATCH/addon-charges/:id/statusX-Tenant + API Key required

An inactive addon or charge cannot go on a new subscription. Subscriptions already running and past invoices are not touched.

JSON body
{
  "is_active": false
}

Status codes

StatusMeaning
200Changed. The addon or charge is returned.
404No addon or charge with that id.
422is_active is missing or not true/false.

Create a Coupon

Add a discount that can be applied to a subscription.

POST/couponsX-Tenant + API Key required

A coupon is applied to a subscription by sending its id as coupon_id on an item in subscription_items, or as subscription_coupon_id for the whole subscription, on create or update.

Body parameters

FieldTypeRequiredDescription
coupon_codestringRequiredmax 100. Must be unique across all pricing components, not only coupons — a normal component's code clashes too.
coupon_namestringRequiredmax 191
discount_typestringRequiredpercent or flat_amount
discount_valuenumberRequiredmin 0. With percent the max is 100.
cycle_countintegerOptionalmin 1. How many billing cycles the discount runs for. null means it never runs out.
is_activebooleanOptionalDefaults to true — on create and on update.
start_datedateOptionalYYYY-MM-DD. The first day the coupon can be used, from the start of that day. null means no start limit.
end_datedateOptionalYYYY-MM-DD, on or after start_date. The last day the coupon can be used, to the end of that day. null means it does not end.
max_redemptionsintegerOptionalmin 1. How many times the coupon can be used in all. null means no limit.
max_per_customerintegerOptionalmin 1. How many times one customer can use it. null means no limit.
pricing_plan_idsarray of integersOptionalThe pricing plans the coupon sits on. Each id must exist and appear once. An empty list takes it off every plan.
customer_idsarray of integersOptionalThe customers the coupon is kept for. Each id must exist and appear once. An empty list opens it to every customer.

Plans added through pricing_plan_ids have no dates on the plan

The coupon then applies for as long as the plan runs. A plan that already had the coupon keeps the dates it had. To give a coupon its own dates on a plan, send it in the plan's coupons list on POST /pricing-plans or PUT /pricing-plans/:id.

A plan update replaces the plan's coupons

PUT /pricing-plans/:id sets the plan's coupons to its coupons list. A coupon put on a plan here is taken off again by a plan update that leaves it out.

The coupon object

Returned by create, update, get and status, inside data for list, and inside coupon for a successful validate.

FieldNotes
discount_typepercent or flat_amount.
discount_valueAlways a number. Whole values have no decimals.
cycle_countHow many billing cycles the discount runs for. null means it never runs out.
start_date, end_dateYYYY-MM-DD or null.
max_redemptions, max_per_customernull means no limit.
redemptions_countHow many times the coupon has been used.
statusWhether it can be used right now. See the table below.
pricing_plan_ids, customer_idsLists of ids. An empty customer_ids means the coupon is open to every customer. Both are null on the coupon inside a validate response.

status

ValueMeaning
activeSwitched on, inside its dates and under its limit. Only an active coupon can be used.
inactiveSwitched off (is_active: false).
scheduledIts start_date has not come yet.
expiredIts end_date has passed.
exhaustedredemptions_count has reached max_redemptions.

Example request

JSON body
{
  "coupon_code": "WELCOME20",
  "coupon_name": "Welcome offer",
  "discount_type": "percent",
  "discount_value": 20,
  "cycle_count": 3,
  "is_active": true,
  "start_date": "2026-11-01",
  "end_date": "2027-03-31",
  "max_redemptions": 100,
  "max_per_customer": 1,
  "pricing_plan_ids": [12],
  "customer_ids": []
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "coupon_code": "WELCOME20",
    "coupon_name": "Welcome offer",
    "discount_type": "percent",
    "discount_value": 20,
    "cycle_count": 3,
    "is_active": true,
    "start_date": "2026-11-01",
    "end_date": "2027-03-31",
    "max_redemptions": 100,
    "max_per_customer": 1,
    "pricing_plan_ids": [12],
    "customer_ids": []
  }'

Example response

201 Created
{
  "id": 7,
  "coupon_code": "WELCOME20",
  "coupon_name": "Welcome offer",
  "discount_type": "percent",
  "discount_value": 20,
  "cycle_count": 3,
  "is_active": true,
  "start_date": "2026-11-01",
  "end_date": "2027-03-31",
  "max_redemptions": 100,
  "max_per_customer": 1,
  "redemptions_count": 0,
  "status": "active",
  "pricing_plan_ids": [12],
  "customer_ids": []
}

Status codes

StatusMeaning
201The coupon is created.
400coupon_code is already in use.
422Validation failed, or a plan or customer id does not exist.
500Unexpected error.
502The service could not be reached.

The bodies for each of those are in Coupon Errors.

Update a Coupon

Change a coupon.

PUT/coupons/:idX-Tenant + API Key required

Takes the same body as create. Every required field must be sent again. The id goes in the path.

Fields left out on update

FieldLeft out
is_activeThe coupon is switched on. Send false every time to keep a coupon switched off.
cycle_count, start_date, end_date, max_redemptions, max_per_customerKept as they are. Send null to clear one.
pricing_plan_ids, customer_idsKept as they are. Send [] to empty one.

A used coupon keeps its discount

Once a coupon has been used, its discount_type, discount_value and cycle_count cannot change — the update is refused with 422. Create a new coupon instead. Its name, dates, limits, plans and customers can still change.

A limit cannot go below what is already used

max_redemptions cannot be set below redemptions_count, and max_per_customer cannot be set below the most any one customer has used it. Either is refused with 422.

Example request

JSON body
{
  "coupon_code": "WELCOME20",
  "coupon_name": "Welcome offer",
  "discount_type": "percent",
  "discount_value": 20,
  "cycle_count": 3,
  "is_active": true,
  "start_date": "2026-11-01",
  "end_date": "2027-03-31",
  "max_redemptions": 100,
  "max_per_customer": 1,
  "pricing_plan_ids": [12],
  "customer_ids": []
}
cURL
curl -X PUT \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons/7' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "coupon_code": "WELCOME20",
    "coupon_name": "Welcome offer",
    "discount_type": "percent",
    "discount_value": 20,
    "cycle_count": 3,
    "is_active": true,
    "start_date": "2026-11-01",
    "end_date": "2027-03-31",
    "max_redemptions": 100,
    "max_per_customer": 1,
    "pricing_plan_ids": [12],
    "customer_ids": []
  }'

Example response

200 OK
{
  "id": 7,
  "coupon_code": "WELCOME20",
  "coupon_name": "Welcome offer",
  "discount_type": "percent",
  "discount_value": 20,
  "cycle_count": 3,
  "is_active": true,
  "start_date": "2026-11-01",
  "end_date": "2027-03-31",
  "max_redemptions": 100,
  "max_per_customer": 1,
  "redemptions_count": 0,
  "status": "active",
  "pricing_plan_ids": [12],
  "customer_ids": []
}

Status codes

StatusMeaning
200The coupon is updated.
400coupon_code is already in use.
404Coupon not found.
422Validation failed, the coupon is in use and its discount or cycle count changed, or a limit is below what is already used.
500Unexpected error.
502The service could not be reached.

The bodies for each of those are in Coupon Errors.

List Coupons

Every coupon at once, with no pagination.

GET/couponsX-Tenant + API Key required

Returns every coupon inside data. There is no meta key and no pagination.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "data": [
    {
      "id": 7,
      "coupon_code": "WELCOME20",
      "coupon_name": "Welcome offer",
      "discount_type": "percent",
      "discount_value": 20,
      "cycle_count": 3,
      "is_active": true,
      "start_date": "2026-11-01",
      "end_date": "2027-03-31",
      "max_redemptions": 100,
      "max_per_customer": 1,
      "redemptions_count": 4,
      "status": "active",
      "pricing_plan_ids": [12],
      "customer_ids": []
    }
  ]
}

Status codes

StatusMeaning
200The coupons are returned.
500Unexpected error.
502The service could not be reached.

Get a Coupon

Read one coupon back by its id.

GET/coupons/:idX-Tenant + API Key required

Path parameters

FieldTypeRequiredDescription
idintegerRequiredThe coupon's id. The example reads coupon 7.

Example request

cURL
curl -X GET \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons/7' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "id": 7,
  "coupon_code": "WELCOME20",
  "coupon_name": "Welcome offer",
  "discount_type": "percent",
  "discount_value": 20,
  "cycle_count": 3,
  "is_active": true,
  "start_date": "2026-11-01",
  "end_date": "2027-03-31",
  "max_redemptions": 100,
  "max_per_customer": 1,
  "redemptions_count": 0,
  "status": "active",
  "pricing_plan_ids": [12],
  "customer_ids": []
}

Errors

404 Not Found
{
  "message": "Coupon not found"
}

Status codes

StatusMeaning
200The coupon is returned.
404Coupon not found.
500Unexpected error.
502The service could not be reached.

Validate a Coupon

Preview what a code takes off a pricing plan or an amount.

POST/coupons/validateX-Tenant + API Key required

Works out what a code would take off a pricing plan, or off an amount you send. It does not apply the coupon. The code is matched without regard to case.

Body parameters

FieldTypeRequiredDescription
coupon_codestringRequiredmax 100
amountnumberOptionalmin 0. The price the discount comes off. When sent, it is used instead of the plan's price, and pricing_plan_id is not needed.
pricing_plan_idintegerOptionalRequired when amount is not sent. Must be an existing plan. The discount comes off the plan's price.
billing_cyclestringOptionalmonthly or yearly. Required when the plan is a subscription plan (has_billing_period: true) and no amount is sent.
customer_idintegerOptionalThe customer who would use the code. A coupon kept for some customers is refused for anyone else — and also when customer_id is left out.

billing_cycle and the plan

This applies when no amount is sent. With an amount, the preview is always on that amount.

Planbilling_cycleResult
Invoice (false)not sentPreview on the plan's price.
Invoice (false)sentIgnored. Preview on the plan's price.
Subscription (true)not sent422
Subscription (true)monthly / yearlyPreview on that period's price.
Anyanything other than monthly or yearly422
422 — subscription plan, no billing_cycle
{
  "message": "This is a subscription plan, so a billing cycle is required to price the discount."
}

There is no errors key in this one, because it names billing_cycle — a field you did not send.

422 — neither amount nor pricing_plan_id
{
  "message": "Send a pricing plan or an amount to price the discount.",
  "errors": {
    "pricing_plan_id": ["Send a pricing plan or an amount to price the discount."]
  }
}

A code that does not apply also returns 200

Clients must check valid.

Example request

JSON body — a plan
{
  "coupon_code": "WELCOME20",
  "pricing_plan_id": 12,
  "billing_cycle": "monthly",
  "customer_id": 45
}
JSON body — an amount
{
  "coupon_code": "WELCOME20",
  "amount": 1000,
  "customer_id": 45
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons/validate' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "coupon_code": "WELCOME20",
    "pricing_plan_id": 12,
    "billing_cycle": "monthly",
    "customer_id": 45
  }'

Example response

When the code applies:

200 OK
{
  "valid": true,
  "coupon": {
    "id": 7,
    "coupon_code": "WELCOME20",
    "coupon_name": "Welcome offer",
    "discount_type": "percent",
    "discount_value": 20,
    "cycle_count": 3,
    "is_active": true,
    "start_date": "2026-11-01",
    "end_date": "2027-03-31",
    "max_redemptions": 100,
    "max_per_customer": 1,
    "redemptions_count": 4,
    "status": "active",
    "pricing_plan_ids": null,
    "customer_ids": null
  },
  "base_amount": 1000,
  "discount_amount": 200,
  "payable_amount": 800
}

When it does not apply:

200 OK
{
  "valid": false,
  "message": "This coupon code does not exist."
}

Known messages

WhenMessage
no coupon has that codeThis coupon code does not exist.
the coupon is switched off (is_active: false)This coupon is no longer active.
the coupon is kept for other customers, or no customer_id was sentThis coupon is not available for this customer.
start_date has not come yetThis coupon has not started yet.
end_date has passedThis coupon has expired.
max_redemptions is used upThis coupon has reached its redemption limit.

Validate does not check max_per_customer. That limit is checked when the coupon is put on a subscription.

Status codes

StatusMeaning
200The check ran. Read valid to see whether the code applies.
422Validation failed: neither amount nor pricing_plan_id, a plan that does not exist, or a missing or unknown billing_cycle.
500Unexpected error.
502The service could not be reached.

Delete a Coupon

Remove a coupon.

DELETE/coupons/:idX-Tenant + API Key required

When a delete is blocked

Blocked whenResponse
The coupon has been used — switched on or off422. Switch it off instead.
The coupon is switched on and sits on live pricing plans422 + items. Detach it from each plan first.

A live plan is one that is switched on and inside its own dates, with the coupon on it for today. An unused coupon that is switched off can always be deleted.

Example request

cURL
curl -X DELETE \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons/7' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY"

Example response

200 OK
{
  "deleted": true
}

Status codes

StatusMeaning
200The coupon is deleted.
404Coupon not found.
422The coupon has been used, or it is switched on and sits on live pricing plans.
500Unexpected error.
502The service could not be reached.

The bodies for each of those are in Coupon Errors.

Change a Coupon's Status

Activate or deactivate a coupon.

PATCH/coupons/:id/statusX-Tenant + API Key required

Body parameters

FieldTypeRequiredDescription
is_activebooleanRequired

Switching a coupon on or off is never blocked. Switching it off only stops new use — subscriptions and invoices that already carry it are not changed.

Example request

JSON body
{
  "is_active": false
}
cURL
curl -X PATCH \
  'https://services.ap.mochatechnologies.com/quickbill/api/coupons/7/status' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{ "is_active": false }'

Example response

The updated coupon object.

200 OK
{
  "id": 7,
  "coupon_code": "WELCOME20",
  "coupon_name": "Welcome offer",
  "discount_type": "percent",
  "discount_value": 20,
  "cycle_count": 3,
  "is_active": false,
  "start_date": "2026-11-01",
  "end_date": "2027-03-31",
  "max_redemptions": 100,
  "max_per_customer": 1,
  "redemptions_count": 4,
  "status": "inactive",
  "pricing_plan_ids": [12],
  "customer_ids": []
}

Status codes

StatusMeaning
200The status is changed.
404Coupon not found.
422Validation failed.
500Unexpected error.
502The service could not be reached.

Coupon Errors

What comes back when a coupon request is refused.

Every error has a message.

Errors

StatusWhenResponse
400coupon_code is already used by another pricing component (create or update)
400 Bad Request
{
  "message": "This code is already used by another pricing component. Choose a different code."
}
404coupon not found
404 Not Found
{
  "message": "Coupon not found"
}
422validation failed
422 Unprocessable
{
  "message": "A percentage discount cannot be more than 100.",
  "errors": {
    "discount_value": ["A percentage discount cannot be more than 100."]
  }
}
422a used coupon's discount or cycle count was changed (update)
422 Unprocessable
{
  "message": "This coupon is already in use, so its discount and duration cannot be changed. Create a new coupon instead."
}
422a limit is below what is already used (update)
422 Unprocessable
{
  "message": "This coupon has already been used 4 times, so its limit cannot go below 4."
}
422the coupon has been used (delete)
422 Unprocessable
{
  "message": "This coupon is already in use, so it cannot be deleted. Switch it off instead."
}
422the coupon is switched on and sits on live plans (delete)
422 Unprocessable
{
  "message": "This coupon is attached to live pricing plans. Removing it will take it off those plans. Detach it from them first.",
  "items": [
    { "type": "pricing_plan", "id": 12, "name": "Starter Plan" }
  ]
}

Validation messages

WhenMessage
percent with a discount_value over 100A percentage discount cannot be more than 100.
discount_type is not percent or flat_amountThe discount type must be either percent or flat_amount.
cycle_count below 1The cycle count must be at least 1. Leave it out for a discount that never runs out.
start_date or end_date not YYYY-MM-DDStart date must be in the YYYY-MM-DD format. / End date must be in the YYYY-MM-DD format.
end_date before start_dateEnd date cannot be before the start date.
max_redemptions below 1Max redemptions must be at least 1. Leave it out for no limit.
max_per_customer below 1Max per customer must be at least 1. Leave it out for no limit.
the same id twice in pricing_plan_idsA pricing plan is listed more than once.
the same id twice in customer_idsA customer is listed more than once.
an id in pricing_plan_ids or customer_ids that does not exist"The selected ... is invalid.", keyed by the entry — for example pricing_plan_ids.0.

Telling the 422s apart

All of these share a status code. A validation failure has errors. The live-plans block has items — one { type, id, name } entry per plan, with type always pricing_plan. To get past it, detach the coupon from each listed plan and try again. The others carry only message.

Subscriptions

How the subscription endpoints behave, before you call any of them.

These endpoints take a compact payload: you send ids, and the service resolves everything else — the customer, the plan price, the current plan, the product name and whether a change is an upgrade or a downgrade.

Two things you never send

FieldWhy not
billing_alignment_modeWhether a change applies now or at the next renewal. The service decides it.
business_entity_idDerived from the subscription.

subscription_code

Every endpoint except create identifies the subscription by its subscription_code, not by a numeric id:

Format
SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001

Send it whole, and treat it as opaque

It is a long string, not a short reference like INV-00016 or PMT-00004. Store it as you received it and send it back unchanged — do not shorten it, and do not build one yourself from the trailing counter.

Upgrade and downgrade

TermWhat it means
upgradeThe new plan costs the same as, or more than, the current one.
downgradeThe new plan costs less.

Comparison is on gross price

Always the price before any discount. A discounted expensive plan is still an upgrade over a cheaper one.

Five behaviours worth knowing up front

  • prorate defaults to false — an invoice is only raised when you send true.
  • Whether a change lands now or at the next renewal is decided by the service, never sent by you.
  • Nothing is charged during a trial or before the start date — in update and in preview.
  • A downgrade never applies immediately outside a trial.
  • No payment record is ever created by these endpoints.

Invoices yes, payments no

These endpoints create invoices but never record a payment. Collecting the money happens outside this API — there is no receive-payment row to find afterwards.

Coupons

A coupon goes on an item by sending its id as coupon_id on that item in subscription_items, or on the whole subscription as subscription_coupon_id, on create or update. The subscription coupon comes off what the items leave after their own coupons.

What you sentResponse
An id that is not a coupon422 The selected coupon does not exist.
A new coupon that is inactive422 This coupon is no longer active.
On update, the coupon the item (or the subscription) already hasKept as it is: its cycles keep counting from when it went on, and it is not counted as a new use. This holds even if the coupon was switched off since, or its cycles have run out.
On update, a different couponTakes the place of the one running; its cycles count from today.
No coupon_id / subscription_coupon_idNo error. On create, no discount is applied. On update, the coupon is taken off — send the current one back to keep it.

Discount details

Discount
{
  "discount_type": "percentage",
  "discount_value": 20,
  "discount_tenure": 3,
  "discount_amount": 200
}
FieldWhat it is
discount_typepercentage or amount.
discount_tenureThe number of billing cycles the discount lasts. null means it never ends.
discount_amountSee below.
discount_amount
percent coupon:  rate x value / 100
flat coupon:     the smaller of value and rate

Validation messages

Create, update and preview check the body first, and answer 422 with one of these on the field that is wrong:

FieldProblemMessage
subscription_itemsMissing or emptyAt least one subscription item is required.
subscription_itemsNot a listSubscription items must be a list.
item_typeMissingItem type is required for each subscription item.
item_typeNot plan, addon or chargeItem type must be plan, addon or charge.
item_idMissing / not a numberItem is required for each subscription item. / Item must be a valid id.
plan_idMissing / not a numberPlan is required for each subscription item. / Plan must be a valid id.
coupon_idNot a numberCoupon must be a valid id.
item_priceNot a number / below 0Item price must be a valid amount. / Item price cannot be negative.
subscription_coupon_idNot a numberSubscription coupon must be a valid id.
billing_cycleNot monthly or yearlyBilling cycle must be either monthly or yearly.
cycle_change_atNot now or term_endCycle change must be either now or term_end.
prorateNot true or falseProrate must be either true or false.

Create a Subscription

Put a customer on a plan, with or without a trial.

POST/subscriptionsX-Tenant + API Key required

Body parameters

FieldTypeRequiredDefaultNotes
customer_idintegerRequired—Must exist for the tenant.
subscription_itemsarrayRequired—Exactly one plan item, then any addons and charges. See Subscription items below.
billing_cyclestringRequired—monthly or yearly.
start_datedateOptionaltodayYYYY-MM-DD, today or later.
trial_daysintegerOptionalnoneMinimum 1. trial_end = start_date + trial_days.
subscription_coupon_idintegerOptionalnoneA coupon on the whole subscription. Leave it out and none is applied. See Coupons.

Subscription items

Each entry in subscription_items is one line of the subscription. Update and preview take the same items.

FieldTypeRequiredNotes
item_typestringRequiredplan, addon or charge. Send exactly one plan.
item_idintegerRequiredThe product for a plan item; else the addon or the charge, from /addon-charges.
plan_idintegerRequiredThe pricing plan the item is billed on, attached to that item. A charge takes a one-time plan (has_billing_period: false).
coupon_idintegerOptionalA coupon on this item.
item_pricenumberOptionalA price typed in by hand, 0 or more. Leave it out for the plan's price.
  • Every line is billed at a quantity of 1.
  • An addon and a charge are billed on the subscription's billing cycle, next to the plan.
  • A charge bills once and at once, so it is refused on a subscription with a trial or a future start date.

The four cases

What gets created depends on two things only — whether the start date is today or in the future, and whether there is a trial.

Start dateTrialInvoice todaytrial_endTerm end and recurring anchorstatus
todaynoYes, full amount—start_date + 1 cycleactive
todayyesYes, zero amount (100% discount)start_date + trial_daystrial_endtrialing
futurenoNo—start_dateactive
futureyesNostart_date + trial_daystrial_endtrialing

Always created, in every case

The subscription row, its items, and a recurring template anchored as the table shows.

Example request

JSON body
{
  "customer_id": 16908,
  "billing_cycle": "monthly",
  "start_date": "2026-09-07",
  "trial_days": 14,
  "subscription_coupon_id": 8,
  "subscription_items": [
    { "item_type": "plan", "item_id": 3210, "plan_id": 5, "coupon_id": 7 },
    { "item_type": "addon", "item_id": 3305, "plan_id": 12 }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/subscriptions' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "customer_id": 16908,
    "billing_cycle": "monthly",
    "start_date": "2026-09-07",
    "trial_days": 14,
    "subscription_coupon_id": 8,
    "subscription_items": [
      { "item_type": "plan", "item_id": 3210, "plan_id": 5, "coupon_id": 7 },
      { "item_type": "addon", "item_id": 3305, "plan_id": 12 }
    ]
  }'

The minimum

Leave everything optional out and the subscription starts today on the plan alone, with no trial and no coupon.

Minimum body
{
  "customer_id": 16908,
  "billing_cycle": "monthly",
  "subscription_items": [
    { "item_type": "plan", "item_id": 3210, "plan_id": 5 }
  ]
}

Errors

ConditionStatusMessage
Not exactly one plan item422subscription_items needs exactly one plan item.
The plan item's item_id is not a product (for example an addon's id)422The selected plan item does not exist.
Plan not attached to the product422The selected pricing plan is not attached to this product.
Plan is inactive422The selected pricing plan is inactive and cannot be used.
An addon or charge that does not exist, or is inactive422Addon #<id> does not exist. / Addon #<id> is inactive and cannot be added. (Charge the same way.)
Plan not attached to the addon or charge422Pricing plan #<plan_id> is not attached to addon #<id>.
A charge on a subscription plan422Pricing plan #<plan_id> is a subscription plan and cannot be used for charge #<id>.
A charge with a trial or a future start date422Charges are not applicable to a subscription with a trial or a future start date.
coupon_id or subscription_coupon_id is not a coupon422The selected coupon does not exist.
Coupon is inactive422This coupon is no longer active.
Unknown customer, item or plan422Validation errors on the id fields.
billing_cycle is not monthly or yearly422Validation error.

List Subscriptions

Read your subscriptions back, a page at a time.

GET/subscriptionsX-Tenant + API Key required

Returns your subscriptions in pages. It takes the same three query parameters as every other list endpoint on this page — the same products, invoices and payments lists use, so one paging helper works everywhere.

Query parameters

FieldTypeRequiredDescription
pageintegerRequiredWhich page to return, starting at 1.
page_lengthintegerRequiredHow many subscriptions per page.
searchstringRequiredA JSON object, sent as a string, holding your filters. Send {} for no filter, and URL-encode it.

Example request

cURL
curl -G \
  'https://services.ap.mochatechnologies.com/quickbill/api/subscriptions' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  --data-urlencode 'page=1' \
  --data-urlencode 'page_length=10' \
  --data-urlencode 'search={}'

Status codes

StatusMeaning
200The page is returned, even when it is empty.
500Unexpected error.

Update a Subscription

Change the plan, addons, charges, coupons or billing cycle.

POST/subscriptions/updateX-Tenant + API Key required

Moves a subscription onto a different plan of the same product, adds or takes off addons, adds one-time charges, puts on or takes off coupons, or changes the billing cycle — any of these in one call.

Body parameters

FieldTypeRequiredDefaultNotes
subscription_codestringRequired—Must exist for the tenant.
subscription_itemsarrayRequired—The whole list the subscription should have: its plan item and every addon to keep, with the same fields as on create. The plan item's item_id must be the product the subscription is already on.
billing_cyclestringOptionalcurrent cyclemonthly or yearly. Send it only to change the cycle.
cycle_change_atstringOptionalnowWhen a new cycle starts: now bills the whole new cycle at once, term_end waits for the renewal.
subscription_coupon_idintegerOptionalnoneThe coupon on the whole subscription. Leave it out and it is taken off.
proratebooleanOptionalfalsetrue to raise a proration invoice. Ignored when the billing cycle changes.

prorate defaults to false

A missing flag never charges a customer by accident. Send prorate: true explicitly when you want the mid-term difference charged.

Send the whole list

  • An addon left out of subscription_items is taken off. Send every addon you want to keep, every time.
  • A charge already on the subscription is never taken again; send only new charges. A new charge is refused while the subscription is in its trial or has not started.
  • An addon that has run all its cycles stays ended, even if you send it back.

Prices on an update

item_pricePrice the item gets
A numberThat price.
nullThe plan's own price.
Left outWhat the customer pays now. A new plan, a new billing cycle or a new addon takes the plan's price instead.

Coupons on an update

  • Send an item's current coupon back to keep it as it is — even on a new plan.
  • Send a different coupon to replace the one running; its cycles count from today.
  • Leave the coupon out and it is taken off.
  • Swapping one addon for another takes the old one off and adds a new one: the old addon's coupon does not move across. A coupon sent on the new addon goes on as a new coupon, its cycles counting from today.
  • The same holds for subscription_coupon_id on the whole subscription.

How the mode is decided

You do not send it. The service works it out:

SituationModeWhat it means
Subscription is in trialimmediateApplies now, even for a downgrade.
UpgradeimmediateApplies now.
Downgrade, not in trialdelayedNothing changes today; it applies at the next renewal.
New billing cycle with cycle_change_at: term_end, not in trialdelayedThe new cycle starts at the next renewal.

Upgrade and downgrade compare what one cycle costs after the change — the plan and every addon — with what it costs now.

A delayed change is stored, not applied

The whole request is kept and applied when the next renewal invoice is generated. Nothing is written to the subscription until then — reading it back straight after the call will still show the old plan.

Every case

PlanIn trialModeProration invoiceResult
upgradenoimmediateif proratePlan changes now.
nothing changedno——422
new billing cycle, nownoimmediateNoneOne invoice for the whole new cycle, which runs from the current term end.
new addon addednoimmediateif prorateAddon goes on now; the proration invoice covers the days left in the term.
new charge addednoeitherNoneA separate charge invoice now — even when the rest of the change waits for the renewal.
downgradenodelayedNoneApplies at next renewal.
upgrade or downgradeyesimmediateNonePlan changes now, nothing charged.

Proration

Charged only when all of these hold: prorate is true, the mode is immediate, the subscription is not in trial, its start date has passed, and the billing cycle is not changing. Coupons are taken into account on both sides.

Formula
proration = (new cycle amount - current cycle amount)
              x remaining days
              / total days in the term

cycle amount = each plan and addon line after its own coupon,
               less the subscription coupon
  • The invoice line is described as <plan name> - Proration Adjustment.
  • The current term end and next billing date do not move.
  • The amount is worked out on the whole subscription — the plan and every addon — so a new addon, a new addon plan and a new plan are all prorated the same way.

Adding an addon

Send the plan item and every addon to keep as they are, plus the new one. A new addon raises what a cycle costs, so it is an upgrade and applies now.

JSON body
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "prorate": true,
  "subscription_items": [
    { "item_type": "plan",  "item_id": 3210, "plan_id": 6 },
    { "item_type": "addon", "item_id": 3305, "plan_id": 12 },
    { "item_type": "addon", "item_id": 3306, "plan_id": 14 }
  ]
}
prorateWhat happens
trueThe addon goes on now, and a proration invoice is raised for its price over the days left in the term. From the next renewal it is billed in full with the plan.
false or left outThe addon goes on now with nothing charged today. The next renewal bills it in full.
In trial, or not startedThe addon goes on now and nothing is charged, whatever prorate says.

Show the amount before you save

Send the same body (without prorate) to Preview Proration: total_proration_amount is what prorate: true will invoice.

Example request

JSON body
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "prorate": true,
  "subscription_items": [
    { "item_type": "plan", "item_id": 3210, "plan_id": 6, "coupon_id": 7 },
    { "item_type": "addon", "item_id": 3305, "plan_id": 12 }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/subscriptions/update' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
    "prorate": true,
    "subscription_items": [
      { "item_type": "plan", "item_id": 3210, "plan_id": 6, "coupon_id": 7 },
      { "item_type": "addon", "item_id": 3305, "plan_id": 12 }
    ]
  }'

Example response

An addon added with prorate: true:

200 OK
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "business_entity_id": "...",
  "billing_cycle": "monthly",
  "customer": { "id": 16908, "email": "aarav@example.com", "name": "Aarav Mehta" },
  "billing_alignment_mode": "immediate",
  "effective_at": "2026-11-20T10:15:00Z",
  "prorate_invoice": { "id": 1190, "reference_no": "INV-00020" },
  "charge_invoice": [],
  "next_billing_at": "2026-12-05 00:00:00",
  "changes": [
    {
      "item_type": "addon",
      "billing_cycle": "monthly",
      "old_reference_id": null,
      "new_reference_id": 14,
      "old_unit_price": null,
      "new_unit_price": 300,
      "old_quantity": null,
      "new_quantity": 1,
      "change_type": "upgrade",
      "product_name": "Extra Storage"
    }
  ],
  "items": [ { "...": "every item with its coupon" } ],
  "discount": null
}
FieldWhat it is
billing_alignment_modeimmediate — the change has been applied now; delayed — it is stored and lands at the current term end. See how the mode is decided.
effective_atWhen the change applies: now for an immediate change, the current term end for a delayed one.
prorate_invoiceThe invoice raised now — the proration, or the whole new cycle when the billing cycle changes now — as id and reference_no. An empty [] when nothing was invoiced, and always on a delayed change.
charge_invoiceThe invoice for new charges, in the same shape. An empty [] when no charge was added.
next_billing_atThe next renewal. It does not move on a proration.
changesOne entry per item that changed: old and new plan (reference_id), price and quantity, upgrade or downgrade. A new item has the old_ fields null; one taken off has the new_ fields null.
items / discountEvery item as it stands now, with its coupon, and the coupon on the whole subscription. On a delayed change these are still the current ones — the change lands at the renewal.

Telling the customer when it applies

On billing_alignment_mode: delayed, show effective_at as the date the change lands; nothing is invoiced today, so prorate_invoice is empty.

Errors

ConditionStatusMessage
Nothing changes: same plan, prices, coupons, addons and cycle, and no new charge422Nothing to change on this subscription.
Not exactly one plan item422subscription_items needs exactly one plan item.
coupon_id or subscription_coupon_id is not a coupon422The selected coupon does not exist.
A new coupon is inactive422This coupon is no longer active.
Moving onto a plan that is inactive422The selected pricing plan is inactive and cannot be used.
A plan or addon plan has no price for the new billing cycle422The selected pricing plan has no price for the yearly billing cycle.
A new charge during the trial or before the start date422Charges are not applicable to a subscription with a trial or a future start date.
Addon or charge problems422The same messages as on create.
The plan item's item_id is not a product (for example an addon's id)422The selected plan item does not exist.
Plan not attached to the product422The selected pricing plan is not attached to this product.
Plan belongs to a different product422A subscription can only move between plans of the same product.
Subscription has no plan item422This subscription has no plan to update.
Unknown subscription, item or plan422Validation errors on the id fields.

Preview Proration

What a plan change will cost, before you commit to it.

POST/subscriptions/calculate-prorationX-Tenant + API Key required

Read-only. Nothing is saved and no invoice is created. Call this before update to show the customer what a change will cost — a new plan, a new addon, or a new plan on an addon.

Body parameters

FieldTypeRequiredDescription
subscription_codestringRequiredThe subscription being previewed.
subscription_itemsarrayRequiredThe whole list the subscription would have — the same items as on update, addons to keep included.
billing_cyclestringOptionalA new billing cycle, as on update. Leave it out to keep the current one.
cycle_change_atstringOptionalnow or term_end, as on update.
subscription_coupon_idintegerOptionalThe coupon on the whole subscription, as on update.

Do not send prorate

It does not affect the number.

What comes back when

The preview runs the same rules as update, so it always matches what update will actually do.

Situationproration_amount
Upgrade, not in trial, already startedThe calculated amount.
A new addon, not in trial, already startedThe addon's price over the days left. Its line has old_amount 0, since nothing was billed for it yet.
Downgrade, not in trial0 — the change lands at the next renewal.
In trial0 — nothing has been billed yet.
Start date is in the future0 — nothing has been billed yet.
The current term ends today0 — no days are left to charge for; the renewal bills the new price.
New billing cycle, now0 — full_cycle_invoice carries the amount billed for the whole new cycle instead.

Example request

JSON body
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "subscription_items": [
    { "item_type": "plan", "item_id": 3210, "plan_id": 6 },
    { "item_type": "addon", "item_id": 3305, "plan_id": 12 }
  ]
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/subscriptions/calculate-proration' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
    "subscription_items": [
      { "item_type": "plan", "item_id": 3210, "plan_id": 6 },
      { "item_type": "addon", "item_id": 3305, "plan_id": 12 }
    ]
  }'

Example response

200 OK
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "business_entity_id": "...",
  "effective_at": "2026-09-16T14:45:59Z",
  "billing_alignment_mode": "immediate",
  "total_proration_amount": 241.94,
  "items": [
    {
      "item_type": "plan",
      "reference_id": 5,
      "new_reference_id": 6,
      "old_amount": "699.0000000000",
      "new_amount": 1199,
      "quantity": 1,
      "unit_price": 1199,
      "proration_amount": 241.94,
      "change_type": "upgrade"
    },
    {
      "item_type": "addon",
      "reference_id": 12,
      "new_reference_id": 12,
      "old_amount": "199.0000000000",
      "new_amount": 199,
      "quantity": 1,
      "unit_price": 199,
      "proration_amount": 0,
      "change_type": "upgrade"
    }
  ],
  "remaining_days": 15,
  "total_days": 31,
  "full_cycle_invoice": null
}

A new addon shows up as its own line:

items[] — a new addon
{
  "item_type": "addon",
  "reference_id": 14,
  "new_reference_id": 14,
  "old_amount": 0,
  "new_amount": 300,
  "quantity": 1,
  "unit_price": 300,
  "proration_amount": 145.16,
  "change_type": "upgrade"
}

Response fields

FieldWhat it is
total_proration_amountWhat update with prorate: true would invoice now, after coupons. Show this one to the customer.
billing_alignment_modeimmediate — the change would apply now; renewal — it would wait for the term end, and nothing is charged today.
items[]One line per item sent: item_type (plan or addon), reference_id (its plan now; for a new addon, the plan it is added on), new_reference_id (its plan after), old_amount, new_amount, quantity, unit_price, proration_amount and change_type (upgrade or downgrade). A line's proration_amount is before coupons — the total is the number to use.
remaining_days / total_daysThe days left in the term and the days in it — the fraction the proration charges for. Both 0 when nothing is prorated.
full_cycle_invoiceOnly when the billing cycle changes now: amount, period_start and period_end of the invoice update would raise for the whole new cycle. null otherwise.
effective_atWhen the preview was worked out.

Errors

ConditionStatusMessage
Anything update would refuse422The same message update gives — see its errors above.

change_type is reported even when the amount is zero

It is upgrade or downgrade. Use it to tell the customer what kind of change they are making, and total_proration_amount to tell them what it costs — a zero amount does not mean nothing is changing.

Cancel a Subscription

End it now, or let it run to the end of the term.

POST/subscriptions/cancelX-Tenant + API Key required

Body parameters

FieldTypeRequiredDefaultNotes
subscription_codestringRequired——
cancel_typestringRequired—immediate or period_end.
cancel_atdateOptionalsee belowOverrides the default cancel date.
reasonstringOptional—Max 255 characters.

The two cancel types

immediateperiod_end
statuscancelled right awayUnchanged — the customer keeps access.
cancel_atnowThe current term end.
cancel_at_period_endfalsetrue
Renewal invoicesStoppedStopped
Auto-payDisabledDisabled

The recurring template is paused either way

No further renewal invoices are generated in either case. A period_end cancellation is finalised on its cancel date by a scheduled job, which flips the status to cancelled.

No refund, no credit note

Neither cancel type produces one. If money needs to go back, that happens outside these endpoints.

Example: cancel at the end of the term

JSON body
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "cancel_type": "period_end",
  "reason": "Customer request"
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/subscriptions/cancel' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
    "cancel_type": "period_end",
    "reason": "Customer request"
  }'

Example: cancel immediately

JSON body
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000002",
  "cancel_type": "immediate",
  "reason": "Test"
}

Example response

The response to the immediate cancellation above.

200 OK
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000002",
  "business_entity_id": "...",
  "status": "cancelled",
  "cancel_type": "immediate",
  "cancel_at": "2026-09-06 15:15:04",
  "cancel_at_period_end": false
}

Resume a Cancellation

Undo a cancellation and put the subscription back in service.

POST/subscriptions/cancel/reverseX-Tenant + API Key required

Undoes a cancellation and puts the subscription back into service.

Body parameters

FieldTypeRequiredDescription
subscription_codestringRequiredThe cancelled subscription.
reasonstringOptionalMax 255 characters.

What changes

  • status becomes active.
  • cancel_at is cleared and cancel_at_period_end becomes false.
  • The recurring template resumes and its next run date is recalculated.
  • Auto-pay is re-enabled.

A term that expired while cancelled is not replayed

If the term end has already passed, the recurring schedule restarts from today rather than generating the invoices that were missed.

Example request

JSON body
{
  "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
  "reason": "Customer changed their mind"
}
cURL
curl -X POST \
  'https://services.ap.mochatechnologies.com/quickbill/api/subscriptions/cancel/reverse' \
  -H "X-Tenant: $MOCHA_TENANT" \
  -H "API Key: $MOCHA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "subscription_code": "SUB-4E30EC0B-A218-42CE-B0A9-61E03B606739-000001",
    "reason": "Customer changed their mind"
  }'