Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ALEJ4NDRO2025/urban-store/llms.txt

Use this file to discover all available pages before exploring further.

The /api/products/{slug}/ endpoint addresses a single product document by its unique slug. GET is open to the public and returns the complete product record including per-variant stock and all image URLs. PUT and DELETE are restricted to administrators (JWT must carry is_admin: true) and allow in-place edits or permanent removal.

GET /api/products/{slug}/

Retrieve all fields for a single product by its slug. Authentication: None (public)

Path Parameters

slug
string
required
The unique URL-safe slug that identifies the product. Slugs are assigned at creation time and never change. Example: urban-classic-tee

Response Fields

id
string
MongoDB ObjectId of the product, serialized as a string.
name
string
Display name of the product.
slug
string
URL-safe unique identifier.
description
string
Long-form product description. May be an empty string if not set.
price
string
Product price as a decimal string with two decimal places (e.g. "49.99").
category
string
Category the product belongs to.
stock
integer
Total aggregate stock count across all variants.
sizes
array of strings
Available sizes, e.g. ["S", "M", "L", "XL"].
colors
array of strings
Available colors, e.g. ["negro", "blanco"].
images
array of strings
Cloudinary image URLs for the product.
stock_by_variant
object
Per-variant stock counts keyed by "size|color". Example: {"M|negro": 5, "L|blanco": 3}.

Example

curl https://urban-store-api.example.com/api/products/urban-classic-tee/
200 OK:
{
  "id": "665f1a2b3c4d5e6f7a8b9c0d",
  "name": "Urban Classic Tee",
  "slug": "urban-classic-tee",
  "description": "A clean staple for every wardrobe.",
  "price": "49.99",
  "category": "streetwear",
  "stock": 24,
  "sizes": ["S", "M", "L", "XL"],
  "colors": ["negro", "blanco"],
  "images": [
    "https://res.cloudinary.com/urban-store/image/upload/v1/products/classic-tee-1.jpg",
    "https://res.cloudinary.com/urban-store/image/upload/v1/products/classic-tee-2.jpg"
  ],
  "stock_by_variant": {
    "S|negro": 4,
    "S|blanco": 3,
    "M|negro": 5,
    "M|blanco": 4,
    "L|negro": 3,
    "L|blanco": 3,
    "XL|negro": 1,
    "XL|blanco": 1
  }
}
404 Not Found — no product exists with the given slug:
{
  "error": "Producto no encontrado"
}

PUT /api/products/{slug}/

Update one or more fields of an existing product. Only fields included in the request body are changed — this is a partial update. Authentication: Bearer token required. The JWT payload must contain is_admin: true.
Authorization: Bearer <admin_token>

Path Parameters

slug
string
required
The slug of the product to update.

Request Body

All fields are optional. Send only the fields you want to change. Field definitions match those used in POST /api/products/.
name
string
New display name.
description
string
Updated product description.
price
decimal
New price with up to two decimal places.
category
string
Replacement category name.
stock
integer
Updated total stock count.
sizes
array of strings
Replacement sizes list. This overwrites the entire existing array.
colors
array of strings
Replacement colors list. This overwrites the entire existing array.
stock_by_variant
object
Replacement variant-stock map. This overwrites the entire existing object.
images
array of strings
Replacement Cloudinary image URL list.
is_active
boolean
Set to false to hide the product from the public catalog without deleting it.

Response

200 OK:
{
  "message": "Producto actualizado"
}
400 Bad Request — validation failed:
{
  "price": ["A valid number is required."]
}
404 Not Found — no product exists with the given slug:
{
  "error": "Producto no encontrado"
}

Example — Updating stock_by_variant

curl -X PUT https://urban-store-api.example.com/api/products/urban-classic-tee/ \
  -H "Authorization: Bearer <admin_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "stock": 18,
    "stock_by_variant": {
      "S|negro": 2,
      "S|blanco": 3,
      "M|negro": 5,
      "M|blanco": 4,
      "L|negro": 2,
      "L|blanco": 1,
      "XL|negro": 0,
      "XL|blanco": 1
    }
  }'

DELETE /api/products/{slug}/

Permanently remove a product document from MongoDB. Authentication: Bearer token required. The JWT payload must contain is_admin: true.
Authorization: Bearer <admin_token>

Path Parameters

slug
string
required
The slug of the product to delete.

Response

200 OK:
{
  "message": "Producto eliminado"
}
404 Not Found — no product exists with the given slug:
{
  "error": "Producto no encontrado"
}

Example

curl -X DELETE https://urban-store-api.example.com/api/products/urban-classic-tee/ \
  -H "Authorization: Bearer <admin_token>"
Prefer soft-deletion over hard deletion. Deleting a product is permanent and removes it from MongoDB entirely. If the product has appeared in past orders or analytics, consider using PUT to set is_active: false instead. This hides the product from the public catalog while preserving its record for historical reference.

Build docs developers (and LLMs) love