Skip to content

Polling Orders & Commands

After receiving a message event on the SSE stream, the client polls GET /orders/location to retrieve all pending orders and commands. This endpoint returns both regular orders and command objects in a single response.

Endpoint

text
GET https://{host}/orders/location

Headers:

HeaderRequiredDescription
api_keyYesService device API key

Query parameters:

ParameterTypeDefaultDescription
orderNumberlong0Only return orders with number greater than this value
commandNumberlong0Only return commands with ID greater than this value

Response: 200 OK with body ExternalOrder[] (JSON array)

Response Schema

The endpoint returns a JSON array of ExternalOrder objects. Each object can represent either a food/beverage order or a command (e.g., read table state, request bill, export data).

ExternalOrder

json
{
  "number": 12345,
  "orderTime": "10:30:00",
  "tableNumber": 12,
  "userNumber": 5,
  "togo": null,
  "guestCount": 1,
  "moveTableTo": null,
  "readTableState": null,
  "paymentNumber": null,
  "receipt": null,
  "exportMainData": null,
  "paymentDiscount": null,
  "customer": null,
  "rows": [
    {
      "category": {
        "order": 1,
        "id": 1,
        "description": "Beverages"
      },
      "itemType": "MENU_ITEM",
      "name": "Espresso",
      "infotext": null,
      "number": 1,
      "factor": 2,
      "price": 3.50,
      "priceTogo": null,
      "discount": null,
      "subrows": null
    }
  ],
  "state": "PLACED"
}

Top-Level Fields

FieldTypeDescription
numberlongUnique order/command identifier. Use this for idempotency and offset tracking
orderTimestringTime the order was placed, format HH:mm:ss
tableNumberlong or nullTable number
userNumberlong or nullUser number who placed the order
togoint or nullTakeout flag indicator
guestCountint or nullNumber of guests
moveTableToint or nullIf set, this object represents a move table command
readTableStateboolean or nullIf true, this object represents a read table state command
paymentNumberint or nullIf set, this object represents a request bill command
receiptboolean or nullIf true, this object represents a print receipt command
exportMainDataboolean or nullIf true, this object represents an export main data / fetch remote menu command
paymentDiscountarray or nullArray of payment discount objects applied to the order
customerobject or nullCustomer information (for invoice orders)
rowsarray or nullOrder line items. null for commands
statestring or nullOrder state. null or "PLACED" for commands

OrderRow

FieldTypeDescription
categoryobject or nullProduct category with order, id, and description
itemTypestringType of item (MENU_ITEM, FOOD, TAKEOUT, CONDIMENTS, BEVERAGES, ARRANGEMENT)
namestringProduct name
infotextstring or nullSpecial instructions or notes
numberintRow number
factorintQuantity
pricenumber or nullUnit price
priceTogonumber or nullTakeout price if different
discountarray or nullDiscounts applied to this row
subrowsarray or nullSub-items (modifiers, sides)

Category

FieldTypeDescription
orderintSort order
idintCategory ID
descriptionstring or nullCategory name

Distinguishing Orders from Commands

The response array contains a mix of regular orders and commands. Use the isCommand() logic to differentiate them. An ExternalOrder is a command if any of these fields is set:

  • readTableState is true
  • moveTableTo is not null
  • exportMainData is true
  • paymentNumber is not null

Detection pseudo-code:

javascript
function isCommand(item) {
  return item.readTableState === true
      || item.moveTableTo !== null
      || item.exportMainData === true
      || item.paymentNumber !== null;
}

function processResponse(items) {
  for (const item of items) {
    if (isCommand(item)) {
      handleCommand(item);
    } else {
      handleOrder(item);
    }
  }
}

Command Types

Detection FieldCommand TypeWhat To Do
readTableState: trueRead table stateQuery your local table state and POST response to /commands/{id}/response
moveTableTo: <int>Move tableMove items to the specified table number
exportMainData: trueFetch remote menu / export dataExport your menu data (e.g., for Vectron integration)
paymentNumber: <int>Request billSend the bill for the specified payment number

OrderState Enum

The state field on orders uses these values:

text
SELECTING  — Customer is still selecting items (not yet placed)
NEW        — Order was just created by a client application
PLACED     — Customer has submitted the order, ready for processing
ABORTED    — Order was cancelled (e.g., session closed)
FAILED     — Order processing failed in the backend system
COMPLETED  — Order was completed successfully

For polling, the endpoint returns orders with state PLACED. Commands always have state PLACED.

Polling Guidance

  1. Poll on SSE message event — When the SSE stream sends a message event, call this endpoint immediately.
  2. Fallback interval poll — As a safety net, poll at a reasonable interval (every 5 seconds) even without SSE notifications.
  3. Use order offset — Track the highest number you have processed and pass it as orderNumber to avoid receiving already-processed orders.
  4. Use command offset — Similarly, track the highest command ID and pass it as commandNumber.
  5. Batch processing — You may receive multiple orders in one response. Process them in sequence, updating status for each.

Curl Examples

Success Response with Multiple Orders

bash
curl -i -H "api_key: abc123-def456-ghi789" \
  "https://{host}/orders/location"

Response:

http
HTTP/1.1 200 OK
Content-Type: application/json

[
  {
    "number": 12345,
    "orderTime": "10:30:00",
    "tableNumber": 12,
    "userNumber": 5,
    "rows": [
      {
        "category": { "order": 1, "id": 1, "description": "Beverages" },
        "itemType": "MENU_ITEM",
        "name": "Espresso",
        "number": 1,
        "factor": 2,
        "price": 3.50
      }
    ],
    "state": "PLACED"
  },
  {
    "number": 12346,
    "orderTime": "10:32:00",
    "tableNumber": 5,
    "userNumber": 3,
    "rows": [
      {
        "category": { "order": 2, "id": 3, "description": "Main Course" },
        "itemType": "FOOD",
        "name": "Caesar Salad",
        "number": 1,
        "factor": 1,
        "price": 12.90
      }
    ],
    "state": "PLACED"
  }
]

With Offset Parameters (after processing)

bash
curl -i -H "api_key: abc123-def456-ghi789" \
  "https://{host}/orders/location?orderNumber=12346&commandNumber=42"

Empty Response (no pending items)

bash
curl -i -H "api_key: abc123-def456-ghi789" \
  "https://{host}/orders/location"

Response:

http
HTTP/1.1 200 OK
Content-Type: application/json

[]

Response Containing a Command

bash
curl -i -H "api_key: abc123-def456-ghi789" \
  "https://{host}/orders/location"

Response:

json
[
  {
    "number": 99,
    "orderTime": "11:05:00",
    "readTableState": true,
    "tableNumber": 12,
    "state": "PLACED"
  }
]

This is a Read Table State command for table 12. The readTableState: true indicates it is a command, not an order.

Error Handling

StatusMeaning
200Success (may return empty array [])
401Unauthorized (invalid or expired API key)
500Internal server error (retry with backoff)

Next Steps