Authenticate with two headers, pick your environment, and make your first call to the Mocha QuickBill API. JSON in, JSON out, over plain REST.
What the Mocha QuickBill API is for.
As a business owner, you would want to design a seamless experience for your customers to subscribe to your business, improve the ease of making payments and create a consistent brand outlook. But building from scratch might require time, effort, and security worries.
With Mocha's advanced hosted pages solutions, you will now be able to easily set up subscription creation, management, and payments for your customers. Mocha Technologies is providing HTTP based APIs that follow the principles of REST. The HTTP rules followed allow simple HTTP clients like cURL to be used as well. The URLs are resource oriented and the responses are in JSON.
Depending on the type of operation, the endpoints use the following HTTP methods:
| Method | Used for |
|---|---|
GET | All read-only operations — fetching or retrieving data from the server, or listing a group of data. |
POST | All write operations. Sends data to the server to create a new resource. Such operations modify the state of a resource. |
PUT | Updates that change a resource in place rather than creating one — for example voiding an invoice. |
DELETE | All delete operations. Deletes a resource on the server. |
A history of changes to the API is provided in the API Changelog.
Five steps from a new account to your first invoice.
Sign up or log in to Mocha QuickBill
Generate an API key
Create your products and customers
POST /products and POST /customers, or read what you already have with GET /products and GET /customers.Raise the invoice
X-Tenant and API Key headers on every request. Confirm your credentials work with a read such as GET /products, take the next number from GET /invoices/get-invoice-number, then create the invoice with POST /invoices.Record the payment
POST /payments. Read the invoice back with GET /invoices/:id afterwards to see the new balance — the payment call does not return it.Two headers, on every single request.
Mocha QuickBill uses API key based authentication. Every request must carry both headers. There is no OAuth flow, no token exchange and no expiry to manage on your side.
| Header | Value | Where to find it |
|---|---|---|
X-Tenant | Your tenant identifier | Provided with your account; the organisation identifier your account belongs to |
API Key | The API key you generated | Your account settings (TODO: confirm exact path) |
Content-Type | application/json | On every request that sends a JSON body |
# Read your credentials from the environment - never paste an API key
# into a shell command, where it lands in your history and process list.
# export MOCHA_TENANT=...
# export MOCHA_API_KEY=...
curl -G \
'https://services.ap.mochatechnologies.com/quickbill/api/products' \
-H "X-Tenant: $MOCHA_TENANT" \
-H "API Key: $MOCHA_API_KEY" \
-H 'Content-Type: application/json' \
--data-urlencode 'page=1' \
--data-urlencode 'page_length=10' \
--data-urlencode 'search={}'A missing or invalid header is rejected before the request reaches the resource you asked for, so an authentication failure looks the same on every endpoint. Handle it in one place — the layer that adds the two headers — rather than in each call. The endpoint pages do not repeat it.
Every endpoint hangs off a single host.
All API paths are relative to this base URL:
https://services.ap.mochatechnologies.com/quickbill/apiKeep it in configuration rather than hard-coding it into each call, so a host change never means touching your integration code.
How requests and responses are shaped.
Mocha follows the REST model of exposing resources as URLs. For example, invoices are exposed as:
https://services.ap.mochatechnologies.com/quickbill/api/invoicesThe HTTP method like GET, POST and DELETE determines the operation type on the resource. Query parameters allow you to provide additional options to the GET requests. POST parameters provide the data to write operations like creation and modification of resources. DELETE is used to delete a resource on the server.
By default cURL uses the GET method. Use the -X option to specify a specific HTTP method. For passing parameters, use the -d option.
-d option. To send query parameters on a GET request, use -G.curl -G 'https://services.ap.mochatechnologies.com/quickbill/api/products' \
--data-urlencode 'page=1' \
--data-urlencode 'page_length=10' \
--data-urlencode 'search={}'search parameter — and some a sort — whose value is a JSON object sent as a string. Braces and quotes must be encoded, so use --data-urlencode as above rather than pasting raw JSON into a URL.The response is in JSON format. Currently Mocha does not support any other response format.
Every list endpoint wraps its results in a paged envelope — the records in data, with current_page, last_page, per_page and total describing the page. Where those paging fields sit is not the same everywhere: products nest them under a meta key, as above, while the other lists put them at the top level next to data. Read a single record by id and you get it on its own, with no envelope at all.
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={}'{
"data": [
{
"id": 6,
"name": "Premium Monthly",
"sku": "PRECNBRHWH",
"type": "service",
"description": "A Premium Monthly",
"tags": [],
"is_active": true
}
],
"meta": {
"current_page": 1,
"per_page": 10,
"last_page": 1,
"total": 6,
"from": 1,
"to": 6
}
}Compliant with OpenAPI v3.0.1.
Mocha Technologies supports the OpenAPI Specification, making it easier for developers to work with our APIs. The spec is compliant with OpenAPI v3.0.1, enabling customers to:
This is part of our commitment to providing a smoother, more efficient developer experience.
Try it, and tell us how it goes.
Explore how our solutions can make a difference. Try Mocha Technologies today and discover a new level of business freedom and insight.