Skip to Content
MySagra 1.4.0 is released 🎉

Foods

Manage food items within categories. Foods can have ingredients, a custom printer, and can be toggled available/unavailable.

Food Object

{ "id": "clm9876543210", "name": "Pizza Margherita", "description": "Classic pizza with tomato and mozzarella", "price": 9.99, "categoryId": "clxyz123456789abcdef", "printerId": "clxyz987654321fedcba", "available": true, "category": { "id": "clxyz123456789abcdef", "name": "Pizzeria", "available": true, "position": 1 }, "ingredients": [ { "id": "clm111", "name": "Mozzarella" }, { "id": "clm222", "name": "Tomato Sauce" } ] }
FieldTypeDescription
idstringUnique identifier (CUID)
namestringFood name
descriptionstringFood description
pricenumberPrice in currency units
categoryIdstringParent category ID
printerIdstring | nullOptional printer override
availablebooleanWhether the item is available
categoryobjectParent category details
ingredientsarrayList of ingredients (only with include=ingredients)

GET /v1/foods

Retrieve all food items with optional filtering.

Authentication: Bearer token

  • Non-admin users: only available=true foods
  • Admin users: all foods

Query Parameters

ParameterTypeDescription
includestringSet to ingredients to include ingredient details
availablebooleanFilter by availability
categorystring[]Filter by category name(s) — can be repeated

Example

GET /v1/foods?include=ingredients&available=true&category=Pizzeria&category=Grill

Response 200 OK

Returns an array of Food Objects.


GET /v1/foods/{id}

Retrieve a single food item by ID.

Authentication: Bearer token

Path Parameters

ParameterTypeDescription
idstringFood ID (CUID)

Query Parameters

ParameterTypeDescription
includestringSet to ingredients to include ingredient details

Response 200 OK

Returns a Food Object.

Errors

StatusDescription
400Invalid ID parameter
404Food item not found

POST /v1/foods

Create a new food item.

Authentication: Bearer token (admin)

Request Body

{ "name": "Pizza Margherita", "description": "Classic pizza with tomato and mozzarella", "price": 9.99, "categoryId": "clxyz123456789abcdef", "printerId": "clxyz987654321fedcba", "available": true, "ingredients": [ { "id": "clm1234567890" }, { "id": "clm0987654321" } ] }
FieldTypeRequiredDescription
namestringYesFood name
descriptionstringNoFood description
pricenumberYesPrice
categoryIdstringYesParent category ID
printerIdstring | nullNoPrinter override
availablebooleanYesAvailability status
ingredientsarrayNoArray of { id: string } ingredient references

Response 201 Created

Returns the created Food Object.

Errors

StatusDescription
400Invalid request body
409Food name already exists

PUT /v1/foods/{id}

Update a food item (full replacement).

Authentication: Bearer token (admin)

Path Parameters

ParameterTypeDescription
idstringFood ID (CUID)

Request Body

Same as POST.

Response 200 OK

Returns the updated Food Object.

Errors

StatusDescription
400Invalid request body or ID
404Food item not found
409Food name already exists

PATCH /v1/foods/{id}

Update the availability status (or printer) of a food item.

Authentication: Bearer token (admin)

Path Parameters

ParameterTypeDescription
idstringFood ID (CUID)

Request Body

{ "available": false, "printerId": "clxyz987654321fedcba" }
FieldTypeRequiredDescription
availablebooleanNoNew availability status
printerIdstring | nullNoPrinter override, or null to remove

Response 200 OK

Returns the updated Food Object.

Errors

StatusDescription
400Invalid ID or request body
401Unauthorized — authentication required
403Forbidden — admin access required
404Food item not found

DELETE /v1/foods/{id}

Delete a food item.

Authentication: Bearer token (admin)

Path Parameters

ParameterTypeDescription
idstringFood ID (CUID)

Response 204 No Content

Errors

StatusDescription
400Invalid ID parameter
404Food item not found
Last updated on