Developer API

TPVStream API: clients and remote orders

Read and manage clients, and send orders to the POS.

On this page

Common rules (key, pagination, Idempotency-Key, If-Match, errors) are in API rules.

Clients

Method Route Right
GET /clients (?q&active&updatedSince) clients:read
GET /clients/{id} clients:read
POST /clients clients:write
PATCH /clients/{id} clients:write
DELETE /clients/{id} (deactivates) clients:write

?q= searches the name, email, phone, CIF or NIF.

{
  "id": "c9e2…",
  "type": "company",
  "name": "Restaurante El Puerto SL",
  "cif": "B12345678",
  "nid": null,
  "email": "admin@elpuerto.es",
  "phone": "+34 600 000 000",
  "address": "Calle Mayor 1",
  "city": "Valencia",
  "postalCode": "46001",
  "country": "España",
  "notes": null,
  "isActive": true,
  "updatedAt": "2026-11-27T08:00:00.000Z"
}

To create one: type (company or person) and name are required. A company has its tax number in cif; a person, their NIF or NIE in nid.

This is personal data: ask for the client rights only if your application really needs them, and handle them under the GDPR.

Remote orders

An order sent through the API reaches the POS as a remote order: it shows in the Orders list and every terminal shows an alert. It is not a sale: it becomes a ticket when it is paid on the POS, the normal way (VeriFactu, TicketBAI). The API takes no payment, not even a deposit.

Method Route Right
GET /orders (?status&from&to) orders:read
GET /orders/{id} orders:read
POST /orders orders:write
POST /orders/{id}/cancel orders:write

Create an order

curl -X POST https://api.tpvstream.com/<id>/v1/orders \
  -H "Authorization: Bearer tpv_live_…" \
  -H "Idempotency-Key: 9d2f…" \
  -H "Content-Type: application/json" \
  -d '{
    "externalRef": "WEB-1042",
    "customerName": "Laura Gómez",
    "customerPhone": "+34 600 111 222",
    "dueDate": "2026-11-28",
    "notes": "Pick-up at 13:30",
    "items": [
      { "productId": "8f1c…", "quantity": 2 },
      { "productId": "1a2b…", "quantity": 1, "notes": "No onion" }
    ]
  }'
  • externalRef (required): your order reference, unique per key. Sending it again answers 409 DUPLICATE_REF: an order never comes in twice.
  • customerName or clientId: one of them is required.
  • items: 1 to 200 lines. Whole quantities, except for a product sold by weight.
  • dueDate: delivery or pick-up date (YYYY-MM-DD).
  • The price and VAT of each line come from the POS catalogue. Prices you send are ignored.

Answer 201:

{
  "id": "e7a1…",
  "number": 58,
  "status": "pending",
  "externalRef": "WEB-1042",
  "items": [
    { "productId": "8f1c…", "name": "Cheesecake", "quantity": 2, "unitPriceCents": 1800, "taxRate": 10, "notes": null }
  ],
  "totalCents": 4350,
  "customerName": "Laura Gómez",
  "customerPhone": "+34 600 111 222",
  "clientId": null,
  "dueDate": "2026-11-28",
  "notes": "Pick-up at 13:30",
  "ticketId": null,
  "createdAt": "2026-11-27T10:15:00.000Z",
  "deliveredAt": null
}

Statuses

pending (received) → in_progress (being prepared) → ready → delivered. Or cancelled.

The POS changes the status; once paid, ticketId gives the ticket. To know without asking, use the order.status_changed webhook (Webhooks).

Cancel

POST /orders/{id}/cancel cancels an order only while it is pending. After that, only the POS can cancel it.

WhatsApp