1. Store Management
This article explains how to manage stores (warehouses) in tSpoonLab — create, retrieve, update, and link components and locations.
1.1 REST API: Login
To make API calls, you must first authenticate via a login request.
The login returns a token, which must be included in every subsequent request.
Example (cURL)
[email protected] password=XXXXXXX url=https://app.tspoonlab.com/recipes/api authenticate="username=$username&password=$password" echo -n 'rememberme:' > rememberme.txt curl -v --data "$authenticate" "$url/login" >> rememberme.txt
Use the token in all following calls:
curl -X PUT -v -H "$(cat rememberme.txt)" "$url/integration/call"
1.2 Select a Cost Center / Restaurant
Most requests relate to a specific cost center (usually a restaurant).
To retrieve cost centers and their IDs, see:
REST API: Get a list of cost centers
Add the idOrderCenter
value to your headers:
echo -n 'order:351583444167656299610202XXXXXXXXXXXX' >> rememberme.txt
Headers example
rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX order:351583444167656299610202XXXXXXXXXXXX
1.3 Retrieve all Stores
Endpoint
GET https://app.tspoonlab.com/recipes/api/listStoresPaged
Query params
start
(int, required) – first row indexrows
(int, required) – number of rows to returnfilter
(string, optional) – text filter by name or code
Response
class StoreEntry { String id; String descr; boolean defecte; }
Fields
id
: store IDdescr
: store namedefecte
: true if it’s the default store
1.4 Retrieve a Store
Endpoint
GET https://app.tspoonlab.com/recipes/api/store/{idStore}/inventory/{idInventory}/components/num/{numComponents}
Parameters
idStore
: store identifieridInventory
: inventory ID (null = last inventory)numComponents
: number of components to return
Response
class Store { String id; String descr; String comment; List<StoreComponent> listComponent; } class StoreComponent { String id; String descr; String idComponent; String idUse; String use; String unit; String idUnit; Double quantityInventory; Double quantityInput; Double quantityOutput; Double quantityDesviation; }
To retrieve more components:
GET https://app.tspoonlab.com/recipes/api/store/{idStore}/inventory/{idInventory}/components/paged
With params:
start
,rows
,filter
(optional)
Returns a list of StoreComponent
.
1.5 Create a Store
Endpoint
POST https://app.tspoonlab.com/recipes/api/store
Body
class NewStore { String descr; // Store name String comment; // Comment boolean defaultReception; // Default reception store boolean defaultProduction; // Default production store boolean defaultExpedition; // Default expedition store }
1.6 Delete a Store
Endpoint
DELETE https://app.tspoonlab.com/recipes/api/store/{idStore}
Deleting a store also removes all its inventories.
1.7 Add Components to a Store
Endpoint
PUT https://app.tspoonlab.com/recipes/api/store/{idStore}/components
Body
class NewStoreComponentsWrapper { List<NewStoreComponent> components; } class NewStoreComponent { String id; // null when adding new String idComponent; // component ID String idUse; // cut or subproduct ID }
1.8 Remove a Component from a Store
Endpoint
DELETE https://app.tspoonlab.com/recipes/api/store/{idStore}/component/{idStoreComponent}
1.9 List Store Locations
Endpoint
GET https://app.tspoonlab.com/recipes/api/store/{idStore}/locations
Response
class StoreLocation { String id; String descr; Integer countStoreComponents; String comment; }
1.10 Create a Location
Endpoint
POST https://app.tspoonlab.com/recipes/api/store/{idStore}/location
Body
class NewStoreLocation { String descr; String comment; }
Response
class IdWrapper { String id; }
1.11 Delete a Location
Endpoint
DELETE https://app.tspoonlab.com/recipes/api/store/{idStore}/location/{idStoreLocation}
1.12 List Components in a Location
Endpoint
GET https://app.tspoonlab.com/recipes/api/storeLocation/{idStoreLocation}/storeComponents
Response
class StoreLocationStoreComponent { String id; String descr; String idComponent; String idUse; String use; }
1.13 Add Components to a Location
Endpoint
POST https://app.tspoonlab.com/recipes/api/storeLocation/{idStoreLocation}/storeComponents/add
Body
class NewStoreLocationStoreComponentsWrapper { List<NewStoreLocationStoreComponent> storeComponents; } class NewStoreLocationStoreComponent { String id; // null when adding String idStoreComponent; }
1.14 Remove Components from a Location
Endpoint
POST https://app.tspoonlab.com/recipes/api/storeLocation/{idStoreLocation}/storeComponents/delete
Body
class NewStoreLocationStoreComponentsWrapper { List<NewStoreLocationStoreComponent> storeComponents; } class NewStoreLocationStoreComponent { String id; // ID to delete String idStoreComponent; }
1.15 Move Components between Stores
Endpoint
PUT https://app.tspoonlab.com/recipes/api/store/{idStore}/components/move/some/{idStoreDest}
Parameters
idStore
: source storeidStoreDest
: destination store
Body
class NewListIds { List<String> listIds; // IDs of store components to move }
1.16 List All Inventories
Endpoint
GET https://app.tspoonlab.com/recipes/api/listInventoriesPaged
Query params
start
,rows
(int, required) – paginationfilter
(string, optional)year
,month
(int, optional) – filter by date
Response
class EntityBaseDate { String id; // Inventory ID String descr; // Store name String idAux; // Store ID Integer year; Integer month; Date dateGenerated; // Inventory date }
Results are sorted by dateGenerated
(descending).
1.17 Get the Total Value of an Inventory
Endpoint
GET https://app.tspoonlab.com/recipes/api/inventory/{idInventory}/total
Response
class DoubleWrapper { Double value; } // inventory valuation
1.18 Retrieve Component Quantities in an Inventory
Endpoint
GET https://app.tspoonlab.com/recipes/api/inventory/{idInventory}/components/paged?start=0&rows=50
Query params
start
,rows
(required)filter
(optional)
Response
class StoreComponent { String id; // inventory line ID String descr; // product name String idComponent; Double quantity; // counted quantity Double cost; // cost per count }
Notes
All endpoints require valid headers:
rememberme
(token)order
(cost center ID)
Use HTTPS for all calls.
Deleting a store also removes its inventories and related records.
For performance, always use pagination when retrieving store components.