Skip to content

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 with X-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_cursor is null on the last page.
  • Async commands answer 202 with { request_id, queued: true }. They usually finish with an event carrying the same request_id (GET /events; led.done, content.displayed and the final content.failed also 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 by label_id and content_hash (see PUT /labels/{id}/content).
  • CORS is open (Access-Control-Allow-Origin: *); authentication is by header only.

Endpoints

MethodPathRoleSummary
GET/labelsviewerList the labels of the org, ordered by id.
GET/labels/{id}viewerOne label with its binding and current desired content.
PATCH/labels/{id}operatorRename a label or move it to another site.
PUT/labels/{id}/bindingoperatorBind a label to an entity and resolve its content now.
DELETE/labels/{id}/bindingoperatorUnbind a label. It keeps its last image.
PUT/labels/{id}/contentoperatorShow static content on a label (manual labels, signage).
POST/labels/{id}/ledoperatorFlash the LED of one label.
POST/locateoperatorFlash every label bound to an entity.
POST/refreshoperatorRe-resolve bindings now, e.g. after bulk ERP changes. The empty JSON object {} re-resolves the whole org.
GET/templatesviewerList the templates of the org, ordered by name.
GET/templates/{id}viewerOne template version, the current one unless ?version= is given.
GET/eventsviewerThe event log, newest first (by at, then by id).
GET/webhooksadminList outbound webhook subscriptions.
POST/webhooksadminSubscribe a URL to events. The signing secret is returned once.
DELETE/webhooks/{id}adminDelete a webhook subscription.

GET /labels

List the labels of the org, ordered by id.

Minimum role: viewer. Success: 200.

Query parameterMeaning
site_idonly labels of this site
statusonly labels with this status
qsubstring of the name or the BLE address
limit1–200, default 50
cursornext_cursor of the previous page

Response (200)

FieldTypeRequiredDescription
itemsarray of objectyes
items[].iduuidyes
items[].site_iduuidyes
items[].hw_addressstring ^([0-9A-F]{2}:){5}[0-9A-F]{2}$yes
items[].modelm29-bw | m29-bwry | m42-bwryyes
items[].drivermerkora-ble | simyes
items[].namestring ≤ 120 chars | nullyes
items[].statusnew | provisioning | online | offline | erroryes
items[].ap_hw_idstring ^[0-9a-f]{12}$ | nullyesAP the label is currently synced to, as reported by the bridge.
items[].battery_mvinteger | nullyes
items[].rssiinteger | nullyes
items[].fw_versionstring | nullyes
items[].displayed_hashstring | nullyescontent_hash the label is confirmed to show.
items[].last_seen_atRFC 3339 date-time | nullyes
next_cursorstring | nullyes

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

FieldTypeRequiredDescription
iduuidyes
site_iduuidyes
hw_addressstring ^([0-9A-F]{2}:){5}[0-9A-F]{2}$yes
modelm29-bw | m29-bwry | m42-bwryyes
drivermerkora-ble | simyes
namestring ≤ 120 chars | nullyes
statusnew | provisioning | online | offline | erroryes
ap_hw_idstring ^[0-9a-f]{12}$ | nullyesAP the label is currently synced to, as reported by the bridge.
battery_mvinteger | nullyes
rssiinteger | nullyes
fw_versionstring | nullyes
displayed_hashstring | nullyescontent_hash the label is confirmed to show.
last_seen_atRFC 3339 date-time | nullyes
bindingobject | nullyes
binding.iduuidyes
binding.label_iduuidyes
binding.entityobjectyes
binding.entity.systemstring 1–32 charsyes
binding.entity.connection_iduuidno
binding.entity.doctypestring 1–140 charsyes
binding.entity.namestring 1–140 charsyes
binding.template_iduuidyes
binding.empty_template_iduuid | nullyes
binding.resolverone of the variants belowyes
binding.resolver with kind = "erpnext-doc"variant–
binding.resolver.kind"erpnext-doc"yes
binding.resolver.fieldsarray of string, ≥ 1 itemsyes
binding.resolver.mapobject of stringno
binding.resolver.lookupsarray of objectno
binding.resolver.lookups[].keystringyes
binding.resolver.lookups[].doctypestringyes
binding.resolver.lookups[].filtersarray of string, string, anyyes
binding.resolver.lookups[].fieldstringno
binding.resolver.lookups[].aggregatefirst | countnoDefault "first".
binding.resolver.lookups[].order_bystringno
binding.resolver.transformsarray of objectno
binding.resolver.transforms[].keystringyes
binding.resolver.transforms[].fromstringno
binding.resolver.transforms[].opsarray of one of the variants below, ≥ 1 itemsyes
binding.resolver.transforms[].ops[] with kind = "date"variant–
binding.resolver.transforms[].ops[].kind"date"yes
binding.resolver.transforms[].ops[].formatstringnoDefault "DD.MM.YYYY".
binding.resolver.transforms[].ops[] with kind = "replace"variant–
binding.resolver.transforms[].ops[].kind"replace"yes
binding.resolver.transforms[].ops[].patternstringyes
binding.resolver.transforms[].ops[].flagsstringno
binding.resolver.transforms[].ops[].replacementstringnoDefault "".
binding.resolver.transforms[].ops[] with kind = "match"variant–
binding.resolver.transforms[].ops[].kind"match"yes
binding.resolver.transforms[].ops[].casesarray of object, ≥ 1 itemsyes
binding.resolver.transforms[].ops[].cases[].patternstringyes
binding.resolver.transforms[].ops[].cases[].valuestringyes
binding.resolver.transforms[].ops[].defaultstringno
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.doctypestringyes
binding.resolver.filtersarray of string, string, anyyes
binding.resolver.fieldsarray of string, ≥ 1 itemsyes
binding.resolver.order_bystringno
binding.resolver.mapobject of stringno
binding.resolver.lookupsarray of objectno
binding.resolver.lookups[].keystringyes
binding.resolver.lookups[].doctypestringyes
binding.resolver.lookups[].filtersarray of string, string, anyyes
binding.resolver.lookups[].fieldstringno
binding.resolver.lookups[].aggregatefirst | countnoDefault "first".
binding.resolver.lookups[].order_bystringno
binding.resolver.transformsarray of objectno
binding.resolver.transforms[].keystringyes
binding.resolver.transforms[].fromstringno
binding.resolver.transforms[].opsarray of one of the variants below, ≥ 1 itemsyes
binding.resolver.transforms[].ops[] with kind = "date"variant–
binding.resolver.transforms[].ops[].kind"date"yes
binding.resolver.transforms[].ops[].formatstringnoDefault "DD.MM.YYYY".
binding.resolver.transforms[].ops[] with kind = "replace"variant–
binding.resolver.transforms[].ops[].kind"replace"yes
binding.resolver.transforms[].ops[].patternstringyes
binding.resolver.transforms[].ops[].flagsstringno
binding.resolver.transforms[].ops[].replacementstringnoDefault "".
binding.resolver.transforms[].ops[] with kind = "match"variant–
binding.resolver.transforms[].ops[].kind"match"yes
binding.resolver.transforms[].ops[].casesarray of object, ≥ 1 itemsyes
binding.resolver.transforms[].ops[].cases[].patternstringyes
binding.resolver.transforms[].ops[].cases[].valuestringyes
binding.resolver.transforms[].ops[].defaultstringno
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.dataobject (any keys)yes
contentobject | nullyes
content.template_iduuidyes
content.content_hashstringyes
content.updated_atstringyes
content.dataobject (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

FieldTypeRequiredDescription
iduuidyes
site_iduuidyes
hw_addressstring ^([0-9A-F]{2}:){5}[0-9A-F]{2}$yes
modelm29-bw | m29-bwry | m42-bwryyes
drivermerkora-ble | simyes
namestring ≤ 120 chars | nullyes
statusnew | provisioning | online | offline | erroryes
ap_hw_idstring ^[0-9a-f]{12}$ | nullyesAP the label is currently synced to, as reported by the bridge.
battery_mvinteger | nullyes
rssiinteger | nullyes
fw_versionstring | nullyes
displayed_hashstring | nullyescontent_hash the label is confirmed to show.
last_seen_atRFC 3339 date-time | nullyes

PUT /labels/{id}/binding

Bind a label to an entity and resolve its content now.

Minimum role: operator. Success: 200.

Request body: PutBindingRequest

FieldTypeRequiredDescription
entityobjectyes
entity.systemstring 1–32 charsyes
entity.connection_iduuidno
entity.doctypestring 1–140 charsyes
entity.namestring 1–140 charsyes
template_iduuidyes
empty_template_iduuid | nullyes
resolverone of the variants belowyes
resolver with kind = "erpnext-doc"variant–
resolver.kind"erpnext-doc"yes
resolver.fieldsarray of string, ≥ 1 itemsyes
resolver.mapobject of stringno
resolver.lookupsarray of objectno
resolver.lookups[].keystringyes
resolver.lookups[].doctypestringyes
resolver.lookups[].filtersarray of string, string, anyyes
resolver.lookups[].fieldstringno
resolver.lookups[].aggregatefirst | countnoDefault "first".
resolver.lookups[].order_bystringno
resolver.transformsarray of objectno
resolver.transforms[].keystringyes
resolver.transforms[].fromstringno
resolver.transforms[].opsarray of one of the variants below, ≥ 1 itemsyes
resolver.transforms[].ops[] with kind = "date"variant–
resolver.transforms[].ops[].kind"date"yes
resolver.transforms[].ops[].formatstringnoDefault "DD.MM.YYYY".
resolver.transforms[].ops[] with kind = "replace"variant–
resolver.transforms[].ops[].kind"replace"yes
resolver.transforms[].ops[].patternstringyes
resolver.transforms[].ops[].flagsstringno
resolver.transforms[].ops[].replacementstringnoDefault "".
resolver.transforms[].ops[] with kind = "match"variant–
resolver.transforms[].ops[].kind"match"yes
resolver.transforms[].ops[].casesarray of object, ≥ 1 itemsyes
resolver.transforms[].ops[].cases[].patternstringyes
resolver.transforms[].ops[].cases[].valuestringyes
resolver.transforms[].ops[].defaultstringno
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.doctypestringyes
resolver.filtersarray of string, string, anyyes
resolver.fieldsarray of string, ≥ 1 itemsyes
resolver.order_bystringno
resolver.mapobject of stringno
resolver.lookupsarray of objectno
resolver.lookups[].keystringyes
resolver.lookups[].doctypestringyes
resolver.lookups[].filtersarray of string, string, anyyes
resolver.lookups[].fieldstringno
resolver.lookups[].aggregatefirst | countnoDefault "first".
resolver.lookups[].order_bystringno
resolver.transformsarray of objectno
resolver.transforms[].keystringyes
resolver.transforms[].fromstringno
resolver.transforms[].opsarray of one of the variants below, ≥ 1 itemsyes
resolver.transforms[].ops[] with kind = "date"variant–
resolver.transforms[].ops[].kind"date"yes
resolver.transforms[].ops[].formatstringnoDefault "DD.MM.YYYY".
resolver.transforms[].ops[] with kind = "replace"variant–
resolver.transforms[].ops[].kind"replace"yes
resolver.transforms[].ops[].patternstringyes
resolver.transforms[].ops[].flagsstringno
resolver.transforms[].ops[].replacementstringnoDefault "".
resolver.transforms[].ops[] with kind = "match"variant–
resolver.transforms[].ops[].kind"match"yes
resolver.transforms[].ops[].casesarray of object, ≥ 1 itemsyes
resolver.transforms[].ops[].cases[].patternstringyes
resolver.transforms[].ops[].cases[].valuestringyes
resolver.transforms[].ops[].defaultstringno
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.dataobject (any keys)yes

Response (200): Binding. The Binding plus refresh, the outcome of the immediate re-resolution.

FieldTypeRequiredDescription
iduuidyes
label_iduuidyes
entityobjectyes
entity.systemstring 1–32 charsyes
entity.connection_iduuidno
entity.doctypestring 1–140 charsyes
entity.namestring 1–140 charsyes
template_iduuidyes
empty_template_iduuid | nullyes
resolverone of the variants belowyes
resolver with kind = "erpnext-doc"variant–
resolver.kind"erpnext-doc"yes
resolver.fieldsarray of string, ≥ 1 itemsyes
resolver.mapobject of stringno
resolver.lookupsarray of objectno
resolver.lookups[].keystringyes
resolver.lookups[].doctypestringyes
resolver.lookups[].filtersarray of string, string, anyyes
resolver.lookups[].fieldstringno
resolver.lookups[].aggregatefirst | countnoDefault "first".
resolver.lookups[].order_bystringno
resolver.transformsarray of objectno
resolver.transforms[].keystringyes
resolver.transforms[].fromstringno
resolver.transforms[].opsarray of one of the variants below, ≥ 1 itemsyes
resolver.transforms[].ops[] with kind = "date"variant–
resolver.transforms[].ops[].kind"date"yes
resolver.transforms[].ops[].formatstringnoDefault "DD.MM.YYYY".
resolver.transforms[].ops[] with kind = "replace"variant–
resolver.transforms[].ops[].kind"replace"yes
resolver.transforms[].ops[].patternstringyes
resolver.transforms[].ops[].flagsstringno
resolver.transforms[].ops[].replacementstringnoDefault "".
resolver.transforms[].ops[] with kind = "match"variant–
resolver.transforms[].ops[].kind"match"yes
resolver.transforms[].ops[].casesarray of object, ≥ 1 itemsyes
resolver.transforms[].ops[].cases[].patternstringyes
resolver.transforms[].ops[].cases[].valuestringyes
resolver.transforms[].ops[].defaultstringno
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.doctypestringyes
resolver.filtersarray of string, string, anyyes
resolver.fieldsarray of string, ≥ 1 itemsyes
resolver.order_bystringno
resolver.mapobject of stringno
resolver.lookupsarray of objectno
resolver.lookups[].keystringyes
resolver.lookups[].doctypestringyes
resolver.lookups[].filtersarray of string, string, anyyes
resolver.lookups[].fieldstringno
resolver.lookups[].aggregatefirst | countnoDefault "first".
resolver.lookups[].order_bystringno
resolver.transformsarray of objectno
resolver.transforms[].keystringyes
resolver.transforms[].fromstringno
resolver.transforms[].opsarray of one of the variants below, ≥ 1 itemsyes
resolver.transforms[].ops[] with kind = "date"variant–
resolver.transforms[].ops[].kind"date"yes
resolver.transforms[].ops[].formatstringnoDefault "DD.MM.YYYY".
resolver.transforms[].ops[] with kind = "replace"variant–
resolver.transforms[].ops[].kind"replace"yes
resolver.transforms[].ops[].patternstringyes
resolver.transforms[].ops[].flagsstringno
resolver.transforms[].ops[].replacementstringnoDefault "".
resolver.transforms[].ops[] with kind = "match"variant–
resolver.transforms[].ops[].kind"match"yes
resolver.transforms[].ops[].casesarray of object, ≥ 1 itemsyes
resolver.transforms[].ops[].cases[].patternstringyes
resolver.transforms[].ops[].cases[].valuestringyes
resolver.transforms[].ops[].defaultstringno
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.dataobject (any keys)yes
  • Both templates must belong to the org and be made for the label model (400 model_mismatch otherwise).
  • 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

FieldTypeRequiredDescription
template_iduuidyes
dataobject (any keys)yes

Response (202): Accepted. The Accepted body plus delivered_to_bridge (boolean) and error (string, when the bridge could not be reached).

FieldTypeRequiredDescription
request_iduuidyes
queuedtrueyes
  • Every call answers 202 with a fresh request_id, but not every request_id gets an event. If the label already shows the same content_hash, the bridge queues nothing and sends no event. If the same hash is already queued, its events carry the earlier request_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_hash from GET /labels/{id}; the label shows it once displayed_hash equals it, or once a content.displayed event with that label_id and content_hash arrives. content.failed with retrying: false and 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

FieldTypeRequiredDescription
colorstring ^#[0-9A-Fa-f]{6}$no
duration_sinteger 1–32767no
on_msinteger 2–5000no
off_msinteger 2–5000no
brightnessnumber 0–1no
request_iduuidno
presetlocate | pick | attention | alert | ack | offnoDefault "locate".

Response (202): Accepted

FieldTypeRequiredDescription
request_iduuidyes
queuedtrueyes
  • 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_LIMITS on every command (at most 20 % on per complete pattern repetition, at most 300 s).
  • 502 bridge_unavailable (with details.request_id) when the bridge cannot be reached. The server sends each command once and does not retry it.
  • request_id is an idempotency key; omit it to have the server generate one. Repeating a request_id for the same label and the same command (after preset expansion) answers 202 again without a second command; a command that never reached the bridge is sent again. The same request_id with another label or command answers 409 request_id_reused.
  • Finishes with a led.done or led.failed event, 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 newer request_id gets 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

FieldTypeRequiredDescription
colorstring ^#[0-9A-Fa-f]{6}$no
duration_sinteger 1–32767no
on_msinteger 2–5000no
off_msinteger 2–5000no
brightnessnumber 0–1no
entityobjectyes
entity.systemstring 1–32 charsno
entity.connection_iduuidno
entity.doctypestring 1–140 charsyes
entity.namestring 1–140 charsyes
presetlocate | pick | attention | alert | ack | offnoDefault "locate".

Response (200): LocateResponse

FieldTypeRequiredDescription
labelsarray of objectyes
labels[].label_iduuidyes
labels[].request_iduuidyes
  • entity.system defaults to erpnext. An entity without bound labels returns an empty list.
  • Every bound label is listed with its request_id even when its bridge could not be reached; that command is then recorded as failed and no event follows. Unlike POST /labels/{id}/led there is no 502.

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

FieldTypeRequiredDescription
label_idsarray of uuidno
entityobjectno
entity.systemstring 1–32 charsno
entity.connection_iduuidno
entity.doctypestring 1–140 charsyes
entity.namestring 1–140 charsyes

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 answers 400 invalid_json.
  • label_ids and entity narrow 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 parameterMeaning
versiontemplate version (default: current)

Response (200): Template

FieldTypeRequiredDescription
iduuidyes
versioninteger ≥ 1yes
slugstring ^[a-z0-9][a-z0-9-]{1,62}$noStable, human-readable handle used by presets and seeds (newmatik-kitting-box). Unique per org.
namestring 1–120 charsyes
modelm29-bw | m29-bwry | m42-bwryyes
engine"html-mustache-v1"yes
sourcestring ≤ 64000 charsyes
fieldsarray of objectnoDefault [].
fields[].keystring ^[a-z][a-z0-9_.]*$yes
fields[].labelstringyes
fields[].typestring | number | date | enum | qryes
fields[].max_leninteger > 0noSoft limit the template is designed for; longer values are shrunk or ellipsised by the template.
fields[].optionsarray of stringno
sample_dataobject (any keys)noDefault {}.

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 parameterMeaning
sinceonly events at or after this RFC 3339 time
typeonly this event type (e.g. button.pressed)
label_idonly events of this label
limit1–200, default 50
cursornext_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)

FieldTypeRequiredDescription
itemsarray of objectyes
items[].iduuidyes
items[].bridge_iduuid | nullyes
items[].label_iduuid | nullyes
items[].ap_hw_idstring ^[0-9a-f]{12}$ | nullyes
items[].typestringyes
items[].atstringyes
items[].payloadobject (any keys)yes
next_cursorstring | nullyes

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

FieldTypeRequiredDescription
urlURLyes
eventsarray of button.pressed | content.displayed | content.failed | label.offline | label.battery_low | led.done, ≥ 1 itemsyes
descriptionstring ≤ 200 charsno

Response (201): WebhookSubscription

FieldTypeRequiredDescription
urlURLyes
eventsarray of button.pressed | content.displayed | content.failed | label.offline | label.battery_low | led.done, ≥ 1 itemsyes
descriptionstring ≤ 200 chars | nullyesnull when the subscription was created without one.
iduuidyes
secretstringnoReturned once on creation.
created_atstringyes

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

FieldTypeRequiredDescription
doctypestringyes
namestringyes
eventon_update | on_submit | on_cancel | on_trash | on_change | after_renameno
old_namestringno

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.pressed
  • content.displayed
  • content.failed
  • label.offline
  • label.battery_low
  • led.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

FieldTypeRequiredDescription
iduuidyes
typebutton.pressed | content.displayed | content.failed | label.offline | label.battery_low | led.doneyes
atRFC 3339 date-timeyes
org_iduuidyes
dataobjectyes
data.label_iduuidyes
data.label_namestring | nullyes
data.entityobject | nullyes
data.entity.systemstringyes
data.entity.doctypestringyes
data.entity.namestringyes
data.eventobject (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

CodeHTTPMeaning
invalid_json400The body is not valid JSON.
invalid_request400The body (or a parameter) does not match the contract schema. details holds the zod issues.
invite_failed400Supabase Auth refused the invitation.
model_mismatch400A template is for another label model than the label.
no_site400A label was registered before the org has a site.
org_required400A user in several (or no) orgs called without X-Merkora-Org.
invalid_signature401The X-Merkora-Signature (or Frappe signature) is missing, malformed, outside the 300 s window or wrong.
unauthorized401Missing or invalid bearer token, API key, session or cron secret.
forbidden403The caller lacks the role, is not a member of the org in X-Merkora-Org, or the batch is for another bridge.
not_found404No such route, or the resource is not in the caller's org.
unknown_connection404No enabled ERP connection with this id.
method_not_allowed405Only POST is accepted.
no_bridge409The org has no bridge to render a preview.
request_id_reused409The 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_large413The body exceeds the size limit (2 MiB ingest, 256 KiB hints).
internal_error500Unexpected server error, including a bridge that failed during a proxied admin call. Logged server-side.
bridge_unavailable502The bridge could not be reached for an LED command. details.request_id names the command.
preview_failed502The bridge answered a preview request with an error.