Skip to main content

REST API: Suppliers & Purchases

How to read and create suppliers, manage their catalog items, and generate purchases. (Note: in the API, the term “vendor” is still used for backward compatibility.)

Gustavo Vera avatar
Written by Gustavo Vera
Updated over 3 weeks ago

1. Overview

Each cost center can have multiple suppliers.
Each supplier provides a list of items, each with a vendor-specific code (codi), description, purchase format, and price.

A supplier item may be linked to a tSpoonLab product or not.
You can load a supplier’s full catalog and link only those items you purchase regularly.


1.1 REST API: Login

To call our APIs, first authenticate via a login call.
This call returns a token that must be included in every subsequent request.

[email protected] password=XXXXXXX url=https://www.tspoonlab.com/recipes/api authenticate="username=$username&password=$password"  echo -n 'rememberme:' > rememberme.txt curl -v --data "$authenticate" "$url/login" >> rememberme.txt

For later calls, add the token to your headers:

curl -X PUT -v -H "$(cat rememberme.txt)" "$url/integration/call"

1.2 REST API: Select a Cost Center / Restaurant

Most requests refer to a cost center (usually a restaurant).

To retrieve the list of cost centers and IDs, see:
REST API: Get a List of Cost Centers

The cost center identifier corresponds to idOrderCenter in class UserOrderCenter.
Add this identifier to your headers for all subsequent calls:

echo -n 'order:351583444167656299610202XXXXXXXXXXXX' >> rememberme.txt

Headers example:

rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX order:351583444167656299610202XXXXXXXXXXXX

1.3 REST API: List all Suppliers

Endpoint

GET https://www.tspoonlab.com/recipes/api/listVendorsPaged

Query params

Param

Type

Required

Description

start

int

first row index

rows

int

number of rows to return

filter

string

text filter by supplier name

hidden

boolean

only return hidden suppliers

Response

class TypeEntry {   String id;   String descr;   String codi;   boolean defecte;   String descrType;   String idType;   EntityBaseDescr orderCenter; }  class EntityBaseDescr {   String id;   String descr; }

Explanation

  • id: supplier ID

  • descr: supplier name

  • codi: supplier code

  • defecte: true if this is the default supplier (used when no linked item exists)

  • idType, descrType: supplier classification

  • orderCenter: if supplier is linked to another client (e.g. central kitchen)


1.4 REST API: List Supplier Types

GET https://www.tspoonlab.com/recipes/api/listVendorTypesPaged

Query params

Param

Type

Required

start

int

rows

int

filter

string

Response

class EntityBaseBoolCodi {   String id;   String descr;   String codi; }

1.5 REST API: Create / Delete a Supplier Type

Create

POST https://www.tspoonlab.com/recipes/api/vendorType

Body

class NewVendorType {   String descr;   String codi;   String comment; }

Response

class IdWrapper { String id; }

Delete

DELETE https://www.tspoonlab.com/recipes/api/vendorType/{idVendorType}

1.6 REST API: Create a Supplier

Endpoint

POST https://www.tspoonlab.com/recipes/api/vendor

Body

class NewVendor {   String descr;   Boolean defecte;   String comment;   String mailcc;   String web;   String codi;   String nif;   String address;   String city;   String cp;   boolean creditor;   String idVendorType;   List<NewVendorContact> listContact;   List<NewVendorMail> listMail; }  class NewVendorContact {   String descr;  // contact name   String phone; }  class NewVendorMail {   String descr;  // email address }

Notes

  • defecte: set as default supplier

  • mailcc: CC address for purchase emails

  • nif: tax ID

  • creditor: marks as creditor (non-typical supplier)

  • idVendorType: optional supplier type

Response

class IdWrapper { String id; }

1.7 REST API: Delete / Hide / Unhide a Supplier

Suppliers with existing purchases cannot be deleted — hide them instead.

Delete

DELETE https://www.tspoonlab.com/recipes/api/vendor/{idVendor}

Hide

PUT https://www.tspoonlab.com/recipes/api/vendor/{idVendor}/hide

Unhide

PUT https://www.tspoonlab.com/recipes/api/vendor/{idVendor}/unhide

1.8 REST API: Get Supplier Details

GET https://www.tspoonlab.com/recipes/api/vendor/{idVendor}

Response (simplified)

class Vendor {   String id;   String descr;   Boolean defecte;   String comment;   String mailcc;   String web;   String codi;   String nif;   boolean creditor;   String address;   String city;   String cp;   List<VendorContact> listContact;   List<VendorMail> listMail;   List<VendorComponent> listComponent;   List<VendorOther> listOther;   List<VendorOrder> listOrders; }

Key Lists

  • listComponent: linked supplier items (connected to tSpoonLab products)

  • listOther: unlinked supplier items

  • listOrders: recent purchases (10 latest)

Unlinked Supplier Item

class VendorOther {   String id;   String descr;   String codi;   Double cost;   String comment;   String lastModified; }

Linked Supplier Item

class VendorComponent {   String id;   String descr;   String codi;   Double cost;   String comment;   String lastModified;   String unit;   String idUnit;   Boolean defecte;   String idComponent;   String component;   List<Format> listFormat; }  class Format {   String id;   String descr;   String comment;   String codi;   Double costFormat;   String lastModified;   Double quantityFormat;   String unitFormat;   String idUnitFormat; }

Recent Purchases (summary)

class VendorOrder extends EntityBaseDescr {   String idProveidorComanda;   Double cost;   String dateGenerated;   int type; // 0=pending send, 1=pending receive, 2=received }

For more than 10 purchases:

GET https://www.tspoonlab.com/recipes/api/vendor/{idVendor} ?start=0&rows=100

1.9 REST API: Add / Remove Unlinked Supplier Items

Add

POST https://www.tspoonlab.com/recipes/api/vendor/{idVendor}/components/other

Body

class NewVendorOther {   String descr;   String codi;   Double cost;   String comment; }

Delete

DELETE https://www.tspoonlab.com/recipes/api/vendor/{idVendor}/component/{idVendorComponent}

1.10 REST API: Add / Remove Linked Supplier Items

You can add multiple linked items in a single call.

Add

POST https://www.tspoonlab.com/recipes/api/vendor/{idVendor}/components/add

Body

class NewVendorComponentWrapper {   List<NewVendorComponent> components; }  class NewVendorComponent {   String codi;   String descr;   String comment;   String idComponent;   // target product   Double cost;   Boolean defecte;      // default supplier for product   List<NewFormat> listFormat; }  class NewFormat {   String codi;   String descr;   String comment;   String idUnit;   Double quantity;   Double cost; }

Best practice:
One VendorComponent per format.
If a supplier sells the same product in multiple formats, create separate entries.

Remove

DELETE https://www.tspoonlab.com/recipes/api/vendor/{idVendor}/component/{idVendorComponent}

1.11 REST API: Manage Purchases (Orders)

A Purchase Order groups multiple supplier purchases under one operation (e.g., daily order).

List Orders

GET https://www.tspoonlab.com/recipes/api/listOrdersPagedExt

Create Order

POST https://www.tspoonlab.com/recipes/api/order
class NewOrder {   String descr;   Date data; }

Delete Order

DELETE https://www.tspoonlab.com/recipes/api/order/{idOrder}

Get Full Order (with supplier purchases)

POST https://www.tspoonlab.com/recipes/api/order/{idOrder}
class Order {   String id;   String descr;   String dateGenerated;   Date data;   Double cost;   Double taxes;   List<OrderVendor> listComandes; }

Supplier Purchase

class OrderVendor {   String id;   String idProveidorComanda;   String idVendor;   short status; // 0=pending send, 1=pending receive, 2=received   String comment;   String dateGenerated;   String dateReceptionFlat;   Double cost;   Double taxes;   List<OrderVendorComponent> listComponents; }

Purchase Line Items

class OrderVendorComponent {   String id;   String idVendorComponent;   String comment;   boolean rebut;   Double cost;   Double quantity;   Double quantityFormat;   String idUnit;   String idUnitFormat;   String idFormat; }

To compute total line cost:

  • Without format → cost * quantity

  • With format → cost * quantityFormat

Create a Supplier Purchase

POST https://www.tspoonlab.com/recipes/api/order/{idOrder}/vendor/{idVendor}

Response

class IdWrapper { String id; } // Returns purchase ID

Add Items to Purchase

PUT https://www.tspoonlab.com/recipes/api/orderVendor/{idOrderVendor}/edit
class NewOrderComponentData {   List<NewOrderComponent> components; }  class NewOrderComponent {   String idVendorComponent;   Double quantity;   Double quantityFormat;   String idUnit;   String idUnitFormat;   String idFormat;   Double cost;   String comment; }

Delete Purchase

DELETE https://www.tspoonlab.com/recipes/api/orderVendor/{id}

Notes

  • All endpoints require a valid rememberme token and order (cost center) header.

  • Always use HTTPS.

  • Prefer one VendorComponent per purchase format.

  • The API returns all numeric costs excluding tax (net values).

Did this answer your question?