Skip to Content
MySagra 1.4.0 is released 🎉
API ReferenceCategories

Categories

Manage menu categories (e.g. “Pizzeria”, “Grill”, “Drinks”). Categories group food items and can be toggled on/off to control availability.

Category Object

{ "id": "clxyz123456789abcdef", "name": "Pizzeria", "available": true, "position": 1 }
FieldTypeDescription
idstringUnique identifier (CUID)
namestringCategory name
availablebooleanWhether the category is available for ordering
positionintegerDisplay order position

GET /v1/categories

Retrieve all categories with optional filtering.

Authentication:

  • available=true: Public, no authentication required
  • Otherwise: Bearer token (admin)

Query Parameters

ParameterTypeDescription
availablebooleanFilter by availability
includestringSet to foods to include food items with ingredients

Response 200 OK

[ { "id": "clxyz123456789abcdef", "name": "Pizzeria", "available": true, "position": 1 } ]

GET /v1/categories/{id}

Retrieve a single category by ID.

Authentication: Bearer token (admin)

Path Parameters

ParameterTypeDescription
idstringCategory ID (CUID)

Query Parameters

ParameterTypeDescription
includestringSet to foods to include food items

Response 200 OK

Returns a Category Object.

Errors

StatusDescription
404Category not found

POST /v1/categories

Create a new category.

Authentication: Bearer token (admin)

Request Body

{ "name": "Pizzeria", "available": true, "position": 1, "printerId": "clxyz987654321fedcba" }
FieldTypeRequiredDescription
namestringYesCategory name
availablebooleanNoAvailability (default: true)
positionintegerNoDisplay position
printerIdstring | nullNoAssociated printer ID

Response 201 Created

Errors

StatusDescription
400Invalid request body

PUT /v1/categories/{id}

Update an existing category (full replacement).

Authentication: Bearer token (admin)

Note: Changing available will also update the availability of all associated foods. Changing printerId will also cascade to all associated foods — set to null to remove the printer association from the category and all its foods.

Path Parameters

ParameterTypeDescription
idstringCategory ID (CUID)

Request Body

Same as POST.

Response 200 OK

Errors

StatusDescription
400Invalid request body
404Category not found
409Category conflict

PATCH /v1/categories/{id}

Partially update a category’s availability or printer.

Authentication: Bearer token (admin)

Note: Changing available will also update the availability of all associated food items. Changing printerId will also update the printer of all associated foods — set to null to remove the association.

Path Parameters

ParameterTypeDescription
idstringCategory ID (CUID)

Request Body

{ "available": true, "printerId": "clxyz987654321fedcba" }
FieldTypeRequiredDescription
availablebooleanNoNew availability status
printerIdstring | nullNoNew printer ID, or null to remove

Response 200 OK

Errors

StatusDescription
404Category not found

PATCH /v1/categories/{id}/image

Upload or update the category image.

Authentication: Bearer token (admin)

Path Parameters

ParameterTypeDescription
idstringCategory ID (CUID)

Request Body

multipart/form-data with the following field:

FieldTypeRequiredDescription
imagefileYesImage file to upload

Response 200 OK

Errors

StatusDescription
400Invalid or missing image file
404Category not found

DELETE /v1/categories/{id}

Delete a category.

Authentication: Bearer token (admin)

Path Parameters

ParameterTypeDescription
idstringCategory ID (CUID)

Response 204 No Content

Errors

StatusDescription
404Category not found
Last updated on