HaatlyOwner API v1

Haatly owner API

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.

  1. Go to Account → API tokens and create a token. Choose the businesses it can reach, whether it can only read or also make changes, and when it expires.
  2. Copy the token (shown once). Keep it secret — it acts as you.
  3. Send it with every request: 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 & limits

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 there
  • 429 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.

Google Sheets

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);
}

Account

GET/me

The token and its owner

GET/businesses

Businesses this token can reach

With your role and permissions in each.

Business

GET/businesses/{slug}

One business

GET/businesses/{slug}/shops

Connected shops

Use a shop id as the shop filter elsewhere.

Orders

GET/businesses/{slug}/orders

Orders

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.

QueryMeaning
statusOne or more, comma-separated: pending, confirmed, processing, shipped, delivered, returned, cancelled
shopA shop id, or "haatly" for orders entered in Haatly
fromFirst day (YYYY-MM-DD, business time zone)
toLast day (YYYY-MM-DD)
updated_sinceISO 8601 date-time
qCustomer name, phone or order number
pagePage number, from 1
per_pageUp to 100 (default 50)

GET/businesses/{slug}/orders/{id}

One order, with items and history

Item costs only with reports.view. Needs orders.view.

POST/businesses/{slug}/orders/{id}/status

Change 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 fieldMeaning
status requiredstring
notestring
restockPut items back in stock on return

Products & stock

GET/businesses/{slug}/products

Products with variants and stock

Costs only with reports.view. Needs products.view.

QueryMeaning
statusactive (default), draft, archived or all
shopA shop id, or "haatly"
low_stock"true" for products at or below their low-stock level
updated_sinceISO 8601 date-time
qName or SKU
pagePage number, from 1
per_pageUp to 100 (default 50)

POST/businesses/{slug}/products/{id}/variants/{variantId}/stock

Set or adjust stock

Only products managed in Haatly. Needs a write token and products.manage.

Body fieldMeaning
mode requiredset, add, remove
quantity requiredinteger
notestring

Customers

GET/businesses/{slug}/customers

Customers

One per phone number, with their order counts. Needs customers.view.

QueryMeaning
qName or phone
updated_sinceISO 8601 date-time
pagePage number, from 1
per_pageUp to 100 (default 50)

Reports & expenses

GET/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.

QueryMeaning
rangetoday, yesterday, this_week, last_week, 7d, 30d, month (default), last_month, year
fromFirst day (YYYY-MM-DD) — use with to instead of range
toLast day (YYYY-MM-DD)
shopA shop id, "haatly" or "business"

GET/businesses/{slug}/expenses

Expenses

Needs reports.view.

QueryMeaning
monthYYYY-MM
shopA shop id, or "business" for business-wide
categorycourier, ads, packaging, salaries, rent, software, returns, other

POST/businesses/{slug}/expenses

Add an expense

Needs a write token and expenses.manage.

Body fieldMeaning
spent_on requiredstring
category requiredcourier, ads, packaging, salaries, rent, software, returns, other
amount requirednumber
shopA shop id; leave out for the whole business
notestring