API basics
Smarton has a JSON API over HTTPS. It is the same API the Smarton web app and POS use, so almost everything you see in Smarton can be read through it. This page explains what every integration needs: how to get access, how to read lists, how to filter them, how to fetch only what changed, and the limits. The other API pages describe the data of each area.
Every company has its own address: https://{company}.smarton.app. All API paths start with /api/.
Which data is where
| Data | Resources | Page |
|---|---|---|
| Sales receipts, lines, discounts, VAT, cost | order, order_product | Orders API |
| Payments, split payments, refunds | account_registry, account_registry_payment, payment_type | Orders API |
| Deleted orders and removed items | order, order_product with _deleted=1 | Orders API |
| POS devices, tables, zones, cash in/out, X and Z reports | device, order_consumer, area, fiscal_report_log | POS API |
| Articles (menu items), categories, prices, cost, recipes | article, article_category, article_material | Technology API |
| Employees | employee | Staff API |
| Work shifts, work schedule, entrance records | workshift, employee_workshift, employee_schedule_entry, entrance_log | Staff API |
| Customers and their contact persons | customer, customer_employee | Customers API |
| Table reservations | consumer_booking | Reservations API |
| Materials, suppliers, purchases, stock, write-offs, warehouses | material, supplier, purchase, material_quant, material_quant_event, warehouse | Materials API |
| Inventory: items, types, categories, stock, purchases, tests, tags | material with stock==inventory, material_type, material_category, material_test, inventory_tag | Inventory API |
| Accounting entries, chart of accounts, balance, sales invoices, payments, bank transactions, fixed assets | general_ledger_record, account_category, invoice, payment, bank_transaction, assets | Accounting API |
Access
There are two ways to call the API:
- Way 1: log in as a user. The integration logs in with a username and password or a personal access token, gets a session token and sends it with every request. It sees the same data as that user.
- Way 2: API key. The integration sends an API key with every request, without logging in. The key can read only the data areas ticked when it was created, and it can be revoked at any time.
In the examples on these pages, Authorization: <token> stands for either the session token (way 1) or Bearer and the API key (way 2).
Way 1: log in as a user
Create a separate Smarton user for the integration (Staff → Employees, the employee's user account). Then you can see what it does and switch it off at any time. The integration sees the same data as this user. For sales data the user must see all orders, so make it an administrator or give it the permission to view all orders.
Log in with a username and password
POST /api/login Content-Type: application/x-www-form-urlencoded _username=integration&_password=…
The response is JSON. Its token field is the session token:
{ "token": "12/34/5f2c…", "ttl": 86400, "namespace": "company", … }
Send the token in the Authorization header of every request:
Authorization: 12/34/5f2c…
- The session stays valid while you use it. It ends after
ttlseconds without requests (24 hours by default). When you get401, log in again. - A token works only on the address where it was issued.
- Three wrong passwords in a row lock the user for 5 minutes.
Log in with a personal access token
Instead of a password, the integration user can create a personal access token: in Smarton, click the user's picture → User account → Personal access token → Create. Exchange it for a session token with the same login call:
POST /api/login Content-Type: application/x-www-form-urlencoded _token=…
Then use the returned token as above. Keep the personal access token secret and send it only in the body of the login request, never in a URL. It does not expire. To stop it, clear it in the user account; sessions already started from it end when their time runs out.
Way 2: API key
An API key works as the person who created it, but only for the data areas ticked when it was created. Everything else is refused, so a key can be given to another company without giving it access to the whole of Smarton.
Create a key
- In Smarton, open Settings → Integrations → API keys. You need the permissions to edit the system options (to open Integrations) and API key. When API keys were added, everyone who could edit the system options got the API key permission.
- Click + and enter a name, for example the name of the program that will use the key.
- Tick what the key may access (see the table below). Optionally, set the date when the key stops working.
- Click Create and copy the key. It starts with
smk_and is shown only once: Smarton keeps only a hash of it. If the key is lost, revoke it and create a new one.
The key works as you: it sees only what you can see in Smarton, limited to the ticked areas. For sales data you must see all orders, so create the key as an administrator or as a user with the permission to view all orders. If your login is switched off, the key stops working too.
| Area | What the key can do |
|---|---|
| Sales | Read order, order_product, product, product_parameter, account_registry, account_registry_payment, invoice, order_consumer. |
| POS | Read device, area, order_consumer, fiscal_report_log. |
| Products | Read article, article_category, article_material, article_type, parameter, dropdown_option. |
| Staff | Read employee, specialisation, role. Persons can be joined (for example createdBy) but not listed. |
| Customers | Read customer, customer_employee. |
| Purchasing and stock | Read supplier, material_supplier, purchase, product, material, material_type, material_category, material_quant, material_quant_event, warehouse, warehouse_location, payment. |
| Accounting | Read general_ledger_record, account_category, bank_transaction, payment. |
| Send purchase documents | Create, confirm and receive purchase documents: POST /api/purchase/create, /api/purchase/create_with_positions, /api/purchase/update, /api/purchase/receive and /api/material_quant/purchase (see Materials API). Also turns on Purchasing and stock, and Products. |
Every key can also read the lookups vat, currency, payment_type, tag, file, country and region.
Use the key
Send the key in the Authorization header of every request, after Bearer:
curl -g -G 'https://{company}.smarton.app/api/order/search' \
-H 'Authorization: Bearer smk_…' \
--data-urlencode 'paginate=true' \
--data-urlencode 'limit=200'
- A key can call only
GET /api/{resource}/searchand/getfor the resources of its areas, plus the addresses of Send purchase documents. Joins, filters and sorting may only go into these resources too:join[]=manageron orders needs Staff,join[]=customerneeds Customers. - Anything else is refused with
403and a message, for example{"message": "This API key cannot read customer"}. - With a key, personal data is left out of employees and other persons: personal codes, passport details, dates of birth, bank details, contract numbers, salary sums and similar fields. Users and salaries cannot be read at all.
- A wrong, expired or revoked key gets
401with{"message": "Invalid API key"}. - Send the key only in the header, never in a URL, and keep it secret like a password.
Manage keys
The list in Settings → Integrations → API keys shows each key's name, its last four characters, what it can access, who it acts as and who created it, when and from which IP address it was last used (updated at most every 5 minutes), its expiry date and status: Active, Expired or Revoked. To stop a key, click the revoke button in its row. Programs that use it get 401 from the next request.
Reading lists
GET /api/{resource}/search?…
GET /api/{resource}/get?id=123
| Parameter | What it does |
|---|---|
paginate=true | Returns {"length": …, "total": …, "data": [ … ]}: the rows of this page and the total number of rows. |
limit, offset | Page size and start. There is no default and no maximum: always send a limit, for example 200–500. |
sort[field]=asc | Sort order. There is no default order, so sort by id or a date when you page through a list. |
join[]=relation | Includes a related record in full, for example join[]=customer. Nested: join[]=product.article. |
partialJoin[relation][]=field | Includes only some fields of a related record, for example partialJoin[customer][]=name. |
select[]=field | Returns only these fields of the main record. id is always included. |
count=1 | Returns only {"count": …}. |
- Related records you don't join are left out of the response completely, even their IDs. To get only the ID, use
partialJoin[customer][]=id. - Amounts come as
{"amount": 12.5, "currency": "EUR"}. - Dates and times are in UTC, for example
2026-10-09T18:20:00Z. - Joining two lists of children in one request (for example lines and payments of orders) multiplies the rows. Fetch them in separate requests.
- Field names and types of a resource:
GET /api/public/metadata/{resource}.
Filters
Every other parameter filters by a field: ?status==complete&numberOfVisitors=>2. Fields of related records work too: order.finishedAt. Filter a related record by its ID: customer.id=5.
| Value | Meaning |
|---|---|
abc | Text contains abc. |
=abc | Text is exactly abc. |
!abc, !=abc | Does not contain abc, is not abc. |
5, >5, >=5, <5, <=5, !5 | Number comparisons. |
a|b | a or b. For numbers: one of the values. |
>=2026-10-01T00:00:00Z&<2026-11-01T00:00:00Z | A date range. Always send full UTC times ending in Z. |
-, !- | Empty, not empty. |
1, 0 | Yes or no fields. |
URL-encode the values: & inside a value is %26, = is %3D, + is %2B. With curl, -G and --data-urlencode do this for you:
curl -g -G 'https://{company}.smarton.app/api/order/search' \
-H 'Authorization: <token>' \
--data-urlencode 'paginate=true' \
--data-urlencode 'limit=200' \
--data-urlencode 'offset=0' \
--data-urlencode 'status==complete' \
--data-urlencode 'finishedAt=>=2026-10-01T00:00:00Z&<2026-11-01T00:00:00Z' \
--data-urlencode 'sort[finishedAt]=asc'
A field name that does not exist is ignored without an error, so a typo returns the unfiltered list. Check the field names with the metadata call above.
Getting only changes and deletions
After the first full load, fetch only what changed since your last run.
- New and changed records:
updatedAtis set when a record is changed and stays empty until then. Ask for both:search[createdAt]=>=T&search[updatedAt]=>=T, where T is the time of your last run. Conditions insearch[…]are combined with "or". - Deleted records: deleted records are hidden from lists.
_deleted=1returns only deleted records, withdeleted: trueanddeletedAt:_deleted=1&deletedAt=>=T. Leave the parameter out for normal lists. - Lines are separate records. A changed order line does not change the order's
updatedAt. Fetch lines with their ownupdatedAt. - Lists without these fields. Some records are deleted without a trace (for example accounting entries and invoices), and some lists have no
updatedAt(for example suppliers). Load these lists in full from time to time and compare the IDs.
Several locations
A company with several locations (units) has a main address and an address for each unit. The main address returns the data of all units; each record has a namespace field with its unit. To get one unit, filter by it: namespace==vilnius. GET /api/public/system_options lists the units in namespaces. A session token works only on the address where you logged in.
Limits
- There is no fixed request quota, but every company runs on a small number of workers that also serve its POS and staff. Make one request at a time, at most two in parallel.
- A request stops after about 2 minutes, and a database query after 60 seconds. Split large periods into days or weeks and page through them.
- Run the regular sync every few minutes or less often, and the first full load outside working hours.
Writing data
Most records are created, changed and removed with the same three calls. They need a login (way 1) with the permission to create, edit or remove that kind of record. API keys cannot use them: a key can only send purchase documents. When an area page describes its own calls, for example POS orders or purchase documents, use those.
POST /api/{resource}/create the fields of the new record
POST /api/{resource}/update id and the fields to change
POST /api/{resource}/remove id
- Send the fields as form data (
application/x-www-form-urlencoded) or as a JSON body. The field names are the same as in the lists. - Set a related record by its ID:
customer=5. Send an amount as two fields:price[amount]=12.5&price[currency]=EUR. createanswers{"status": 1, "message": "info.created", "data": 123}, wheredatais the new ID.updateanswersinfo.updated,removeanswersinfo.removed.updateandremovealso take several IDs:id[]=1&id[]=2makes the same change to all of them.removemarks the record as deleted when it keeps a deleted flag; it then appears with_deleted=1. Other records are removed for good.
Errors
| Status | Meaning | Body |
|---|---|---|
200 | Done. | The data. Writes answer {"status": 1, …}. |
400 | The request cannot be done: the record is not found, a value is wrong, or the user has no permission. | Type, message and details, for example ["E_USER_ERROR", "Not found", {}] or ["E_USER_WARNING", "No permission for", ["order.view"]]. |
401 | Not logged in, the session has ended, or the API key is wrong, expired or revoked. | Log in again or check the key. For a key: {"message": "Invalid API key"}. |
403 | The API key cannot reach this data or address. | {"message": "This API key cannot read customer"} |
500 and other 5xx | An error on the server. | May not be JSON. Wait and repeat the request a few times. If it keeps failing, send Smarton the time, the address and the parameters of the request. |
A field name that does not exist is ignored in filters (see Filters), but gives an error in select[].
Notifications about changes
Smarton does not send webhooks or other notifications to integrations. Fetch the changes regularly, as described in Getting only changes and deletions.
Changes to the API
This is the API the Smarton apps use, and it has no versions. New resources and fields are added as Smarton grows, and fields can change with updates. Read fields by name, ignore fields you do not know, and check the field list with the metadata call when something stops working.
Test environment and terms
To build and test an integration, ask Smarton for a test company (sandbox) with demo data. Integration terms and pricing are agreed with Smarton: contact our sales team.
English