---
name: ka-ching-api
description: Build tools and integrations against the Ka-ching POS REST API and import endpoints. Use when writing code that reads Ka-ching checkouts, customers, loyalty points, products, product assets, register close statement receipts or sales stats, or that imports data into Ka-ching; when the user mentions Ka-ching, developers.ka-ching.dk or a ka-ching-base cloudfunctions URL.
---

# Ka-ching API

Ka-ching is a cloud POS system. Its public APIs are plain HTTPS + JSON:

- **REST API** (`/rest/...`): read data from an account (checkouts, customers, loyalty points, products, receipts, stats).
- **Import endpoints** (`/imports/...`): push data into an account (products, stock, customers, ...). Processed asynchronously through import queues.
- **Webhooks / export integrations**: Ka-ching pushes sales, checkouts and register close statements to your server.

The full OpenAPI 3.1 spec is at <https://developers.ka-ching.dk/openapi/openapi-bundled.json>. Fetch it when you need exact schemas (for example the full `Checkout` model) or want to generate a client. All documentation is indexed for LLMs at <https://developers.ka-ching.dk/llms.txt>.

## Base URLs

| Region | Base URL |
|---|---|
| EU (preferred for European merchants) | `https://europe-west1-ka-ching-base.cloudfunctions.net` |
| US | `https://us-central1-ka-ching-base.cloudfunctions.net` |

Both regions serve the same data. REST paths start with `/rest/`, import paths with `/imports/`.

## Authentication

Every REST request needs:

- `account` **query parameter**: the Ka-ching account ID.
- A **REST API key**, either in the `X-API-Key` header (preferred) or the `apikey` query parameter.

REST API keys are created by the merchant in the Ka-ching back office under *Advanced → REST API*. They are **different from import queue API keys**: import endpoints take `account`, `integration` (the import queue ID) and `apikey` (an import queue key) as query parameters instead.

Never hard-code keys. Read them from the environment, for example `KACHING_ACCOUNT` and `KACHING_API_KEY`, and keep them out of version control and logs.

A missing or inactive key gives `401` with a plain-text body such as `Unauthorized - API key not active`.

## REST endpoints

All are `GET`. Details, parameters and response shapes: [references/rest-api.md](references/rest-api.md).

| Path | Returns |
|---|---|
| `/rest/checkouts?since=&shop=&limit=` | Checkouts, newest first. At most 500 per request (default 500). |
| `/rest/checkouts/{checkout_id}` | One checkout |
| `/rest/customer/{customer_id}` | One customer |
| `/rest/customer/{customer_id}/loyalty_points` | Loyalty point balances keyed by currency |
| `/rest/customer/{customer_id}/loyalty_points/{currency}` | Balance in one currency |
| `/rest/product/{product_id}?market=` | One product (default market `dk`) |
| `/rest/products?barcode=&limit=&market=` or `?search=&market=` | Products by barcode or free-text search |
| `/rest/product_assets/{product_id}` | Product images/documents (`[]` if none) |
| `/rest/receipts/register_close_statement/{id}?shop=&format=html\|pdf` | Rendered Z report |
| `/rest/stats/summary/market/{market_id}/{time_resolution}/{time_value}/{bucket}` | Sales key figures for a market |
| `/rest/stats/summary/shop/{shop_id}/all/{time_resolution}/{time_value}/{bucket}` | Sales key figures for a shop |

Stats need the right time formats and bucket names: see [references/stats.md](references/stats.md).

## Conventions that trip people up

- **404 has an empty body.** "Not found" (unknown ID, no stats for the period, malformed stats path) is a bare `404`. Treat it as "no data", not as an error to parse.
- **400 bodies are plain text**, for example `'limit' must be a positive integer`. `500` bodies are JSON `{"error": "..."}`.
- **Times are local to the shop.** `timing.timestamp_date_string` is `YYYY-MM-DD-HH-mm` in the shop's time zone; `timing.timestamp` is seconds since the Unix epoch (UTC). Stats periods use the shop's local calendar.
- **`since` is a string prefix comparison** on `timestamp_date_string`, so `2025-03`, `2025-03-14` and `2025-03-14-09` all work.
- **Paging checkouts**: there is no cursor. Request a day (or shorter) at a time with `since`, and if you get exactly `limit` results, narrow the window, because there may be more.
- **Amounts are numbers in the sale's base currency** (for example `199.95` DKK), not minor units.
- **Firestore timestamps** (for example `last_modified` on loyalty points) are serialized as `{"_seconds": 1741958961, "_nanoseconds": 565000000}`.
- **IDs**: shop, market and register IDs are not listed by the REST API. Get them from the merchant (back office) or from checkouts you have already read (`source.shop_id`, `source.market_id`).
- **Products are per market.** Pass `market` (default `dk`) when the merchant sells in several markets.

## How to work

1. Confirm with the user which account, region and API key variable to use, and what the tool should do with the data.
2. For anything beyond the summary above, read the relevant reference file, or fetch the OpenAPI spec and read the schema you need.
3. Write a small, typed client: one function per endpoint, a shared request helper that adds `account` and `X-API-Key`, maps `404` to "not found" (`nil`/`undefined`), and surfaces `400`/`401`/`500` with the response text. See [references/examples.md](references/examples.md) for TypeScript, Swift and cURL.
4. Be gentle with the API: no tight polling loops, reuse results, and fetch stats at the coarsest resolution that answers the question (one `month` request instead of 31 `day` requests).
5. To push data into Ka-ching, use the import endpoints. Read <https://developers.ka-ching.dk/import-integrations-overview.md> and the page for the entity type first.
