Skip to main content

Overview

The Products API allows you to retrieve, create, update, and delete products in the FitAiid store. Products include fitness equipment, supplements, apparel, and digital fitness plans.

Product Object

The Product object contains all information about items available for purchase.
id
string
Unique identifier for the product (MongoDB ObjectId)
name
string
required
Product name (2-200 characters)
description
string
required
Detailed product description (10-2000 characters)
price
integer
required
Product price in cents (Colombian Pesos). Must be between 0 and 999,999,999
originalPrice
integer
Original price before discount (must be greater than or equal to current price)
discount
number
Discount percentage (0-100). Auto-calculated if originalPrice is set
category
string
required
Product category
subcategory
string
Product subcategory
brand
string
required
Product brand name (1-50 characters)
images
array
required
Array of image URLs (1-10 images). Accepts trusted domains (Unsplash, Cloudinary, etc.) or URLs with image extensions
mainImage
string
required
Primary product image URL
quantity
integer
required
Available stock quantity (0-99,999)
inStock
boolean
Whether product is in stock. Auto-synced with quantity
rating
object
Product rating information
status
string
Product status: active, inactive, discontinued, or coming-soon
Whether product is featured
salesCount
integer
Total number of sales
viewCount
integer
Number of product views

Get All Products

Query Parameters

category
string
Filter by category (e.g., laptops, smartphones)
brand
string
Filter by brand name (case-insensitive)
minPrice
integer
Minimum price filter in cents
maxPrice
integer
Maximum price filter in cents
inStock
boolean
Filter by stock availability (true or false)
Search query for name, description, or brand
sortBy
string
Sort order
page
integer
default:"1"
Page number for pagination
limit
integer
default:"12"
Number of products per page

Response

{
  "success": true,
  "count": 12,
  "total": 150,
  "pagination": {
    "currentPage": 1,
    "totalPages": 13,
    "limit": 12,
    "hasNextPage": true,
    "hasPrevPage": false
  },
  "data": [
    {
      "id": "507f1f77bcf86cd799439011",
      "name": "Protein Powder Premium",
      "description": "High-quality whey protein isolate",
      "price": 89900,
      "originalPrice": 119900,
      "discount": 25,
      "category": "supplements",
      "brand": "FitAiid Pro",
      "mainImage": "https://images.unsplash.com/photo-1593095948071-474c5cc2989d",
      "images": [
        "https://images.unsplash.com/photo-1593095948071-474c5cc2989d"
      ],
      "quantity": 45,
      "inStock": true,
      "rating": {
        "average": 4.5,
        "count": 128
      },
      "status": "active",
      "featured": true,
      "formattedPrice": "$89,900"
    }
  ]
}

Get Product by ID

Path Parameters

id
string
required
MongoDB ObjectId of the product

Response

{
  "success": true,
  "data": {
    "id": "507f1f77bcf86cd799439011",
    "name": "Protein Powder Premium",
    "description": "High-quality whey protein isolate with 25g protein per serving...",
    "price": 89900,
    "originalPrice": 119900,
    "discount": 25,
    "category": "supplements",
    "subcategory": "protein",
    "brand": "FitAiid Pro",
    "mainImage": "https://images.unsplash.com/photo-1593095948071-474c5cc2989d",
    "images": [
      "https://images.unsplash.com/photo-1593095948071-474c5cc2989d",
      "https://images.unsplash.com/photo-1579722820303-d8e4223a0500"
    ],
    "quantity": 45,
    "inStock": true,
    "lowStockAlert": 5,
    "rating": {
      "average": 4.5,
      "count": 128,
      "breakdown": {
        "five": 85,
        "four": 30,
        "three": 10,
        "two": 2,
        "one": 1
      }
    },
    "tags": ["protein", "whey", "isolate", "muscle-building"],
    "status": "active",
    "featured": true,
    "salesCount": 453,
    "viewCount": 1250,
    "stockStatus": "in-stock",
    "discountPercentage": 25,
    "formattedPrice": "$89,900",
    "formattedOriginalPrice": "$119,900",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-03-01T14:20:00.000Z"
  }
}

Create Product

This endpoint requires authentication with an admin account. Include the JWT token in the Authorization header.

Headers

Authorization
string
required
Bearer token: Bearer YOUR_JWT_TOKEN

Body Parameters

name
string
required
Product name (2-200 characters, must be unique)
description
string
required
Product description (10-2000 characters)
price
integer
required
Product price in cents (10,000 - 50,000,000)
category
string
required
Product category from allowed values
brand
string
required
Product brand (1-50 characters)
mainImage
string
required
Primary product image URL
images
array
required
Array of image URLs (1-10 images)
quantity
integer
required
Initial stock quantity (0-99,999)
originalPrice
integer
Original price before discount
subcategory
string
Product subcategory
tags
array
Array of tags (max 20)
lowStockAlert
integer
default:"5"
Stock level threshold for low stock alerts

Response

curl -X POST https://api.fitaiid.com/api/products \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Resistance Bands Set",
    "description": "Premium resistance bands for strength training and flexibility",
    "price": 45000,
    "originalPrice": 60000,
    "category": "accesorios",
    "subcategory": "training-equipment",
    "brand": "FitAiid",
    "mainImage": "https://images.unsplash.com/photo-1598289431512-b97b0917affc",
    "images": [
      "https://images.unsplash.com/photo-1598289431512-b97b0917affc"
    ],
    "quantity": 100,
    "tags": ["resistance", "bands", "strength", "flexibility"]
  }'

Update Product

Path Parameters

id
string
required
MongoDB ObjectId of the product to update

Headers

Authorization
string
required
Bearer token: Bearer YOUR_JWT_TOKEN

Body Parameters

All fields are optional. Only include fields you want to update.
name
string
Product name (must be unique)
description
string
Product description
price
integer
Product price in cents
quantity
integer
Update stock quantity
status
string
Product status: active, inactive, discontinued, or coming-soon

Response

curl -X PUT https://api.fitaiid.com/api/products/507f1f77bcf86cd799439012 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "price": 42000,
    "quantity": 150
  }'

Delete Product

Path Parameters

id
string
required
MongoDB ObjectId of the product to delete

Headers

Authorization
string
required
Bearer token: Bearer YOUR_JWT_TOKEN

Response

curl -X DELETE https://api.fitaiid.com/api/products/507f1f77bcf86cd799439012 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Error Responses

400 Bad Request
Invalid parameters or validation errors
401 Unauthorized
Missing or invalid authentication token
403 Forbidden
User does not have admin privileges
404 Not Found
Product not found

Build docs developers (and LLMs) love