Skip to main content

Endpoint

PATCH /api/menu/:id/availability

Authentication

This endpoint requires authentication and store employee authorization.
This is a convenience endpoint that toggles the is_available field. If the item is currently available, it becomes unavailable, and vice versa. You don’t need to specify the new state.

Request

Path parameters

id
string
required
MongoDB ObjectId of the menu item to toggle

Headers

Authorization
string
required
Bearer token for authentication
This endpoint does not require a request body. It automatically toggles the current availability state.

Response

success
boolean
Indicates if the request was successful
message
string
Human-readable message describing the result. Will say either “Menu item is now available.” or “Menu item is now unavailable.”
data
object
Contains the updated menu item data
data.menuItem
object
The updated menu item object
data.menuItem.id
string
Unique identifier for the menu item
data.menuItem.store_id
string
ID of the store this item belongs to
data.menuItem.name
string
Name of the menu item
data.menuItem.description
string
Description of the menu item
data.menuItem.price
number
Price of the menu item
data.menuItem.image_url
string
URL to the menu item image
data.menuItem.category
string
Category of the menu item
data.menuItem.is_available
boolean
New availability status (toggled from previous state)
data.menuItem.created_at
string
ISO 8601 timestamp of creation
data.menuItem.updated_at
string
ISO 8601 timestamp of last update

Examples

curl -X PATCH https://api.campusbite.com/api/menu/507f1f77bcf86cd799439011/availability \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Success response - Made available (200)

{
  "success": true,
  "message": "Menu item is now available.",
  "data": {
    "menuItem": {
      "id": "507f1f77bcf86cd799439011",
      "store_id": "507f191e810c19729de860ea",
      "name": "Classic Cheeseburger",
      "description": "Juicy beef patty with cheddar cheese, lettuce, tomato, and our special sauce",
      "price": 8.99,
      "image_url": "https://api.campusbite.com/uploads/burger-1234567890.jpg",
      "category": "Burgers",
      "is_available": true,
      "created_at": "2026-03-04T10:30:00.000Z",
      "updated_at": "2026-03-04T14:20:00.000Z"
    }
  }
}

Success response - Made unavailable (200)

{
  "success": true,
  "message": "Menu item is now unavailable.",
  "data": {
    "menuItem": {
      "id": "507f1f77bcf86cd799439011",
      "store_id": "507f191e810c19729de860ea",
      "name": "Classic Cheeseburger",
      "description": "Juicy beef patty with cheddar cheese, lettuce, tomato, and our special sauce",
      "price": 8.99,
      "image_url": "https://api.campusbite.com/uploads/burger-1234567890.jpg",
      "category": "Burgers",
      "is_available": false,
      "created_at": "2026-03-04T10:30:00.000Z",
      "updated_at": "2026-03-04T14:25:00.000Z"
    }
  }
}

Error responses

404 - Menu item not found

{
  "success": false,
  "message": "Menu item not found."
}

403 - Not authorized

This error occurs when you try to toggle availability for a menu item that belongs to another store.
{
  "success": false,
  "message": "You are not authorized to update this menu item."
}

401 - Unauthorized

{
  "success": false,
  "message": "Authentication required."
}

Use cases

This endpoint is useful for:
  • Quickly marking items as out of stock during busy periods
  • Temporarily disabling seasonal items
  • Managing item availability based on inventory
  • Hiding items during preparation or menu updates
If you need to set a specific availability state, use the update menu item endpoint with the is_available parameter instead.

Build docs developers (and LLMs) love