GET/me
The token and its owner
Pull your orders, products, customers and reports into Google Sheets, accounting software or your own scripts — and add expenses or update Haatly-managed orders and stock. This is different from the sync API, which shops use to talk to Haatly.
Authorization: Bearer hk_pat_…Base address: https://haatly.shop/api/v1 · JSON in, JSON out · money is a number in the business's currency · times are ISO 8601 UTC · date filters (from, to) are days in the business's time zone.
curl https://haatly.shop/api/v1/businesses \
-H "Authorization: Bearer hk_pat_…"
A token can never do more than you can: it uses your current role in each business, so if your access changes, the token's does too. Costs and profit only appear if your role includes See reports, profit & loss.
Errors look like {"error": {"code": "validation_failed", "message": "…", "fields": {"status": "Invalid status"}}}.
401 missing, invalid, expired or revoked token · 403 read-only token or your role lacks the permission · 404 not found (or the token can't reach that business)402 plan_ended the business's Haatly plan has ended, so changes are refused (reading still works)409 managed_by_shop the order or product belongs to a connected shop — change it there429 more than 60 requests a minute for this token. The RateLimit headers show what's left.Lists are paged: ?page=2&per_page=100 → {"data": […], "page", "per_page", "total", "has_more"}. To sync only changes, pass updated_since with the last updated_at you stored.
In a sheet, open Extensions → Apps Script, paste this, put your token in Project settings → Script properties as HAATLY_TOKEN, and run loadOrders (or set a time trigger to refresh it every hour).
function loadOrders() {
const token = PropertiesService.getScriptProperties().getProperty('HAATLY_TOKEN');
const res = UrlFetchApp.fetch('https://haatly.shop/api/v1/businesses/YOUR-SLUG/orders?per_page=100', {
headers: { Authorization: 'Bearer ' + token },
});
const orders = JSON.parse(res.getContentText()).data;
const rows = orders.map(o => [o.number, o.placed_at, o.shop ? o.shop.name : 'Haatly', o.customer.name, o.status, o.total]);
const sheet = SpreadsheetApp.getActiveSheet();
sheet.clearContents();
sheet.appendRow(['Order', 'Placed', 'Shop', 'Customer', 'Status', 'Total']);
if (rows.length) sheet.getRange(2, 1, rows.length, rows[0].length).setValues(rows);
}
/meThe token and its owner
/businessesBusinesses this token can reach
With your role and permissions in each.
/businesses/{slug}One business
/businesses/{slug}/shopsConnected shops
Use a shop id as the shop filter elsewhere.
/businesses/{slug}/ordersOrders
Newest first. With updated_since, oldest change first — store the last updated_at you saw and pass it next time to fetch only changes. Needs orders.view.
| Query | Meaning |
|---|---|
status | One or more, comma-separated: pending, confirmed, processing, shipped, delivered, returned, cancelled |
shop | A shop id, or "haatly" for orders entered in Haatly |
from | First day (YYYY-MM-DD, business time zone) |
to | Last day (YYYY-MM-DD) |
updated_since | ISO 8601 date-time |
q | Customer name, phone or order number |
page | Page number, from 1 |
per_page | Up to 100 (default 50) |
/businesses/{slug}/orders/{id}One order, with items and history
Item costs only with reports.view. Needs orders.view.
/businesses/{slug}/orders/{id}/statusChange an order’s status
Only orders managed in Haatly (phone / WhatsApp orders) — shop orders change in their shop (409 managed_by_shop). Allowed moves are in next_statuses. Needs a write token and orders.manage.
| Body field | Meaning |
|---|---|
status required | string |
note | string |
restock | Put items back in stock on return |
/businesses/{slug}/productsProducts with variants and stock
Costs only with reports.view. Needs products.view.
| Query | Meaning |
|---|---|
status | active (default), draft, archived or all |
shop | A shop id, or "haatly" |
low_stock | "true" for products at or below their low-stock level |
updated_since | ISO 8601 date-time |
q | Name or SKU |
page | Page number, from 1 |
per_page | Up to 100 (default 50) |
/businesses/{slug}/products/{id}/variants/{variantId}/stockSet or adjust stock
Only products managed in Haatly. Needs a write token and products.manage.
| Body field | Meaning |
|---|---|
mode required | set, add, remove |
quantity required | integer |
note | string |
/businesses/{slug}/customersCustomers
One per phone number, with their order counts. Needs customers.view.
| Query | Meaning |
|---|---|
q | Name or phone |
updated_since | ISO 8601 date-time |
page | Page number, from 1 |
per_page | Up to 100 (default 50) |
/businesses/{slug}/reports/{kind}A report: sales, profit, products, shops or expenses
The same reports as on the Reports page: highlights, sections (columns + rows + total) and notes. Needs reports.view.
| Query | Meaning |
|---|---|
range | today, yesterday, this_week, last_week, 7d, 30d, month (default), last_month, year |
from | First day (YYYY-MM-DD) — use with to instead of range |
to | Last day (YYYY-MM-DD) |
shop | A shop id, "haatly" or "business" |
/businesses/{slug}/expensesExpenses
Needs reports.view.
| Query | Meaning |
|---|---|
month | YYYY-MM |
shop | A shop id, or "business" for business-wide |
category | courier, ads, packaging, salaries, rent, software, returns, other |
/businesses/{slug}/expensesAdd an expense
Needs a write token and expenses.manage.
| Body field | Meaning |
|---|---|
spent_on required | string |
category required | courier, ads, packaging, salaries, rent, software, returns, other |
amount required | number |
shop | A shop id; leave out for the whole business |
note | string |