Skip to main content

REST API: Allergens

How to Retrieve, Create, Update and Delete Allergens

Gustavo Vera avatar
Written by Gustavo Vera
Updated today

1. Allergen Management Overview

When a new account is created, tSpoonLab automatically includes the 14 official allergens defined by the European Union regulations.
Users can also create custom allergens for more detailed control.

Allergens are assigned to ingredients/products, based on the technical data sheets provided by suppliers — which must be archived to comply with health regulations.
Each assignment indicates whether the allergen is present or just a trace.

Recipes (intermediate preparations) and dishes (final elaborations) automatically inherit allergens based on their ingredients.
If the same allergen appears both as a trace and as a main allergen in different ingredients, the system will automatically register it as a main allergen.

In certain contexts (e.g., flour or nuts in shared production areas), you may also assign trace allergens directly to intermediate or final products.


1.1 REST API: Login

Authenticate before making API calls.

[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

Include the token in all subsequent headers:

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

1.2 Select a Cost Center / Restaurant

All operations must reference a cost center (usually a restaurant).

To retrieve the list of cost centers and their IDs, refer to:
Get a List of Cost Centers

Once you have the idOrderCenter, include it in the header along with the token:

rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX order:351583444167656299610202XXXXXXXXXXXX

1.3 Retrieve the List of Allergens

GET /listAllergiesPaged?filter=&rows=50&start=0

Query parameters

  • filter: (optional) filter by description

  • rows: number of rows to return

  • start: offset (first row to return)

Response example

[   {     "id": "194443382822263016755563050734447984070",     "descr": "Lupins"   },   {     "id": "181691964862034253332266321442051901807",     "descr": "Celery"   } ]

1.4 Retrieve a Specific Allergen

GET /allergy/{idAllergy}/components/num/{numChild}
  • idAllergy: allergen identifier

  • numChild: number of linked components to return

Response

class Allergy {  String id;  String descr;  String comment;  List<AllergyComponent> listComponentBase;  List<AllergyComponent> listComponentComplex; }  class AllergyComponent {  String id;           // relation ID between allergen and component  String descr;        // component name  String idComponent;  // component ID  boolean traces;      // true = trace, false = allergen  int type;            // 0=ingredient, 1=recipe, 2=material, 3=dish  Long color;          // component color (for ingredients) }

If you need more components (base or elaborated) for that allergen:

GET /allergy/{idAllergy}/base/{isBase}/components/paged?filter=&rows=20&start=20
  • isBase = true → base products (ingredients)

  • isBase = false → elaborated products (recipes or dishes)

Response: List<AllergyComponent>


1.5 Create a New Allergen

POST /allergy

Request body

class NewAllergy {  String descr;   // Allergen description  String comment; // Optional comment }

1.6 Update an Existing Allergen

PUT /allergy/{idAllergy}

Request body

class NewAllergy {  String descr;  String comment; }

1.7 Delete an Allergen

DELETE /allergy/{idAllergy}

This will remove the allergen from:

  • All base products (ingredients)

  • All elaborated products that use those ingredients

⚠️ Once deleted, the allergen disappears from all linked components and recalculated recipes.


1.8 Assign an Allergen to a Product

POST /allergy/{idAllergy}/components/add

Request body

class NewAllergyComponentsWrapper {  List<NewAllergyComponent> components; }  class NewAllergyComponent {  String id;          // must be null  String idComponent; // product ID  boolean traces;     // true if trace }

The response returns all base and elaborated products where this allergen was added (directly or indirectly):

class AllergyGroup {  List<AllergyComponent> listComponentBase;  List<AllergyComponent> listComponentComplex; }

1.9 Unassign (Remove) an Allergen from a Product

POST /allergy/{idAllergy}/components/remove

Request body

class NewAllergyComponentsWrapper {  List<DeleteAllergyComponent> components; }  class DeleteAllergyComponent {  String id; // relation ID between allergen and component }

Response
A list of all products from which the allergen was removed.

class ComponentWithType {  String id;  String descr;  int type;   // 0=ingredient, 1=recipe, 2=material, 3=dish  Long color; // color for ingredients }

Field Summary

Field

Description

id

Unique identifier of the allergen or relation

descr

Description (name) of allergen or product

comment

Optional comment

traces

Indicates if it’s a trace (true) or main allergen (false)

type

0=ingredient, 1=recipe, 2=material, 3=dish

color

Display color assigned to the ingredient


General Notes

  • The 14 default allergens follow EU regulation, but users can freely add or edit their own.

  • Trace allergens are treated as distinct from primary allergens but propagate to all related products.

  • When the same allergen is both trace and main, main takes precedence.

  • Deleted allergens cascade through all related ingredients and recipes.

  • Always use IDs (idAllergy, idComponent) from the relevant retrieval endpoints.

Did this answer your question?