Skip to main content

Endpoint

PUT /stores/:id
Update information for a specific store. Only the store owner can update their store.

Authentication

Required. Must be authenticated as a store employee (owner) and must own the store being updated. Headers:
  • Authorization: Bearer <token> - JWT token from authentication
Required role: store_employee

Path parameters

id
string
required
The unique identifier of the store to update (MongoDB ObjectId)

Body parameters

This endpoint accepts both JSON and multipart/form-data. Use multipart/form-data when uploading files.
name
string
Store name
description
string
Store description (can be null)
upi_id
string
UPI ID for payments. Must match format: username@provider (e.g., store@paytm)
is_active
boolean
Whether the store is active and visible to customers
operating_hours
object | string
Operating hours configuration. Can be a JSON object or a stringified JSON. Example:
{
  "monday": { "open": "08:00", "close": "18:00" },
  "tuesday": { "open": "08:00", "close": "18:00" }
}
image_url
string
URL to store image (if not uploading a file)
qr_code_url
string
URL to QR code image (if not uploading a file)
image
file
Store image file to upload (multipart form field)
qr_code
file
QR code image file to upload (multipart form field)

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Success or error message
data
object
Contains the response data (only present when success is true)

Example requests

Update with JSON

curl -X PUT https://api.campusbite.com/stores/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Campus Cafe - Main Branch",
    "description": "Your favorite campus coffee shop with fresh pastries",
    "is_active": true,
    "operating_hours": {
      "monday": { "open": "07:00", "close": "19:00" },
      "tuesday": { "open": "07:00", "close": "19:00" }
    }
  }'

Update with file upload

curl -X PUT https://api.campusbite.com/stores/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer <token>" \
  -F "name=Campus Cafe - Main Branch" \
  -F "image=@/path/to/store-image.jpg" \
  -F "qr_code=@/path/to/qr-code.png"

Example responses

Success response

{
  "success": true,
  "message": "Store updated successfully.",
  "data": {
    "store": {
      "id": "507f1f77bcf86cd799439011",
      "_id": "507f1f77bcf86cd799439011",
      "name": "Campus Cafe - Main Branch",
      "description": "Your favorite campus coffee shop with fresh pastries",
      "upi_id": "campuscafe@paytm",
      "owner_id": "507f1f77bcf86cd799439012",
      "ownerId": "507f1f77bcf86cd799439012",
      "is_active": true,
      "isActive": true,
      "operating_hours": {
        "monday": { "open": "07:00", "close": "19:00" },
        "tuesday": { "open": "07:00", "close": "19:00" }
      },
      "operatingHours": {
        "monday": { "open": "07:00", "close": "19:00" },
        "tuesday": { "open": "07:00", "close": "19:00" }
      },
      "image_url": "/uploads/stores/campus-cafe.jpg",
      "imageUrl": "/uploads/stores/campus-cafe.jpg",
      "qr_code_url": "/uploads/qr-codes/campus-cafe-qr.png",
      "qrCodeUrl": "/uploads/qr-codes/campus-cafe-qr.png",
      "created_at": "2024-01-15T10:30:00.000Z",
      "createdAt": "2024-01-15T10:30:00.000Z",
      "updated_at": "2024-01-22T16:20:00.000Z",
      "updatedAt": "2024-01-22T16:20:00.000Z"
    }
  }
}

Error responses

Store not found
{
  "success": false,
  "message": "Store not found."
}
Unauthorized
{
  "success": false,
  "message": "You are not authorized to update this store."
}
Invalid UPI ID
{
  "success": false,
  "message": "Invalid UPI ID format."
}

Notes

UPI ID validation: The UPI ID must match the pattern username@provider where:
  • Username: 2-256 characters (alphanumeric, dots, underscores, hyphens)
  • Provider: 2-64 alphabetic characters
  • UPI IDs are automatically normalized to lowercase
File uploads: When uploading files, the endpoint accepts two file fields:
  • image: Store image (max 1 file)
  • qr_code: QR code image (max 1 file)
Uploaded files are automatically stored and their paths are resolved to accessible URLs.
Authorization: Only the store owner (identified by owner_id) can update the store. The user making the request must:
  1. Be authenticated with a valid JWT token
  2. Have the store_employee role
  3. Own the store (their user ID must match the store’s owner_id)

Build docs developers (and LLMs) love