API reference
The API is in development and may change before the first release. This page is generated from the interface contracts in
contracts/; tests check that every route listed here exists in the implementation.
The public REST API is the Supabase edge function api.
- Base URL:
{SUPABASE_URL}/functions/v1/api/v1, e.g.https://merkora.example.com/functions/v1/api/v1. - Auth:
Authorization: Bearer mk_live_…with an org API key, or a Supabase user JWT (the control-center UI). A user who belongs to several orgs picks one withX-Merkora-Org: <org id>. - Roles: every route needs a minimum org role:
viewer<operator<admin(<owner). API key scopes map to roles:read→ viewer,write→ operator,admin→ admin. - Errors: non-2xx answers carry
{ "error": { "code", "message", "details"? } }. Codes: error codes. - Lists are cursor-paginated:
?limit=50&cursor=…→{ items, next_cursor };next_cursorisnullon the last page. - Async commands answer
202with{ request_id, queued: true }. They usually finish with an event carrying the samerequest_id(GET /events;led.done,content.displayedand the finalcontent.failedalso as webhooks), but not always: a request replaced by a newer one for the same label while queued gets no event, content the label already shows produces none, and a command the server could not deliver to its bridge is only recorded as failed. Track content bylabel_idandcontent_hash(seePUT /labels/{id}/content). - CORS is open (
Access-Control-Allow-Origin: *); authentication is by header only.
Endpoints
| Method | Path | Role | Summary |
|---|---|---|---|
| GET | /labels | viewer | List the labels of the org, ordered by id. |
| GET | /labels/{id} | viewer | One label with its binding and current desired content. |
| PATCH | /labels/{id} | operator | Rename a label or move it to another site. |
| PUT | /labels/{id}/binding | operator | Bind a label to an entity and resolve its content now. |
| DELETE | /labels/{id}/binding | operator | Unbind a label. It keeps its last image. |
| PUT | /labels/{id}/content | operator | Show static content on a label (manual labels, signage). |
| POST | /labels/{id}/led | operator | Flash the LED of one label. |
| POST | /locate | operator | Flash every label bound to an entity. |
| POST | /refresh | operator | Re-resolve bindings now, e.g. after bulk ERP changes. The empty JSON object {} re-resolves the whole org. |
| GET | /templates | viewer | List the templates of the org, ordered by name. |
| GET | /templates/{id} | viewer | One template version, the current one unless ?version= is given. |
| GET | /events | viewer | The event log, newest first (by at, then by id). |
| GET | /webhooks | admin | List outbound webhook subscriptions. |
| POST | /webhooks | admin | Subscribe a URL to events. The signing secret is returned once. |
| DELETE | /webhooks/{id} | admin | Delete a webhook subscription. |
GET /labels
List the labels of the org, ordered by id.
Minimum role: viewer. Success: 200.
| Query parameter | Meaning |
|---|---|
site_id | only labels of this site |
status | only labels with this status |
q | substring of the name or the BLE address |
limit | 1–200, default 50 |
cursor | next_cursor of the previous page |
Response (200)
| Field | Type | Required | Description |
|---|---|---|---|
items | array of object | yes | |
items[].id | uuid | yes | |
items[].site_id | uuid | yes | |
items[].hw_address | string ^([0-9A-F]{2}:){5}[0-9A-F]{2}$ | yes | |
items[].model | m29-bw | m29-bwry | m42-bwry | yes | |
items[].driver | merkora-ble | sim | yes | |
items[].name | string ≤ 120 chars | null | yes | |
items[].status | new | provisioning | online | offline | error | yes | |
items[].ap_hw_id | string ^[0-9a-f]{12}$ | null | yes | AP the label is currently synced to, as reported by the bridge. |
items[].battery_mv | integer | null | yes | |
items[].rssi | integer | null | yes | |
items[].fw_version | string | null | yes | |
items[].displayed_hash | string | null | yes | content_hash the label is confirmed to show. |
items[].last_seen_at | RFC 3339 date-time | null | yes | |
next_cursor | string | null | yes |
Example response:
{
"items": [
{
"id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"site_id": "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
"hw_address": "C4:7A:12:00:3F:9E",
"model": "m42-bwry",
"driver": "merkora-ble",
"name": "KIT 164",
"status": "online",
"ap_hw_id": "a0b1c2d3e4f5",
"battery_mv": 2980,
"rssi": -61,
"fw_version": "0.3.0",
"displayed_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"last_seen_at": "2026-10-20T08:15:00Z"
}
],
"next_cursor": null
}
GET /labels/{id}
One label with its binding and current desired content.
Minimum role: viewer. Success: 200.
Response (200): LabelDetail
| Field | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | |
site_id | uuid | yes | |
hw_address | string ^([0-9A-F]{2}:){5}[0-9A-F]{2}$ | yes | |
model | m29-bw | m29-bwry | m42-bwry | yes | |
driver | merkora-ble | sim | yes | |
name | string ≤ 120 chars | null | yes | |
status | new | provisioning | online | offline | error | yes | |
ap_hw_id | string ^[0-9a-f]{12}$ | null | yes | AP the label is currently synced to, as reported by the bridge. |
battery_mv | integer | null | yes | |
rssi | integer | null | yes | |
fw_version | string | null | yes | |
displayed_hash | string | null | yes | content_hash the label is confirmed to show. |
last_seen_at | RFC 3339 date-time | null | yes | |
binding | object | null | yes | |
binding.id | uuid | yes | |
binding.label_id | uuid | yes | |
binding.entity | object | yes | |
binding.entity.system | string 1–32 chars | yes | |
binding.entity.connection_id | uuid | no | |
binding.entity.doctype | string 1–140 chars | yes | |
binding.entity.name | string 1–140 chars | yes | |
binding.template_id | uuid | yes | |
binding.empty_template_id | uuid | null | yes | |
binding.resolver | one of the variants below | yes | |
binding.resolver with kind = "erpnext-doc" | variant | – | |
binding.resolver.kind | "erpnext-doc" | yes | |
binding.resolver.fields | array of string, ≥ 1 items | yes | |
binding.resolver.map | object of string | no | |
binding.resolver.lookups | array of object | no | |
binding.resolver.lookups[].key | string | yes | |
binding.resolver.lookups[].doctype | string | yes | |
binding.resolver.lookups[].filters | array of string, string, any | yes | |
binding.resolver.lookups[].field | string | no | |
binding.resolver.lookups[].aggregate | first | count | no | Default "first". |
binding.resolver.lookups[].order_by | string | no | |
binding.resolver.transforms | array of object | no | |
binding.resolver.transforms[].key | string | yes | |
binding.resolver.transforms[].from | string | no | |
binding.resolver.transforms[].ops | array of one of the variants below, ≥ 1 items | yes | |
binding.resolver.transforms[].ops[] with kind = "date" | variant | – | |
binding.resolver.transforms[].ops[].kind | "date" | yes | |
binding.resolver.transforms[].ops[].format | string | no | Default "DD.MM.YYYY". |
binding.resolver.transforms[].ops[] with kind = "replace" | variant | – | |
binding.resolver.transforms[].ops[].kind | "replace" | yes | |
binding.resolver.transforms[].ops[].pattern | string | yes | |
binding.resolver.transforms[].ops[].flags | string | no | |
binding.resolver.transforms[].ops[].replacement | string | no | Default "". |
binding.resolver.transforms[].ops[] with kind = "match" | variant | – | |
binding.resolver.transforms[].ops[].kind | "match" | yes | |
binding.resolver.transforms[].ops[].cases | array of object, ≥ 1 items | yes | |
binding.resolver.transforms[].ops[].cases[].pattern | string | yes | |
binding.resolver.transforms[].ops[].cases[].value | string | yes | |
binding.resolver.transforms[].ops[].default | string | no | |
binding.resolver.transforms[].ops[] with kind = "upper" | variant | – | |
binding.resolver.transforms[].ops[].kind | "upper" | yes | |
binding.resolver.transforms[].ops[] with kind = "lower" | variant | – | |
binding.resolver.transforms[].ops[].kind | "lower" | yes | |
binding.resolver.transforms[].ops[] with kind = "trim" | variant | – | |
binding.resolver.transforms[].ops[].kind | "trim" | yes | |
binding.resolver with kind = "erpnext-query" | variant | – | |
binding.resolver.kind | "erpnext-query" | yes | |
binding.resolver.doctype | string | yes | |
binding.resolver.filters | array of string, string, any | yes | |
binding.resolver.fields | array of string, ≥ 1 items | yes | |
binding.resolver.order_by | string | no | |
binding.resolver.map | object of string | no | |
binding.resolver.lookups | array of object | no | |
binding.resolver.lookups[].key | string | yes | |
binding.resolver.lookups[].doctype | string | yes | |
binding.resolver.lookups[].filters | array of string, string, any | yes | |
binding.resolver.lookups[].field | string | no | |
binding.resolver.lookups[].aggregate | first | count | no | Default "first". |
binding.resolver.lookups[].order_by | string | no | |
binding.resolver.transforms | array of object | no | |
binding.resolver.transforms[].key | string | yes | |
binding.resolver.transforms[].from | string | no | |
binding.resolver.transforms[].ops | array of one of the variants below, ≥ 1 items | yes | |
binding.resolver.transforms[].ops[] with kind = "date" | variant | – | |
binding.resolver.transforms[].ops[].kind | "date" | yes | |
binding.resolver.transforms[].ops[].format | string | no | Default "DD.MM.YYYY". |
binding.resolver.transforms[].ops[] with kind = "replace" | variant | – | |
binding.resolver.transforms[].ops[].kind | "replace" | yes | |
binding.resolver.transforms[].ops[].pattern | string | yes | |
binding.resolver.transforms[].ops[].flags | string | no | |
binding.resolver.transforms[].ops[].replacement | string | no | Default "". |
binding.resolver.transforms[].ops[] with kind = "match" | variant | – | |
binding.resolver.transforms[].ops[].kind | "match" | yes | |
binding.resolver.transforms[].ops[].cases | array of object, ≥ 1 items | yes | |
binding.resolver.transforms[].ops[].cases[].pattern | string | yes | |
binding.resolver.transforms[].ops[].cases[].value | string | yes | |
binding.resolver.transforms[].ops[].default | string | no | |
binding.resolver.transforms[].ops[] with kind = "upper" | variant | – | |
binding.resolver.transforms[].ops[].kind | "upper" | yes | |
binding.resolver.transforms[].ops[] with kind = "lower" | variant | – | |
binding.resolver.transforms[].ops[].kind | "lower" | yes | |
binding.resolver.transforms[].ops[] with kind = "trim" | variant | – | |
binding.resolver.transforms[].ops[].kind | "trim" | yes | |
binding.resolver with kind = "static" | variant | – | |
binding.resolver.kind | "static" | yes | |
binding.resolver.data | object (any keys) | yes | |
content | object | null | yes | |
content.template_id | uuid | yes | |
content.content_hash | string | yes | |
content.updated_at | string | yes | |
content.data | object (any keys) | yes |
Example response:
{
"id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"site_id": "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
"hw_address": "C4:7A:12:00:3F:9E",
"model": "m42-bwry",
"driver": "merkora-ble",
"name": "KIT 164",
"status": "online",
"ap_hw_id": "a0b1c2d3e4f5",
"battery_mv": 2980,
"rssi": -61,
"fw_version": "0.3.0",
"displayed_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"last_seen_at": "2026-10-20T08:15:00Z",
"binding": {
"id": "7e8f9a0b-1c2d-4e3f-9a4b-5c6d7e8f9a0b",
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"entity": {
"system": "erpnext",
"doctype": "Warehouse",
"name": "KIT 164 - DEMO"
},
"template_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"empty_template_id": null,
"resolver": {
"kind": "erpnext-query",
"doctype": "Work Order",
"filters": [
["kitting_box", "=", "{{entity.name}}"],
[
"status",
"in",
["Not Started", "In Process"]
]
],
"fields": ["name", "production_item", "item_name", "qty", "expected_delivery_date"],
"map": {
"due": "expected_delivery_date"
},
"transforms": [
{
"key": "due",
"ops": [
{
"kind": "date",
"format": "DD.MM."
}
]
}
]
}
},
"content": {
"template_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"content_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"updated_at": "2026-10-20T08:14:52Z",
"data": {
"name": "WO-26-00482",
"item_name": "Controller board"
}
}
}
PATCH /labels/{id}
Rename a label or move it to another site.
Minimum role: operator. Success: 200.
Request body: { name?: string | null, site_id?: uuid }. Changing site_id needs the admin role.
Response (200): Label
| Field | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | |
site_id | uuid | yes | |
hw_address | string ^([0-9A-F]{2}:){5}[0-9A-F]{2}$ | yes | |
model | m29-bw | m29-bwry | m42-bwry | yes | |
driver | merkora-ble | sim | yes | |
name | string ≤ 120 chars | null | yes | |
status | new | provisioning | online | offline | error | yes | |
ap_hw_id | string ^[0-9a-f]{12}$ | null | yes | AP the label is currently synced to, as reported by the bridge. |
battery_mv | integer | null | yes | |
rssi | integer | null | yes | |
fw_version | string | null | yes | |
displayed_hash | string | null | yes | content_hash the label is confirmed to show. |
last_seen_at | RFC 3339 date-time | null | yes |
PUT /labels/{id}/binding
Bind a label to an entity and resolve its content now.
Minimum role: operator. Success: 200.
Request body: PutBindingRequest
| Field | Type | Required | Description |
|---|---|---|---|
entity | object | yes | |
entity.system | string 1–32 chars | yes | |
entity.connection_id | uuid | no | |
entity.doctype | string 1–140 chars | yes | |
entity.name | string 1–140 chars | yes | |
template_id | uuid | yes | |
empty_template_id | uuid | null | yes | |
resolver | one of the variants below | yes | |
resolver with kind = "erpnext-doc" | variant | – | |
resolver.kind | "erpnext-doc" | yes | |
resolver.fields | array of string, ≥ 1 items | yes | |
resolver.map | object of string | no | |
resolver.lookups | array of object | no | |
resolver.lookups[].key | string | yes | |
resolver.lookups[].doctype | string | yes | |
resolver.lookups[].filters | array of string, string, any | yes | |
resolver.lookups[].field | string | no | |
resolver.lookups[].aggregate | first | count | no | Default "first". |
resolver.lookups[].order_by | string | no | |
resolver.transforms | array of object | no | |
resolver.transforms[].key | string | yes | |
resolver.transforms[].from | string | no | |
resolver.transforms[].ops | array of one of the variants below, ≥ 1 items | yes | |
resolver.transforms[].ops[] with kind = "date" | variant | – | |
resolver.transforms[].ops[].kind | "date" | yes | |
resolver.transforms[].ops[].format | string | no | Default "DD.MM.YYYY". |
resolver.transforms[].ops[] with kind = "replace" | variant | – | |
resolver.transforms[].ops[].kind | "replace" | yes | |
resolver.transforms[].ops[].pattern | string | yes | |
resolver.transforms[].ops[].flags | string | no | |
resolver.transforms[].ops[].replacement | string | no | Default "". |
resolver.transforms[].ops[] with kind = "match" | variant | – | |
resolver.transforms[].ops[].kind | "match" | yes | |
resolver.transforms[].ops[].cases | array of object, ≥ 1 items | yes | |
resolver.transforms[].ops[].cases[].pattern | string | yes | |
resolver.transforms[].ops[].cases[].value | string | yes | |
resolver.transforms[].ops[].default | string | no | |
resolver.transforms[].ops[] with kind = "upper" | variant | – | |
resolver.transforms[].ops[].kind | "upper" | yes | |
resolver.transforms[].ops[] with kind = "lower" | variant | – | |
resolver.transforms[].ops[].kind | "lower" | yes | |
resolver.transforms[].ops[] with kind = "trim" | variant | – | |
resolver.transforms[].ops[].kind | "trim" | yes | |
resolver with kind = "erpnext-query" | variant | – | |
resolver.kind | "erpnext-query" | yes | |
resolver.doctype | string | yes | |
resolver.filters | array of string, string, any | yes | |
resolver.fields | array of string, ≥ 1 items | yes | |
resolver.order_by | string | no | |
resolver.map | object of string | no | |
resolver.lookups | array of object | no | |
resolver.lookups[].key | string | yes | |
resolver.lookups[].doctype | string | yes | |
resolver.lookups[].filters | array of string, string, any | yes | |
resolver.lookups[].field | string | no | |
resolver.lookups[].aggregate | first | count | no | Default "first". |
resolver.lookups[].order_by | string | no | |
resolver.transforms | array of object | no | |
resolver.transforms[].key | string | yes | |
resolver.transforms[].from | string | no | |
resolver.transforms[].ops | array of one of the variants below, ≥ 1 items | yes | |
resolver.transforms[].ops[] with kind = "date" | variant | – | |
resolver.transforms[].ops[].kind | "date" | yes | |
resolver.transforms[].ops[].format | string | no | Default "DD.MM.YYYY". |
resolver.transforms[].ops[] with kind = "replace" | variant | – | |
resolver.transforms[].ops[].kind | "replace" | yes | |
resolver.transforms[].ops[].pattern | string | yes | |
resolver.transforms[].ops[].flags | string | no | |
resolver.transforms[].ops[].replacement | string | no | Default "". |
resolver.transforms[].ops[] with kind = "match" | variant | – | |
resolver.transforms[].ops[].kind | "match" | yes | |
resolver.transforms[].ops[].cases | array of object, ≥ 1 items | yes | |
resolver.transforms[].ops[].cases[].pattern | string | yes | |
resolver.transforms[].ops[].cases[].value | string | yes | |
resolver.transforms[].ops[].default | string | no | |
resolver.transforms[].ops[] with kind = "upper" | variant | – | |
resolver.transforms[].ops[].kind | "upper" | yes | |
resolver.transforms[].ops[] with kind = "lower" | variant | – | |
resolver.transforms[].ops[].kind | "lower" | yes | |
resolver.transforms[].ops[] with kind = "trim" | variant | – | |
resolver.transforms[].ops[].kind | "trim" | yes | |
resolver with kind = "static" | variant | – | |
resolver.kind | "static" | yes | |
resolver.data | object (any keys) | yes |
Response (200): Binding. The Binding plus refresh, the outcome of the immediate re-resolution.
| Field | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | |
label_id | uuid | yes | |
entity | object | yes | |
entity.system | string 1–32 chars | yes | |
entity.connection_id | uuid | no | |
entity.doctype | string 1–140 chars | yes | |
entity.name | string 1–140 chars | yes | |
template_id | uuid | yes | |
empty_template_id | uuid | null | yes | |
resolver | one of the variants below | yes | |
resolver with kind = "erpnext-doc" | variant | – | |
resolver.kind | "erpnext-doc" | yes | |
resolver.fields | array of string, ≥ 1 items | yes | |
resolver.map | object of string | no | |
resolver.lookups | array of object | no | |
resolver.lookups[].key | string | yes | |
resolver.lookups[].doctype | string | yes | |
resolver.lookups[].filters | array of string, string, any | yes | |
resolver.lookups[].field | string | no | |
resolver.lookups[].aggregate | first | count | no | Default "first". |
resolver.lookups[].order_by | string | no | |
resolver.transforms | array of object | no | |
resolver.transforms[].key | string | yes | |
resolver.transforms[].from | string | no | |
resolver.transforms[].ops | array of one of the variants below, ≥ 1 items | yes | |
resolver.transforms[].ops[] with kind = "date" | variant | – | |
resolver.transforms[].ops[].kind | "date" | yes | |
resolver.transforms[].ops[].format | string | no | Default "DD.MM.YYYY". |
resolver.transforms[].ops[] with kind = "replace" | variant | – | |
resolver.transforms[].ops[].kind | "replace" | yes | |
resolver.transforms[].ops[].pattern | string | yes | |
resolver.transforms[].ops[].flags | string | no | |
resolver.transforms[].ops[].replacement | string | no | Default "". |
resolver.transforms[].ops[] with kind = "match" | variant | – | |
resolver.transforms[].ops[].kind | "match" | yes | |
resolver.transforms[].ops[].cases | array of object, ≥ 1 items | yes | |
resolver.transforms[].ops[].cases[].pattern | string | yes | |
resolver.transforms[].ops[].cases[].value | string | yes | |
resolver.transforms[].ops[].default | string | no | |
resolver.transforms[].ops[] with kind = "upper" | variant | – | |
resolver.transforms[].ops[].kind | "upper" | yes | |
resolver.transforms[].ops[] with kind = "lower" | variant | – | |
resolver.transforms[].ops[].kind | "lower" | yes | |
resolver.transforms[].ops[] with kind = "trim" | variant | – | |
resolver.transforms[].ops[].kind | "trim" | yes | |
resolver with kind = "erpnext-query" | variant | – | |
resolver.kind | "erpnext-query" | yes | |
resolver.doctype | string | yes | |
resolver.filters | array of string, string, any | yes | |
resolver.fields | array of string, ≥ 1 items | yes | |
resolver.order_by | string | no | |
resolver.map | object of string | no | |
resolver.lookups | array of object | no | |
resolver.lookups[].key | string | yes | |
resolver.lookups[].doctype | string | yes | |
resolver.lookups[].filters | array of string, string, any | yes | |
resolver.lookups[].field | string | no | |
resolver.lookups[].aggregate | first | count | no | Default "first". |
resolver.lookups[].order_by | string | no | |
resolver.transforms | array of object | no | |
resolver.transforms[].key | string | yes | |
resolver.transforms[].from | string | no | |
resolver.transforms[].ops | array of one of the variants below, ≥ 1 items | yes | |
resolver.transforms[].ops[] with kind = "date" | variant | – | |
resolver.transforms[].ops[].kind | "date" | yes | |
resolver.transforms[].ops[].format | string | no | Default "DD.MM.YYYY". |
resolver.transforms[].ops[] with kind = "replace" | variant | – | |
resolver.transforms[].ops[].kind | "replace" | yes | |
resolver.transforms[].ops[].pattern | string | yes | |
resolver.transforms[].ops[].flags | string | no | |
resolver.transforms[].ops[].replacement | string | no | Default "". |
resolver.transforms[].ops[] with kind = "match" | variant | – | |
resolver.transforms[].ops[].kind | "match" | yes | |
resolver.transforms[].ops[].cases | array of object, ≥ 1 items | yes | |
resolver.transforms[].ops[].cases[].pattern | string | yes | |
resolver.transforms[].ops[].cases[].value | string | yes | |
resolver.transforms[].ops[].default | string | no | |
resolver.transforms[].ops[] with kind = "upper" | variant | – | |
resolver.transforms[].ops[].kind | "upper" | yes | |
resolver.transforms[].ops[] with kind = "lower" | variant | – | |
resolver.transforms[].ops[].kind | "lower" | yes | |
resolver.transforms[].ops[] with kind = "trim" | variant | – | |
resolver.transforms[].ops[].kind | "trim" | yes | |
resolver with kind = "static" | variant | – | |
resolver.kind | "static" | yes | |
resolver.data | object (any keys) | yes |
- Both templates must belong to the org and be made for the label model (
400 model_mismatchotherwise). entity.connection_id, when given, must be an ERP connection of the org.
Example request:
{
"entity": {
"system": "erpnext",
"doctype": "Warehouse",
"name": "KIT 164 - DEMO"
},
"template_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"empty_template_id": null,
"resolver": {
"kind": "erpnext-query",
"doctype": "Work Order",
"filters": [
["kitting_box", "=", "{{entity.name}}"],
[
"status",
"in",
["Not Started", "In Process"]
]
],
"fields": ["name", "production_item", "item_name", "qty", "expected_delivery_date"],
"map": {
"due": "expected_delivery_date"
},
"transforms": [
{
"key": "due",
"ops": [
{
"kind": "date",
"format": "DD.MM."
}
]
}
]
}
}
Example response:
{
"id": "7e8f9a0b-1c2d-4e3f-9a4b-5c6d7e8f9a0b",
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"entity": {
"system": "erpnext",
"doctype": "Warehouse",
"name": "KIT 164 - DEMO"
},
"template_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"empty_template_id": null,
"resolver": {
"kind": "erpnext-query",
"doctype": "Work Order",
"filters": [
["kitting_box", "=", "{{entity.name}}"],
[
"status",
"in",
["Not Started", "In Process"]
]
],
"fields": ["name", "production_item", "item_name", "qty", "expected_delivery_date"],
"map": {
"due": "expected_delivery_date"
},
"transforms": [
{
"key": "due",
"ops": [
{
"kind": "date",
"format": "DD.MM."
}
]
}
]
}
}
DELETE /labels/{id}/binding
Unbind a label. It keeps its last image.
Minimum role: operator. Success: 204.
Response (204): no body.
PUT /labels/{id}/content
Show static content on a label (manual labels, signage).
Minimum role: operator. Success: 202.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
template_id | uuid | yes | |
data | object (any keys) | yes |
Response (202): Accepted. The Accepted body plus delivered_to_bridge (boolean) and error (string, when the bridge could not be reached).
| Field | Type | Required | Description |
|---|---|---|---|
request_id | uuid | yes | |
queued | true | yes |
- Every call answers
202with a freshrequest_id, but not everyrequest_idgets an event. If the label already shows the samecontent_hash, the bridge queues nothing and sends no event. If the same hash is already queued, its events carry the earlierrequest_id. If newer content for the label arrives before delivery, this request is superseded and gets no event. - Wait for the content, not the request: read
content.content_hashfromGET /labels/{id}; the label shows it oncedisplayed_hashequals it, or once acontent.displayedevent with thatlabel_idandcontent_hasharrives.content.failedwithretrying: falseand that hash is the final failure.
Example request:
{
"template_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"data": {
"name": "Returns",
"item_name": "Shelf 4"
}
}
Example response:
{
"request_id": "9b1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6",
"queued": true
}
POST /labels/{id}/led
Flash the LED of one label.
Minimum role: operator. Success: 202.
Request body: LedRequest
| Field | Type | Required | Description |
|---|---|---|---|
color | string ^#[0-9A-Fa-f]{6}$ | no | |
duration_s | integer 1–32767 | no | |
on_ms | integer 2–5000 | no | |
off_ms | integer 2–5000 | no | |
brightness | number 0–1 | no | |
request_id | uuid | no | |
preset | locate | pick | attention | alert | ack | off | no | Default "locate". |
Response (202): Accepted
| Field | Type | Required | Description |
|---|---|---|---|
request_id | uuid | yes | |
queued | true | yes |
- The preset is expanded with the org's preset overrides, then with the overrides in the request. The server does not cap duty or duration beyond the schema limits; the label firmware enforces
LED_LIMITSon every command (at most 20 % on per complete pattern repetition, at most 300 s). 502 bridge_unavailable(withdetails.request_id) when the bridge cannot be reached. The server sends each command once and does not retry it.request_idis an idempotency key; omit it to have the server generate one. Repeating arequest_idfor the same label and the same command (after preset expansion) answers202again without a second command; a command that never reached the bridge is sent again. The samerequest_idwith another label or command answers409 request_id_reused.- Finishes with a
led.doneorled.failedevent, unless a newer LED command for the same label replaces it while it waits in the bridge queue (for example during a retry backoff); then only the newerrequest_idgets an event.
Example request:
{
"preset": "pick",
"color": "#00FF00"
}
Example response:
{
"request_id": "9b1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6",
"queued": true
}
POST /locate
Flash every label bound to an entity.
Minimum role: operator. Success: 200.
Request body: LocateRequest
| Field | Type | Required | Description |
|---|---|---|---|
color | string ^#[0-9A-Fa-f]{6}$ | no | |
duration_s | integer 1–32767 | no | |
on_ms | integer 2–5000 | no | |
off_ms | integer 2–5000 | no | |
brightness | number 0–1 | no | |
entity | object | yes | |
entity.system | string 1–32 chars | no | |
entity.connection_id | uuid | no | |
entity.doctype | string 1–140 chars | yes | |
entity.name | string 1–140 chars | yes | |
preset | locate | pick | attention | alert | ack | off | no | Default "locate". |
Response (200): LocateResponse
| Field | Type | Required | Description |
|---|---|---|---|
labels | array of object | yes | |
labels[].label_id | uuid | yes | |
labels[].request_id | uuid | yes |
entity.systemdefaults toerpnext. An entity without bound labels returns an empty list.- Every bound label is listed with its
request_ideven when its bridge could not be reached; that command is then recorded as failed and no event follows. UnlikePOST /labels/{id}/ledthere is no502.
Example request:
{
"entity": {
"doctype": "Warehouse",
"name": "KIT 164 - DEMO"
},
"preset": "locate"
}
Example response:
{
"labels": [
{
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"request_id": "9b1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6"
}
]
}
POST /refresh
Re-resolve bindings now, e.g. after bulk ERP changes. The empty JSON object {} re-resolves the whole org.
Minimum role: operator. Success: 200.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
label_ids | array of uuid | no | |
entity | object | no | |
entity.system | string 1–32 chars | no | |
entity.connection_id | uuid | no | |
entity.doctype | string 1–140 chars | yes | |
entity.name | string 1–140 chars | yes |
Response (200): { refreshed, checked, errors }: labels whose content changed, bindings checked, and the outcomes that failed.
- The body is required: send
{}to re-resolve every binding of the org. A missing or non-JSON body answers400 invalid_json. label_idsandentitynarrow the set; given together, a binding must match both.
Example request:
{
"entity": {
"doctype": "Warehouse",
"name": "KIT 164 - DEMO"
}
}
GET /templates
List the templates of the org, ordered by name.
Minimum role: viewer. Success: 200.
Response (200): { items, next_cursor: null }; items are { id, name, slug, model, current_version, archived, updated_at }.
GET /templates/{id}
One template version, the current one unless ?version= is given.
Minimum role: viewer. Success: 200.
| Query parameter | Meaning |
|---|---|
version | template version (default: current) |
Response (200): Template
| Field | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | |
version | integer ≥ 1 | yes | |
slug | string ^[a-z0-9][a-z0-9-]{1,62}$ | no | Stable, human-readable handle used by presets and seeds (newmatik-kitting-box). Unique per org. |
name | string 1–120 chars | yes | |
model | m29-bw | m29-bwry | m42-bwry | yes | |
engine | "html-mustache-v1" | yes | |
source | string ≤ 64000 chars | yes | |
fields | array of object | no | Default []. |
fields[].key | string ^[a-z][a-z0-9_.]*$ | yes | |
fields[].label | string | yes | |
fields[].type | string | number | date | enum | qr | yes | |
fields[].max_len | integer > 0 | no | Soft limit the template is designed for; longer values are shrunk or ellipsised by the template. |
fields[].options | array of string | no | |
sample_data | object (any keys) | no | Default {}. |
Example response:
{
"id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"version": 3,
"slug": "kitting-box",
"name": "Kitting box",
"model": "m42-bwry",
"engine": "html-mustache-v1",
"source": "<div style=\"display:flex;flex-direction:column;padding:12px\"><div style=\"font-size:40px\">{{name}}</div><div>{{item_name}}</div></div>",
"fields": [
{
"key": "name",
"label": "Work order",
"type": "string",
"max_len": 16
},
{
"key": "item_name",
"label": "Item",
"type": "string",
"max_len": 60
}
],
"sample_data": {
"name": "WO-26-00482",
"item_name": "Controller board"
}
}
GET /events
The event log, newest first (by at, then by id).
Minimum role: viewer. Success: 200.
| Query parameter | Meaning |
|---|---|
since | only events at or after this RFC 3339 time |
type | only this event type (e.g. button.pressed) |
label_id | only events of this label |
limit | 1–200, default 50 |
cursor | next_cursor of the previous page: an opaque keyset of the last event's at and id, so events sharing a timestamp across a page boundary are neither skipped nor repeated. A bare RFC 3339 timestamp (the earlier cursor format) is still accepted and starts strictly before that time. Any other value answers 400 invalid_request. |
Response (200)
| Field | Type | Required | Description |
|---|---|---|---|
items | array of object | yes | |
items[].id | uuid | yes | |
items[].bridge_id | uuid | null | yes | |
items[].label_id | uuid | null | yes | |
items[].ap_hw_id | string ^[0-9a-f]{12}$ | null | yes | |
items[].type | string | yes | |
items[].at | string | yes | |
items[].payload | object (any keys) | yes | |
next_cursor | string | null | yes |
Example response:
{
"items": [
{
"id": "9b1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6",
"bridge_id": "c0ffee00-1234-4abc-8def-001122334455",
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"ap_hw_id": null,
"type": "button.pressed",
"at": "2026-10-20T08:20:11Z",
"payload": {
"id": "9b1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6",
"at": "2026-10-20T08:20:11Z",
"type": "button.pressed",
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"button": 0,
"kind": "short"
}
}
],
"next_cursor": null
}
GET /webhooks
List outbound webhook subscriptions.
Minimum role: admin. Success: 200.
Response (200): { items, next_cursor: null }; items are { id, url, events, description, enabled, created_at }; description is null when none was given.
POST /webhooks
Subscribe a URL to events. The signing secret is returned once.
Minimum role: admin. Success: 201.
Request body: WebhookSubscriptionInput
| Field | Type | Required | Description |
|---|---|---|---|
url | URL | yes | |
events | array of button.pressed | content.displayed | content.failed | label.offline | label.battery_low | led.done, ≥ 1 items | yes | |
description | string ≤ 200 chars | no |
Response (201): WebhookSubscription
| Field | Type | Required | Description |
|---|---|---|---|
url | URL | yes | |
events | array of button.pressed | content.displayed | content.failed | label.offline | label.battery_low | led.done, ≥ 1 items | yes | |
description | string ≤ 200 chars | null | yes | null when the subscription was created without one. |
id | uuid | yes | |
secret | string | no | Returned once on creation. |
created_at | string | yes |
Example request:
{
"url": "https://erp.example.com/api/method/merkora_erpnext.api.webhook",
"events": ["button.pressed", "label.battery_low"]
}
Example response:
{
"id": "7e8f9a0b-1c2d-4e3f-9a4b-5c6d7e8f9a0b",
"url": "https://erp.example.com/api/method/merkora_erpnext.api.webhook",
"events": ["button.pressed", "label.battery_low"],
"description": null,
"secret": "whsec_…",
"created_at": "2026-10-20T08:00:00Z"
}
DELETE /webhooks/{id}
Delete a webhook subscription.
Minimum role: admin. Success: 204.
Response (204): no body.
ERP change hints
POST {SUPABASE_URL}/functions/v1/erp-webhook?c=<connection_id>
Tell the control center that an ERP record changed. The record is re-read over the ERP REST API.
Auth: X-Merkora-Signature with the connection's webhook secret, or a native Frappe webhook's X-Frappe-Webhook-Signature (base64 HMAC-SHA256 of the body, no timestamp, so no replay protection). Success: 202.
Request body: ErpHint
| Field | Type | Required | Description |
|---|---|---|---|
doctype | string | yes | |
name | string | yes | |
event | on_update | on_submit | on_cancel | on_trash | on_change | after_rename | no | |
old_name | string | no |
Response (202): { status: "processed", affected, changed, errors }, or { status: "ignored", reason } for a body without doctype/name or a record without bindings.
- Unknown and disabled connections both answer
404 unknown_connection. - Bodies over 256 KiB are rejected with
413 too_large.
Example request:
{
"doctype": "Work Order",
"name": "WO-26-00482",
"event": "on_update"
}
Outbound webhooks
Subscriptions (POST /webhooks) receive POST requests with a JSON WebhookPayload, signed with the subscription secret in X-Merkora-Signature (see Signatures). A delivery is attempted at once and succeeds on any 2xx answer within 10 s. A failed delivery is retried by a cron job that runs every minute, after 1, 2, 4 … 256 minutes, up to 10 attempts in all; deliveries to a disabled subscription fail without retry. Each event is delivered on its own, in no guaranteed order. led.failed and label.status are not sent as webhooks.
Event types:
button.pressedcontent.displayedcontent.failedlabel.offlinelabel.battery_lowled.done
Content events are per content_hash, not per request: a PUT /labels/{id}/content whose hash the label already shows sends no event, a repeat of a queued hash shares the earlier request_id, and content superseded before delivery gets no event. Reconcile against displayed_hash on the label.
WebhookPayload
| Field | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | |
type | button.pressed | content.displayed | content.failed | label.offline | label.battery_low | led.done | yes | |
at | RFC 3339 date-time | yes | |
org_id | uuid | yes | |
data | object | yes | |
data.label_id | uuid | yes | |
data.label_name | string | null | yes | |
data.entity | object | null | yes | |
data.entity.system | string | yes | |
data.entity.doctype | string | yes | |
data.entity.name | string | yes | |
data.event | object (any keys) | yes |
Example:
{
"id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
"type": "button.pressed",
"at": "2026-10-20T08:20:12Z",
"org_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"data": {
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"label_name": "KIT 164",
"entity": {
"system": "erpnext",
"doctype": "Warehouse",
"name": "KIT 164 - DEMO"
},
"event": {
"id": "9b1e2f3a-4b5c-4d6e-8f70-8192a3b4c5d6",
"at": "2026-10-20T08:20:11Z",
"type": "button.pressed",
"label_id": "3f0c9a52-6d1e-4b8a-9a77-1c2d3e4f5a60",
"button": 0,
"kind": "short"
}
}
}
Signatures
Server → bridge requests, ERP hints and outbound webhooks carry X-Merkora-Signature: t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256 with the shared secret over "<t>.<raw body>" (empty body for GET and DELETE). Receivers reject a t more than 300 s away from their clock and compare in constant time. Reference implementation: signBody() / verifySignature() in contracts/src/signature.ts (WebCrypto only).
Error codes
| Code | HTTP | Meaning |
|---|---|---|
invalid_json | 400 | The body is not valid JSON. |
invalid_request | 400 | The body (or a parameter) does not match the contract schema. details holds the zod issues. |
invite_failed | 400 | Supabase Auth refused the invitation. |
model_mismatch | 400 | A template is for another label model than the label. |
no_site | 400 | A label was registered before the org has a site. |
org_required | 400 | A user in several (or no) orgs called without X-Merkora-Org. |
invalid_signature | 401 | The X-Merkora-Signature (or Frappe signature) is missing, malformed, outside the 300 s window or wrong. |
unauthorized | 401 | Missing or invalid bearer token, API key, session or cron secret. |
forbidden | 403 | The caller lacks the role, is not a member of the org in X-Merkora-Org, or the batch is for another bridge. |
not_found | 404 | No such route, or the resource is not in the caller's org. |
unknown_connection | 404 | No enabled ERP connection with this id. |
method_not_allowed | 405 | Only POST is accepted. |
no_bridge | 409 | The org has no bridge to render a preview. |
request_id_reused | 409 | The request_id of an LED command (or, on the bridge, a provisioning request) was already used for another label or a different command. Repeats with the same body are accepted, not refused. |
too_large | 413 | The body exceeds the size limit (2 MiB ingest, 256 KiB hints). |
internal_error | 500 | Unexpected server error, including a bridge that failed during a proxied admin call. Logged server-side. |
bridge_unavailable | 502 | The bridge could not be reached for an LED command. details.request_id names the command. |
preview_failed | 502 | The bridge answered a preview request with an error. |