Skip to main content

Product Management

Product Management API Documentation

Author: JoshNextGate S.Development SakweliTeam
Last Updated: 2025-09-23
Version: v1.0

Short Description: The Product Management API provides comprehensive functionality for managing products within shops on the NextGate platform. It supports advanced features likeincluding group buying, installment payments, color variations, specifications, search,comprehensive filtering,search and filtering capabilities with role-based access control.

Hints:


Endpoints

1. Create Product

Purpose: Creates a new product in a shop with support for all advanced features supportincluding group buying, installments, color variations, and specifications

Endpoint: POST /api/v1/shops/{shopId}/products

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

Header Type Required Description
Authorization string Yes Bearer token for authentication
Content-Type string Yes application/json

Path Parameters:

Parameter Type Required Description Validation
shopId UUID Yes ID of the shop to create product in Valid UUID formatformat, shop must exist and be active

Query Parameters:

Parameter Type Required Description Validation Default
action ReqAction Yes Action to perform on product SAVE_DRAFT, SAVE_PUBLISH None

Request JSON Sample:

{
  "productName": "iPhone 15 Pro"Pro Max 256GB",
  "productDescription": "LatestThe most advanced iPhone withever, advancedfeaturing the groundbreaking A17 Pro chip, titanium design, and the most versatile Pro camera systemsystem. and titanium design. FeaturesWith a 6.1-7-inch Super Retina XDR displaydisplay, withAction ProMotion technology, A17 Pro chip,Button, and professionalup camerato system.29 hours of video playback battery life.",
  "shortDescription": "Premium smartphone6.7-inch iPhone with A17 Pro camerachip features"and titanium design",
  "price": 999.1199.00,
  "comparePrice": 1099.1299.00,
  "stockQuantity": 50,25,
  "lowStockThreshold": 10,5,
  "categoryId": "123e4567-e89b-12d3-a456-426614174000",
  "brand": "Apple",
  "condition": "NEW",
  "productImages": [
    "https://example.com/images/iphone15-pro-1.max-main.jpg",
    "https://example.com/images/iphone15-pro-2.max-side.jpg",
    "https://example.com/images/iphone15-pro-max-back.jpg",
    "https://example.com/images/iphone15-pro-max-camera.jpg"
  ],
  "tags": ["smartphone", "apple", "premium", "5g", "titanium", "pro-camera"],
  "specifications": {
    "Screen Size"Display": "6.17-inch inches"Super Retina XDR OLED",
    "Chip": "A17 Pro with 6-core GPU",
    "Storage": "256GB",
    "RAM": "8GB",
    "Rear Camera": "48MP TripleMain, Camera"12MP Ultra Wide, 12MP Telephoto",
    "Battery"Front Camera": "327412MP mAh"TrueDepth",
    "OS"Battery Life": "Up to 29 hours video playback",
    "Operating System": "iOS 17",
    "Connectivity": "5G, Wi-Fi 6E, Bluetooth 5.3",
    "Materials": "Titanium frame, Ceramic Shield front",
    "Water Resistance": "IP68 (6 meters for up to 30 minutes)",
    "Dimensions": "159.9 x 76.7 x 8.25 mm",
    "Weight": "221 grams"
  },
  "colors": [
    {
      "name": "SpaceNatural Black"Titanium",
      "hex": "#1D1D1F"#F5F5DC",
      "images": [
        "https://example.com/images/colors/iphone-black.natural-titanium-1.jpg",
        "https://example.com/colors/iphone-natural-titanium-2.jpg"
      ],
      "priceAdjustment": 0.00
    },
    {
      "name": "DeepBlue Purple"Titanium",
      "hex": "#5856D6"#4A90E2",
      "images": [
        "https://example.com/images/colors/iphone-purple.blue-titanium-1.jpg",
        "https://example.com/colors/iphone-blue-titanium-2.jpg"
      ],
      "priceAdjustment": 0.00
    },
    {
      "name": "White Titanium",
      "hex": "#FFFFFF",
      "images": [
        "https://example.com/colors/iphone-white-titanium-1.jpg",
        "https://example.com/colors/iphone-white-titanium-2.jpg"
      ],
      "priceAdjustment": 0.00
    },
    {
      "name": "Black Titanium",
      "hex": "#1C1C1E",
      "images": [
        "https://example.com/colors/iphone-black-titanium-1.jpg",
        "https://example.com/colors/iphone-black-titanium-2.jpg"
      ],
      "priceAdjustment": 50.00
    }
  ],
  "minOrderQuantity": 1,
  "maxOrderQuantity": 5,3,
  "maxPerCustomer": 2,
  "requiresApproval": false,
  "groupBuyingEnabled": true,
  "groupMinSize": 10,
  "groupMaxSize": 50,
  "groupPrice": 899.1099.00,
  "groupTimeLimitHours": 48,72,
  "groupRequiresMinimum": true,
  "installmentEnabled": true,
  "installmentPlans": [
    {
      "duration": 6,
      "interval": "MONTHS",
      "interestRate": 0.00,
      "description": "6 months interest-free"free installment"
    },
    {
      "duration": 12,
      "interval": "MONTHS",
      "interestRate": 5.2.90,
      "description": "12 months with low interest"interest rate"
    },
    {
      "duration": 24,
      "interval": "MONTHS",
      "interestRate": 5.90,
      "description": "24 months extended payment plan"
    }
  ],
  "downPaymentRequired": true,
  "minDownPaymentPercentage": 20.00,
  "trackInventory": true,
  "isFeatured": false,true,
  "isDigital": false,
  "requiresShipping": true,
  "metaTitle": "iPhone 15 Pro Max 256GB - Premium Smartphone"Titanium Smartphone | TechStore Pro",
  "metaDescription": "GetBuy the latest iPhone 15 Pro Max with advanced256GB featuresstorage, A17 Pro chip, and premiumtitanium design"design. Available with group buying discounts and flexible installment plans."
}

Request Body Parameters:

enabled
Parameter Type Required Description Validation
productName string Yes NameUnique name of the product within shop Min: 2, Max: 100 characters
productDescription string Yes Detailed product description Min: 10, Max: 1000 characters
price decimal Yes Product selling price Min: 0.01, Max: 8 digits,digits with 2 decimal places
stockQuantity integer Yes Available stock quantity Min: 0
categoryId UUID Yes Product category IDidentifier Must exist and be active
shortDescription string No Brief product descriptionsummary Max: 200 characters
comparePrice decimal No Original price for discount display Must be greater than price if provided
lowStockThresholdintegerNoLow stock alert thresholdMin: 1, Max: 1000, Default: 5
brand string No Product brand name Max: 100 characters
skustringNoCustom Stock Keeping UnitMax: 50 characters, auto-generated if not provided
condition ProductCondition No Product condition NEW, USED_LIKE_NEW, USED_GOOD, USED_FAIR, REFURBISHED, FOR_PARTS
statusProductStatusNoInitial product statusDRAFT, ACTIVE, INACTIVE, OUT_OF_STOCK, ARCHIVED
productImages array Yes Product image URLs Valid URLs, cannot be emptyempty, at least 1 required
tags array No Product tags for categorization Max 50 characters eachper tag
specifications object No ProductTechnical product specifications Key-value pairs,Key: max 100 charchars, keys,Value: max 500 char valueschars
colors array No Available color variations Color objects with name, hex, images, priceAdjustment
minOrderQuantity integer No Minimum order quantity Min: 1, Default: 1
maxOrderQuantity integer No Maximum order quantity per orderMin: 1, must be >= minOrderQuantity
maxPerCustomerintegerNoMaximum quantity per customer Min: 1
requiresApprovalbooleanNoRequires manual approval for ordersDefault: false
groupBuyingEnabled boolean No Enable group buying feature Default: false
groupMinSize integer No Minimum group sizeparticipants Min: 2, required if group buying enabledgroupBuyingEnabled=true
groupMaxSize integer No Maximum group sizeparticipants Min: 2, must be >= groupMinSize
groupPrice decimal No GroupDiscounted buyinggroup price Must be <less than regular price
groupTimeLimitHours integer No Group formation time limit in hours Min: 1, Max: 8760 (1 year)
groupRequiresMinimumbooleanNoGroup must reach minimum sizeDefault: true
installmentEnabled boolean No Enable installment payments Default: false
installmentPlans array No Available installmentpayment plans Required if installmentsinstallmentEnabled=true
installmentPlans[].durationintegerYesPayment plan durationMin: 1
installmentPlans[].intervalstringYesPayment intervalDAYS, WEEKS, MONTHS
installmentPlans[].interestRatedecimalYesInterest rate percentageMin: 0, Max: 100, 2 decimal places
installmentPlans[].descriptionstringNoPlan descriptionMax: 200 characters
downPaymentRequired boolean No Require down payment Default: false
minDownPaymentPercentage decimal No Minimum down payment %percentage Min: 0, Max: 100100, 2 decimal places
trackInventorybooleanNoTrack inventory changesDefault: true
isFeatured boolean No Mark as featured product Default: false
isDigital boolean No Digital product flag(no shipping) Default: false
requiresShipping boolean No RequiresPhysical shipping required Default: true
metaTitle string No SEO meta title Max: 100 characters
metaDescription string No SEO meta description Max: 200 characters

Color Request Object Structure:

{
  "name": "Color Name",
  "hex": "#HEXCODE",
  "images": ["url1", "url2"],
  "priceAdjustment": 0.00
}

Installment Plan Request Object Structure:

{
  "duration": 12,
  "interval": "MONTHS",
  "interestRate": 2.90,
  "description": "12 months low interest"
}

Response JSON Sample:

{
  "success": true,
  "message": "Product created successfully",
  "data": null
}

Response Fields:

FieldDescription
successBoolean indicating operation success
messageHuman-readable success message
dataAdditional response data (null for create operation)

Business Rules:

  • Product name must be unique within the shop
  • If comparePrice is provided, it must be greater than price
  • Group buying requires groupMinSize โ‰ค groupMaxSize
  • Group price must be less than regular price
  • Installment plans required when installmentEnabled=true
  • At least one installment plan must be provided
  • Color hex codes must be valid 6-digit hex format
  • All image URLs must be valid and accessible
  • Category must exist and be active
  • Shop must exist and be active
  • User must be shop owner or system admin

Validation Rules:

  • @AssertTrue Group maximum size must be greater than minimum size
  • @AssertTrue Group price must be less than regular price
  • @AssertTrue Maximum order quantity must be greater than minimum order quantity
  • @AssertTrue Compare price must be greater than regular price
  • @AssertTrue At least one installment plan required when installments enabled
  • @AssertTrue Group buying settings required when group buying enabled

Error Responses:

  • 400 Bad Request: Invalid request datadata, validation errors, or validationbusiness errorsrule violations
  • 401 Unauthorized: Authentication required or invalid token
  • 403 Forbidden: Insufficient permissions (shop owner/owner or system admin required)
  • 404 Not Found: Shop not found or category not foundfound/inactive
  • 409 Conflict: Product with same name, brand, price, and specifications already exists in shop
  • 422 Unprocessable Entity: Validation errors with detailed field-level messages
  • 500 Internal Server Error: Server error during product creation

2. Update Product

Purpose: Updates an existing product with support for all advanced features and partial updates

Endpoint: PUT /api/v1/shops/{shopId}/products/{productId}

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

Header Type Required Description
Authorization string Yes Bearer token for authentication
Content-Type string Yes application/json

Path Parameters:

Parameter Type Required Description Validation
shopId UUID Yes ID of the shop Valid UUID formatformat, shop must exist
productId UUID Yes ID of the product to update Valid UUID formatformat, product must exist in shop

Query Parameters:

Parameter Type Required Description Validation Default
action ReqAction Yes Action to perform after update SAVE_DRAFT, SAVE_PUBLISH None

Request JSON Sample:

{
  "productName": "iPhone 15 Pro Max"Max 512GB - Updated",
  "price": 1199.1399.00,
  "comparePrice": 1499.00,
  "stockQuantity": 30,15,
  "groupPrice": 1099.1299.00,
  "specifications": {
    "Display": "6.7-inch Super Retina XDR OLED",
    "Storage": "512GB",
    "RAM": "8GB",
    "New Feature": "Enhanced Night Mode"
  },
  "installmentPlans": [
    {
      "duration": 24,6,
      "interval": "MONTHS",
      "interestRate": 3.0.00,
      "description": "6 months interest-free"
    },
    {
      "duration": 18,
      "interval": "MONTHS",
      "interestRate": 4.50,
      "description": "2418 months lowflexible interest plan"payment"
    }
  ],
  "tags": ["smartphone", "apple", "premium", "5g", "512gb", "pro-max"]
}

Request Body Parameters: All parameters are optional for updates. Only provided fields will be updated.

ParameterTypeRequiredDescriptionValidation
productNamestringNoUpdated product nameMin: 2, Max: 100 characters, unique in shop
productDescriptionstringNoUpdated descriptionMin: 10, Max: 1000 characters
shortDescriptionstringNoUpdated short descriptionMax: 200 characters
pricedecimalNoUpdated selling priceMin: 0.01, Max: 8 digits with 2 decimal places
comparePricedecimalNoUpdated original priceMust be greater than price if provided
stockQuantityintegerNoUpdated stock quantityMin: 0
lowStockThresholdintegerNoUpdated low stock thresholdMin: 1, Max: 1000
brandstringNoUpdated brand nameMax: 100 characters
skustringNoUpdated SKUMax: 50 characters, unique if changed
conditionProductConditionNoUpdated conditionNEW, USED_LIKE_NEW, USED_GOOD, USED_FAIR, REFURBISHED, FOR_PARTS
statusProductStatusNoUpdated statusDRAFT, ACTIVE, INACTIVE, OUT_OF_STOCK, ARCHIVED
categoryIdUUIDNoUpdated categoryMust exist and be active
productImagesarrayNoUpdated image URLsValid URLs
tagsarrayNoUpdated tagsMax 50 characters per tag
specificationsobjectNoUpdated specificationsCompletely replaces existing specifications
colorsarrayNoUpdated color variationsCompletely replaces existing colors
minOrderQuantityintegerNoUpdated minimum orderMin: 1
maxOrderQuantityintegerNoUpdated maximum orderMin: 1, must be >= minOrderQuantity
requiresApprovalbooleanNoUpdated approval requirementtrue/false
groupBuyingEnabledbooleanNoEnable/disable group buyingtrue/false
groupMinSizeintegerNoUpdated group minimumMin: 2, required if enabling group buying
groupMaxSizeintegerNoUpdated group maximumMin: 2, must be >= groupMinSize
groupPricedecimalNoUpdated group priceMust be less than regular price
groupTimeLimitHoursintegerNoUpdated group time limitMin: 1, Max: 8760
groupRequiresMinimumbooleanNoUpdated group requirementtrue/false
installmentEnabledbooleanNoEnable/disable installmentstrue/false
installmentPlansarrayNoUpdated installment plansReplaces existing plans, required if enabling
downPaymentRequiredbooleanNoUpdated down payment requirementtrue/false
minDownPaymentPercentagedecimalNoUpdated down payment percentageMin: 0, Max: 100
isFeaturedbooleanNoUpdated featured statustrue/false
isDigitalbooleanNoUpdated digital product flagtrue/false
requiresShippingbooleanNoUpdated shipping requirementtrue/false
metaTitlestringNoUpdated SEO titleMax: 100 characters
metaDescriptionstringNoUpdated SEO descriptionMax: 200 characters

Response JSON Sample:

{
  "success": true,
  "message": "Product updated successfully and published",
  "data": {
    "productId": "456e7890-e89b-12d3-a456-426614174001",
    "productName": "iPhone 15 Pro Max"Max 512GB - Updated",
    "productSlug": "iphone-15-pro-max-512gb-updated",
    "price": 1199.1399.00,
    "comparePrice": 1499.00,
    "status": "ACTIVE",
    "stockQuantity": 15,
    "updatedAt": "2025-09-23T11:45:00"23T14:30:00Z",
    "sku": "SHP12345678-ELE-APP-512-0001"
  }
}

Business Rules for Updates:

  • Product name uniqueness checked only if name is being changed
  • SKU uniqueness validated only if SKU is being changed
  • Group buying settings must be complete when enabling feature
  • Installment plans required when enabling installment feature
  • Category must exist and be active if being changed
  • Action parameter determines final status regardless of status field

Error Responses:

  • 400 Bad Request: Invalid requestupdate data or validation errors
  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Shop or product not found
  • 409 Conflict: ProductUpdated product name or SKU already exists
  • 422 Unprocessable Entity: Validation errors

3. GetPublish Product Detailed

Purpose: RetrievesPublishes comprehensivea draft product detailsmaking withit allactive featuresand publicly available

Endpoint: GETPATCH /api/v1/shops/{shopId}/products/{productId}/detailedpublish

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

Parameter Type Required Description Validation
shopId UUID Yes ID of the shop Valid UUID formatformat, shop must exist
productId UUID Yes ID of the product to publish Valid UUID formatformat, product must exist and be draft

Response JSON Sample:

{
  "success": true,
  "message": "Product details'iPhone retrieved15 Pro Max 512GB' published successfully",
  "data": {
    "productId": "456e7890-e89b-12d3-a456-426614174001",
    "productName": "iPhone 15 Pro"Pro Max 512GB",
    "productSlug": "iphone-15-pro",
    "productDescription": "Latest iPhone with advanced camera system",
    "shortDescription": "Premium smartphone with Pro camera features",
    "productImages": ["https://example.com/images/iphone15-pro-1.jpg"],
    "price": 999.00,
    "comparePrice": 1099.00,
    "discountAmount": 100.00,
    "discountPercentage": 9.09,
    "isOnSale": true,
    "stockQuantity": 50,
    "isInStock": true,
    "isLowStock": false,
    "brand": "Apple",
    "sku": "SHP12345678-ELE-APP-256-0001",
    "condition": "NEW"max-512gb",
    "status": "ACTIVE",
    "tags"publishedAt": ["smartphone", "apple", "premium"]2025-09-23T14:45:00Z",
    "shopId": "123e4567-e89b-12d3-a456-426614174000",
    "shopName": "TechStore Pro",
    "categoryId": "789e0123-e89b-12d3-a456-426614174002",
    "categoryName": "Smartphones",
    "specifications": {
      "Screen Size": "6.1 inches",
      "Storage": "256GB",
      "RAM": "8GB"
    },
    "hasSpecifications": true,
    "specificationCount": 3,
    "colors": [
      {
        "name": "Space Black",
        "hex": "#1D1D1F",
        "images": ["https://example.com/images/iphone-black.jpg"],
        "priceAdjustment": 0.00,
        "finalPrice": 999.00,
        "hasExtraFee": false
      }
    ],
    "hasMultipleColors": false,
    "colorCount": 1,
    "priceRange": {
      "minPrice": 999.00,
      "maxPrice": 999.00,
      "hasPriceVariations": false
    },
    "groupBuying": {
      "isEnabled": true,
      "isAvailable": true,
      "minGroupSize": 10,
      "maxGroupSize": 50,
      "currentGroupSize": 7,
      "remainingSlots": 43,
      "groupPrice": 899.00,
      "groupDiscount": 100.00,
      "groupDiscountPercentage": 10.01,
      "timeLimitHours": 48,
      "timeRemainingHours": 24,
      "status": "PENDING",
      "canJoinGroup": true
    },
    "installmentOptions": {
      "isEnabled": true,
      "isAvailable": true,
      "downPaymentRequired": true,
      "minDownPaymentPercentage": 20.00,
      "plans": [
        {
          "planId": "plan-6m",
          "duration": 6,
          "interval": "MONTHS",
          "interestRate": 0.00,
          "description": "6 months interest-free",
          "calculations": {
            "downPayment": 199.80,
            "remainingAmount": 799.20,
            "paymentAmount": 133.20,
            "totalAmount": 999.00
          },
          "isPopular": true
        }
      ]
    },
    "purchaseOptions": {
      "canBuyNow": true,
      "canJoinGroup": true,
      "canPayInstallment": true,
      "recommendedOption": "GROUP_BUYING",
      "bestDeal": {
        "option": "GROUP_BUYING",
        "savings": 100.00,
        "finalPrice": 899.00
      }
    },
    "createdAt": "2025-09-23T10:30:00",
    "updatedAt": "2025-09-23T11:45:00"
  }
}

Publishing Validation Requirements:

  • Product name must not be empty
  • Product description must not be empty
  • Price must be greater than 0
  • Stock quantity must be >= 0
  • Category must be assigned and active
  • At least one product image required
  • Group buying settings complete if enabled
  • Installment plans present if installments enabled

Error Responses:

  • 400 Bad Request: Product already published or missing required fields for publishing
  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Shop or product not found

4. GetDelete Shop Products (Owner View)Product

Purpose: RetrievesDeletes alla productsproduct forusing shopdifferent managementstrategies based on product status

Endpoint: GETDELETE /api/v1/shops/{shopId}/products/all{productId}

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

Parameter Type Required Description Validation
shopId UUID Yes ID of the shop Valid UUID formatformat, shop must exist
productIdUUIDYesID of the product to deleteValid UUID format, product must exist

Response JSON Sample (Soft Delete):

{
  "success": true,
  "message": "RetrievedProduct 25'iPhone products15 fromPro shop:Max TechStore512GB' Pro"has been deleted and will be permanently removed after 30 days",
  "data": {
    "shop": {
      "shopId"message": "123e4567-e89b-12d3-a456-426614174000"Product 'iPhone 15 Pro Max 512GB' has been deleted and will be permanently removed after 30 days",
    "shopName"productName": "TechStoreiPhone Pro"15 Pro Max 512GB",
      "shopSlug": "techstore-pro",
      "logoUrl": "https://example.com/logos/techstore.png",
      "isVerified": true,
      "isApproved": true
    },
    "summary": {
      "totalProducts": 25,
      "activeProducts": 20,
      "draftProducts": 3,
      "outOfStockProducts": 2,
      "featuredProducts": 5,
      "lowStockProducts": 4,
      "averagePrice": 599.50,
      "totalInventoryValue": 14987.50,
      "productsWithGroupBuying": 8,
      "productsWithInstallments": 12,
      "productsWithMultipleColors": 6
    },
    "products": [
      {
    "productId": "456e7890-e89b-12d3-a456-426614174001",
    "productName": "iPhone 15 Pro",
        "productSlug": "iphone-15-pro",
        "primaryImage": "https://example.com/images/iphone15-pro-1.jpg",
        "price": 999.00,
        "comparePrice": 1099.00,
        "finalPrice": 999.00,
        "isOnSale": true,
        "discountPercentage": 9.09,
        "stockQuantity": 50,
        "isInStock": true,
        "isLowStock": false,
        "brand": "Apple",
        "sku": "SHP12345678-ELE-APP-256-0001",
        "status"previousStatus": "ACTIVE",
    "isFeatured": false,
        "hasGroupBuying": true,
        "hasInstallments": true,
        "hasMultipleColors": true,
        "groupPrice": 899.00,
        "startingFromPrice": 999.00,
        "createdAt"deletedAt": "2025-09-23T10:30:00"
      }
    ]23T15:00:00Z",
    "totalProducts"deletionType": 25"SOFT_DELETE",
    "note": "Product will be permanently deleted after 30 days"
  }
}

Response JSON Sample (Hard Delete):

{
  "success": true,
  "message": "Draft product 'iPhone 15 Pro Max 512GB' has been permanently deleted",
  "data": null
}

Deletion Logic:

  • Draft Products: Hard delete (permanently removed from database)
  • Published Products: Soft delete (marked as deleted, status changed to ARCHIVED)
  • Soft Deleted Products: Marked with deletion timestamp and deleted by user ID
  • Recovery Period: 30 days for soft-deleted products before permanent removal

Error Responses:

  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Shop or product not found

5. GetRestore Shop Products (Paginated)Product

Purpose: RetrievesRestores shopa productssoft-deleted withproduct paginationback forto managementdraft status

Endpoint: GETPATCH /api/v1/shops/{shopId}/products/all-paged{productId}/restore

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

Parameter Type Required Description Validation
shopId UUID Yes ID of the shop Valid UUID formatformat, shop must exist
productIdUUIDYesID of the product to restoreValid UUID format, product must be soft-deleted

Response JSON Sample:

{
  "success": true,
  "message": "Product 'iPhone 15 Pro Max 512GB' has been restored successfully",
  "data": {
    "productId": "456e7890-e89b-12d3-a456-426614174001",
    "productName": "iPhone 15 Pro Max 512GB",
    "productSlug": "iphone-15-pro-max-512gb",
    "status": "DRAFT",
    "restoredAt": "2025-09-23T15:30:00Z",
    "isDeleted": false,
    "shopId": "123e4567-e89b-12d3-a456-426614174000",
    "note": "Product restored as draft. Publish to make it active again."
  }
}

Restoration Process:

  • Sets isDeleted flag to false
  • Clears deletedAt and deletedBy fields
  • Sets status to DRAFT for safety (requires manual publishing)
  • Updates editedBy and updatedAt timestamps

Error Responses:

  • 400 Bad Request: Product is not deleted and cannot be restored
  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Shop or product not found

6. Get Product Detailed (Owner/Admin View)

Purpose: Retrieves comprehensive product details with all features and management information

Endpoint: GET /api/v1/shops/{shopId}/products/{productId}/detailed

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesID of the shopValid UUID format, shop must exist
productIdUUIDYesID of the productValid UUID format, product must exist in shop

Response JSON Sample:

{
  "success": true,
  "message": "Product details retrieved successfully",
  "data": {
    "productId": "456e7890-e89b-12d3-a456-426614174001",
    "productName": "iPhone 15 Pro Max 512GB",
    "productSlug": "iphone-15-pro-max-512gb",
    "productDescription": "The most advanced iPhone ever, featuring the groundbreaking A17 Pro chip...",
    "shortDescription": "Premium 6.7-inch iPhone with A17 Pro chip and titanium design",
    "productImages": [
      "https://example.com/images/iphone15-pro-max-main.jpg",
      "https://example.com/images/iphone15-pro-max-side.jpg"
    ],
    "price": 1199.00,
    "comparePrice": 1299.00,
    "discountAmount": 100.00,
    "discountPercentage": 7.69,
    "isOnSale": true,
    "stockQuantity": 25,
    "lowStockThreshold": 5,
    "isInStock": true,
    "isLowStock": false,
    "trackInventory": true,
    "brand": "Apple",
    "sku": "SHP12345678-ELE-APP-512-0001",
    "condition": "NEW",
    "status": "ACTIVE",
    "tags": ["smartphone", "apple", "premium", "5g", "titanium"],
    "metaTitle": "iPhone 15 Pro Max 512GB - Premium Titanium Smartphone",
    "metaDescription": "Buy the latest iPhone 15 Pro Max with 512GB storage...",
    "shopId": "123e4567-e89b-12d3-a456-426614174000",
    "shopName": "TechStore Pro",
    "shopSlug": "techstore-pro",
    "categoryId": "789e0123-e89b-12d3-a456-426614174002",
    "categoryName": "Smartphones",
    "isFeatured": true,
    "isDigital": false,
    "requiresShipping": true,
    "createdAt": "2025-09-23T10:30:00Z",
    "updatedAt": "2025-09-23T14:30:00Z",
    "createdBy": "111e2222-e89b-12d3-a456-426614174003",
    "editedBy": "111e2222-e89b-12d3-a456-426614174003",
    "specifications": {
      "Display": "6.7-inch Super Retina XDR OLED",
      "Chip": "A17 Pro with 6-core GPU",
      "Storage": "512GB",
      "RAM": "8GB",
      "Battery Life": "Up to 29 hours video playback",
      "Water Resistance": "IP68"
    },
    "hasSpecifications": true,
    "specificationCount": 6,
    "colors": [
      {
        "name": "Natural Titanium",
        "hex": "#F5F5DC",
        "images": ["https://example.com/colors/natural-titanium.jpg"],
        "priceAdjustment": 0.00,
        "finalPrice": 1199.00,
        "hasExtraFee": false,
        "extraFeeReason": null
      },
      {
        "name": "Black Titanium",
        "hex": "#1C1C1E",
        "images": ["https://example.com/colors/black-titanium.jpg"],
        "priceAdjustment": 50.00,
        "finalPrice": 1249.00,
        "hasExtraFee": true,
        "extraFeeReason": "Premium color finish"
      }
    ],
    "hasMultipleColors": true,
    "colorCount": 2,
    "priceRange": {
      "minPrice": 1199.00,
      "maxPrice": 1249.00,
      "priceStartsFrom": 1199.00,
      "hasPriceVariations": true
    },
    "orderingLimits": {
      "minOrderQuantity": 1,
      "maxOrderQuantity": 3,
      "requiresApproval": false,
      "canOrderQuantity": 3,
      "maxAllowedQuantity": 3,
      "hasOrderingLimits": true
    },
    "groupBuying": {
      "isEnabled": true,
      "isAvailable": true,
      "minGroupSize": 10,
      "maxGroupSize": 50,
      "currentGroupSize": 7,
      "remainingSlots": 43,
      "progressPercentage": 70.0,
      "groupPrice": 1099.00,
      "groupDiscount": 100.00,
      "groupDiscountPercentage": 8.34,
      "timeLimitHours": 72,
      "timeRemainingHours": 48,
      "expiresAt": "2025-09-25T10:30:00Z",
      "requiresMinimum": true,
      "status": "PENDING",
      "canJoinGroup": true
    },
    "installmentOptions": {
      "isEnabled": true,
      "isAvailable": true,
      "downPaymentRequired": true,
      "minDownPaymentPercentage": 20.00,
      "eligibilityStatus": "ELIGIBLE",
      "creditCheckRequired": false,
      "plans": [
        {
          "planId": "plan-6m",
          "duration": 6,
          "interval": "MONTHS",
          "interestRate": 0.00,
          "description": "6 months interest-free installment",
          "isPopular": true,
          "calculations": {
            "downPayment": 239.80,
            "remainingAmount": 959.20,
            "totalInterest": 0.00,
            "paymentAmount": 159.87,
            "totalAmount": 1199.00
          },
          "paymentSchedule": [
            {
              "paymentNumber": 1,
              "amount": 159.87,
              "dueDate": "2025-10-23T00:00:00Z",
              "description": "Month 1 payment"
            },
            {
              "paymentNumber": 2,
              "amount": 159.87,
              "dueDate": "2025-11-23T00:00:00Z",
              "description": "Month 2 payment"
            }
          ]
        }
      ]
    },
    "purchaseOptions": {
      "canBuyNow": true,
      "canJoinGroup": true,
      "canPayInstallment": true,
      "recommendedOption": "GROUP_BUYING",
      "bestDeal": {
        "option": "GROUP_BUYING",
        "savings": 100.00,
        "finalPrice": 1099.00
      }
    }
  }
}

Response Fields:

FieldDescription
Basic product informationproductId, productName, productSlug, descriptions, images
Pricing detailsprice, comparePrice, discount calculations, sale status
Inventory informationstock quantities, availability status, tracking settings
Product detailsbrand, SKU, condition, status, category information
Shop informationshopId, shopName, shopSlug
Advanced featuresspecifications, colors, group buying, installments
Management datacreation/update timestamps, user IDs, featured status
Purchase optionsavailable buying methods and recommendations

Error Responses:

  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions (shop owner or admin required)
  • 404 Not Found: Shop or product not found

7. Get Shop Products (Management View)

Purpose: Retrieves all products for shop management with summary statistics

Endpoint: GET /api/v1/shops/{shopId}/products/all

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesID of the shopValid UUID format, shop must exist

Response JSON Sample:

{
  "success": true,
  "message": "Retrieved 47 products from shop: TechStore Pro",
  "data": {
    "shop": {
      "shopId": "123e4567-e89b-12d3-a456-426614174000",
      "shopName": "TechStore Pro",
      "shopSlug": "techstore-pro",
      "logoUrl": "https://example.com/logos/techstore-pro.png",
      "isVerified": true,
      "isApproved": true,
      "isMyShop": true
    },
    "summary": {
      "totalProducts": 47,
      "activeProducts": 35,
      "draftProducts": 8,
      "outOfStockProducts": 4,
      "featuredProducts": 12,
      "lowStockProducts": 6,
      "averagePrice": 649.75,
      "totalInventoryValue": 89543.25,
      "productsWithGroupBuying": 18,
      "productsWithInstallments": 25,
      "productsWithMultipleColors": 14
    },
    "products": [
      {
        "productId": "456e7890-e89b-12d3-a456-426614174001",
        "productName": "iPhone 15 Pro Max 512GB",
        "productSlug": "iphone-15-pro-max-512gb",
        "shortDescription": "Premium 6.7-inch iPhone with A17 Pro chip",
        "primaryImage": "https://example.com/images/iphone15-pro-max-main.jpg",
        "price": 1199.00,
        "comparePrice": 1299.00,
        "finalPrice": 1199.00,
        "isOnSale": true,
        "discountPercentage": 7.69,
        "stockQuantity": 25,
        "isInStock": true,
        "isLowStock": false,
        "brand": "Apple",
        "sku": "SHP12345678-ELE-APP-512-0001",
        "condition": "NEW",
        "status": "ACTIVE",
        "isFeatured": true,
        "isDigital": false,
        "hasGroupBuying": true,
        "hasInstallments": true,
        "hasMultipleColors": true,
        "groupPrice": 1099.00,
        "startingFromPrice": 1199.00,
        "createdAt": "2025-09-23T10:30:00Z"
      }
    ],
    "totalProducts": 47
  }
}

Summary Statistics Fields:

FieldDescription
totalProductsTotal number of products in shop
activeProductsProducts with ACTIVE status
draftProductsProducts with DRAFT status
outOfStockProductsProducts with zero stock
featuredProductsProducts marked as featured
lowStockProductsProducts below low stock threshold
averagePriceAverage price of all products
totalInventoryValueTotal value of inventory (price ร— stock)
productsWithGroupBuyingProducts with group buying enabled
productsWithInstallmentsProducts with installment options
productsWithMultipleColorsProducts with color variations

Error Responses:

  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Shop not found or deleted

8. Get Shop Products Paginated (Management View)

Purpose: Retrieves shop products with pagination for management dashboard

Endpoint: GET /api/v1/shops/{shopId}/products/all-paged

Access Level: ๐Ÿ”’ Protected (Requires shop owner or system admin role)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesID of the shopValid UUID format, shop must exist

Query Parameters:

Parameter Type Required Description Validation Default
page integer No Page number (1-indexed) Min: 1 1
size integer No Items per page Min: 11, Max: 100 10

Response JSON Sample:

{
  "success": true,
  "message": "Retrieved 10 products from shop: TechStore Pro (Page 1 of 5)",
  "data": {
    "contents": {
      "shop": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "TechStore Pro",
        "shopSlug": "techstore-pro",
        "logoUrl": "https://example.com/logos/techstore-pro.png",
        "isVerified": true,
        "isApproved": true,
        "isMyShop": true
      },
      "summary": {
        "totalProducts": 47,
        "activeProducts": 35,
        "draftProducts": 8,
        "averagePrice": 649.75,
        "totalInventoryValue": 89543.25
      },
      "products": [
        {
          "productId": "456e7890-e89b-12d3-a456-426614174001",
          "productName": "iPhone 15 Pro Max 512GB",
          "price": 1199.00,
          "stockQuantity": 25,
          "status": "ACTIVE",
          "isInStock": true,
          "hasGroupBuying": true,
          "hasInstallments": true,
          "createdAt": "2025-09-23T10:30:00Z"
        }
      ],
      "totalProducts": 10
    },
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 47,
    "totalPages": 5,
    "hasNext": true,
    "hasPrevious": false
  }
}

Pagination Fields:

FieldDescription
currentPageCurrent page number (1-indexed)
pageSizeNumber of items per page
totalElementsTotal number of products
totalPagesTotal number of pages
hasNextWhether there is a next page
hasPreviousWhether there is a previous page

Error Responses:

  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Shop not found

9. Get Public Product by ID

Purpose: Retrieves a single active product for public viewing with customer-focused information

Endpoint: GET /api/v1/shops/{shopId}/products/{productId}

Access Level: ๐ŸŒ Public (No authentication required)

Authentication: None

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesID of the shopValid UUID format, shop must be active and approved
productIdUUIDYesID of the productValid UUID format, product must be active

Response JSON Sample:

{
  "success": true,
  "message": "Product retrieved successfully",
  "data": {
    "productId": "456e7890-e89b-12d3-a456-426614174001",
    "productName": "iPhone 15 Pro Max 512GB",
    "productSlug": "iphone-15-pro-max-512gb",
    "productDescription": "The most advanced iPhone ever, featuring the groundbreaking A17 Pro chip...",
    "shortDescription": "Premium 6.7-inch iPhone with A17 Pro chip and titanium design",
    "productImages": [
      "https://example.com/images/iphone15-pro-max-main.jpg",
      "https://example.com/images/iphone15-pro-max-side.jpg"
    ],
    "price": 1199.00,
    "comparePrice": 1299.00,
    "discountAmount": 100.00,
    "discountPercentage": 7.69,
    "isOnSale": true,
    "isInStock": true,
    "isLowStock": false,
    "stockQuantity": 25,
    "brand": "Apple",
    "condition": "NEW",
    "tags": ["smartphone", "apple", "premium", "5g", "titanium"],
    "shopId": "123e4567-e89b-12d3-a456-426614174000",
    "shopName": "TechStore Pro",
    "shopSlug": "techstore-pro",
    "shopLogoUrl": "https://example.com/logos/techstore-pro.png",
    "categoryId": "789e0123-e89b-12d3-a456-426614174002",
    "categoryName": "Smartphones",
    "isDigital": false,
    "requiresShipping": true,
    "specifications": {
      "Display": "6.7-inch Super Retina XDR OLED",
      "Storage": "512GB",
      "Chip": "A17 Pro with 6-core GPU",
      "Battery Life": "Up to 29 hours video playback"
    },
    "hasSpecifications": true,
    "colors": [
      {
        "name": "Natural Titanium",
        "hex": "#F5F5DC",
        "images": ["https://example.com/colors/natural-titanium.jpg"],
        "priceAdjustment": 0.00,
        "finalPrice": 1199.00
      },
      {
        "name": "Black Titanium",
        "hex": "#1C1C1E",
        "images": ["https://example.com/colors/black-titanium.jpg"],
        "priceAdjustment": 50.00,
        "finalPrice": 1249.00
      }
    ],
    "hasMultipleColors": true,
    "priceRange": {
      "minPrice": 1199.00,
      "maxPrice": 1249.00,
      "hasPriceVariations": true
    },
    "groupBuying": {
      "isAvailable": true,
      "minGroupSize": 10,
      "maxGroupSize": 50,
      "groupPrice": 1099.00,
      "groupDiscount": 100.00,
      "groupDiscountPercentage": 8.34,
      "timeLimitHours": 72
    },
    "installmentOptions": {
      "isAvailable": true,
      "downPaymentRequired": true,
      "minDownPaymentPercentage": 20.00,
      "plans": [
        {
          "duration": 6,
          "interval": "MONTHS",
          "interestRate": 0.00,
          "description": "6 months interest-free installment"
        },
        {
          "duration": 12,
          "interval": "MONTHS",
          "interestRate": 2.90,
          "description": "12 months with low interest rate"
        }
      ]
    },
    "createdAt": "2025-09-23T10:30:00Z"
  }
}

Public Response Features:

  • Only shows active products from approved shops
  • Hides internal management data (SKU, creation user IDs, etc.)
  • Shows stock quantity only if product is in stock
  • Includes customer-focused information (shipping, features, pricing)
  • Full specifications and color variations for customer decision making

Error Responses:

  • 404 Not Found: Shop not found, not approved, or product not found/not active

10. Get Public Shop Products

Purpose: Retrieves all active products from a shop for public browsing

Endpoint: GET /api/v1/shops/{shopId}/products/public-view/all

Access Level: ๐ŸŒ Public (No authentication required)

Authentication: None

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesID of the shopValid UUID format, shop must be active and approved

Response JSON Sample:

{
  "success": true,
  "message": "Retrieved 23 products from TechStore Pro",
  "data": {
    "shop": {
      "shopId": "123e4567-e89b-12d3-a456-426614174000",
      "shopName": "TechStore Pro",
      "shopSlug": "techstore-pro",
      "logoUrl": "https://example.com/logos/techstore-pro.png",
      "isVerified": true,
      "isApproved": true,
      "isMyShop": false
    },
    "products": [
      {
        "productId": "456e7890-e89b-12d3-a456-426614174001",
        "productName": "iPhone 15 Pro Max 512GB",
        "productSlug": "iphone-15-pro-max-512gb",
        "shortDescription": "Premium 6.7-inch iPhone with A17 Pro chip",
        "primaryImage": "https://example.com/images/iphone15-pro-max-main.jpg",
        "price": 1199.00,
        "comparePrice": 1299.00,
        "finalPrice": 1199.00,
        "isOnSale": true,
        "discountPercentage": 7.69,
        "isInStock": true,
        "brand": "Apple",
        "condition": "NEW",
        "hasGroupBuying": true,
        "hasInstallments": true,
        "hasMultipleColors": true,
        "groupPrice": 1099.00,
        "startingFromPrice": 1199.00,
        "createdAt": "2025-09-23T10:30:00Z"
      }
    ],
    "totalProducts": 23
  }
}

Public Shop Information:

  • Only shows active products (ACTIVE status)
  • Shop verification and approval status displayed
  • No internal management statistics
  • Customer-focused product information
  • Simplified product cards optimized for browsing

Error Responses:

  • 404 Not Found: Shop not found, not approved, or not active

11. Get Public Shop Products Paginated

Purpose: Retrieves active products from a shop with pagination for public browsing

Endpoint: GET /api/v1/shops/{shopId}/products/public-view/all-paged

Access Level: ๐ŸŒ Public (No authentication required)

Authentication: None

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesID of the shopValid UUID format, shop must be active and approved

Query Parameters:

ParameterTypeRequiredDescriptionValidationDefault
pageintegerNoPage number (1-indexed)Min: 11
sizeintegerNoItems per pageMin: 1, Max: 5010

Response JSON Sample:

{
  "success": true,
  "message": "Retrieved 10 products from TechStore Pro (Page 1 of 3)",
  "data": {
    "contents": {
      "shop": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "TechStore Pro",
        "shopSlug": "techstore-pro",
        "logoUrl": "https://example.com/logos/techstore-pro.png",
        "isVerified": true,
        "isApproved": true,
        "isMyShop": false
      },
      "products": []
        {
          "productId": "456e7890-e89b-12d3-a456-426614174001",
          "summary"productName": {"iPhone 15 Pro Max 512GB",
          "price": 1199.00,
          "isOnSale": true,
          "isInStock": true,
          "hasGroupBuying": true,
          "hasInstallments": true,
          "createdAt": "2025-09-23T10:30:00Z"
        }
      ],
      "totalProducts": 25,
        "activeProducts": 20
      }10
    },
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 25,23,
    "totalPages": 3,
    "hasNext": true,
    "hasPrevious": false
  }
}

Public Pagination Limits:

  • Maximum page size limited to 50 items for performance
  • Only active products included in pagination count
  • Shop must be approved and active to show any products

Error Responses:

  • 404 Not Found: Shop not foundfound, not approved, or not availableactive

12. Search Products

Purpose: Searches products within a shop withusing enhanced multi-word query matching across multiple fields

Endpoint: GET /api/v1/shops/{shopId}/products/search

Access Level: ๐ŸŒ Public (Enhanced features for authenticated users)

Authentication: Optional Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringNoBearer token for authentication (enables additional features)

Path Parameters:

Parameter Type Required Description Validation
shopId UUID Yes ID of the shop to search in Valid UUID formatformat, shop must be accessible

Query Parameters:

Parameter Type Required Description Validation Default
q string Yes Search query Min: 2, Max: 100 characters None
status ProductStatus[] No Product statuses to search DRAFT, ACTIVE, INACTIVE, OUT_OF_STOCK, ARCHIVED ACTIVE (public users)
page integer No Page number (1-indexed) Min: 1 1
size integer No Items per page Min: 1, Max: 50 10
sortBy string No Sort field relevance, createdAt, updatedAt, productName, price, productNamestockQuantity, brand relevance
sortDir string No Sort direction asc, desc desc

Request URL Examples:

# Basic search for "iphone"
GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/search?q=iphone&page=1&size=10

# Multi-word search for "dell precision"
GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/search?q=dell%20precision&sortBy=price&sortDir=asc

# Search with status filter (requires authentication)
GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/search?q=smartphone&status=ACTIVE&status=DRAFT

# Search with pagination and sorting
GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/search?q=laptop&page=2&size=20&sortBy=price&sortDir=asc

# Partial word search
GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/search?q=macbook&sortBy=relevance

Search Features & Behavior:

FeatureDescriptionExample
Multi-word SearchSearches for products containing ALL words"dell precision" finds products with both "dell" AND "precision"
Partial MatchingMatches partial words"iph" matches "iPhone"
Cross-field SearchSearches across multiple product fieldsQuery matches productName, description, shortDescription, brand, tags, specifications
Case InsensitiveSearch is case-insensitive"APPLE" matches "apple" and "Apple"
Special CharactersRemoves harmful charactersAutomatically sanitized for security
Relevance ScoringOrders by relevance when sortBy=relevanceProducts with exact matches ranked higher

Response JSON Sample:

{
  "success": true,
  "message": "Found 812 products matching 'iphone'dell precision'",
  "data": {
    "contents": {
      "shop": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "TechStore Pro",
        "shopSlug": "techstore-pro",
        "logoUrl": "https://example.com/logos/techstore.techstore-pro.png",
        "isVerified": truetrue,
        "isApproved": true,
        "isMyShop": false
      },
      "products": [
        {
          "productId": "456e7890-789e0123-e89b-12d3-a456-426614174001"426614174002",
          "productName": "iPhoneDell 15Precision Pro"7770 Mobile Workstation",
          "productSlug": "iphone-15-pro"dell-precision-7770-mobile-workstation",
          "shortDescription": "Professional mobile workstation with Intel Xeon processor",
          "primaryImage": "https://example.com/images/iphone15-pro-1.dell-precision-7770.jpg",
          "price": 999.2499.00,
          "comparePrice": 1099.2799.00,
          "finalPrice": 2499.00,
          "isOnSale": true,
          "discountPercentage": 9.09,10.72,
          "stockQuantity": 8,
          "isInStock": true,
          "isLowStock": true,
          "brand": "Apple"Dell",
          "sku": "SHP87654321-LAP-DEL-PRE-0005",
          "condition": "NEW",
          "status": "ACTIVE",
          "isFeatured": true,
          "isDigital": false,
          "hasGroupBuying": false,
          "hasInstallments": true,
          "hasMultipleColors": false,
          "groupPrice": null,
          "startingFromPrice": 2499.00,
          "createdAt": "2025-09-22T15:20:00Z"
        },
        {
          "productId": "890e1234-e89b-12d3-a456-426614174003",
          "productName": "Dell Precision 5570 Laptop",
          "productSlug": "dell-precision-5570-laptop",
          "shortDescription": "Compact precision laptop for professionals",
          "primaryImage": "https://example.com/images/dell-precision-5570.jpg",
          "price": 1899.00,
          "comparePrice": null,
          "finalPrice": 1899.00,
          "isOnSale": false,
          "discountPercentage": 0.00,
          "stockQuantity": 15,
          "isInStock": true,
          "isLowStock": false,
          "brand": "Dell",
          "sku": "SHP87654321-LAP-DEL-PRE-0006",
          "condition": "NEW",
          "status": "ACTIVE",
          "isFeatured": false,
          "isDigital": false,
          "hasGroupBuying": true,
          "hasInstallments": true,
          "hasMultipleColors": true,
          "groupPrice": 1749.00,
          "startingFromPrice": 1899.00,
          "createdAt": "2025-09-23T10:30:00"21T09:45:00Z"
        }
      ],
      "totalProducts": 8,12,
      "searchMetadata": {
        "searchQuery": "iphone"dell precision",
        "searchedStatuses": ["ACTIVE"],
        "userType": "PUBLIC",
        "canSearchAllStatuses": false
      }
    },
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 8,12,
    "totalPages": 1,2,
    "hasNext": false,true,
    "hasPrevious": false
  }
}

Search FeaturesMetadata Fields:

  • Multi-word
  • queries:"dellprecision"searchesforproductscontainingboth"dell" name,description,brand,and
  • Field Description
    searchQuery The and "precision"
  • Partial matching: "iph" will match "iPhone"
  • Cross-fieldoriginal search: Searchesquery provided
  • searchedStatusesProduct statuses included in productsearch
    userType User tagstype:
  • StatusPUBLIC, filtering:AUTHENTICATED, ShopSHOP_OWNER, owners/adminsADMIN
  • canSearchAllStatusesWhether user can search draftdraft/inactive products

    RelevanceUser sortingAccess Levels:

    Productsmatchingquerytermsranked
    User areType Searchable StatusesAdditional Features
    Public UserACTIVE onlyBasic search functionality
    Authenticated UserACTIVE onlySame as public (unless shop owner/admin)
    Shop OwnerAll statusesCan search drafts, inactive products, view management data
    System AdminAll statusesCan search all products across all statuses

    Sort Options:

    Sort FieldDescriptionBest Used For
    relevanceOrders by search relevance Default search results
    createdAtOrders by creation dateFinding newest/oldest products
    updatedAtOrders by last updateFinding recently modified products
    productNameAlphabetical orderBrowsing products alphabetically
    priceOrders by pricePrice comparison
    stockQuantityOrders by stock levelInventory management
    brandOrders by brand nameBrand-based organization

    Error Responses:

    • 400 Bad Request: Invalid searchSearch query (too short/long)short (< 2 characters), too long (> 100 characters), or invalid parameters
    • 404 Not Found: Shop not found or not availableaccessible (for public users, shop must be active and approved)

    13. Advanced Product Filter

    Purpose: Filters products using multiple criteria with complex combinations and boolean logic

    Endpoint: GET /api/v1/shops/{shopId}/products/advanced-filter

    Access Level: ๐ŸŒ Public (Enhanced features for authenticated users)

    Authentication: Optional Bearer Token

    Request Headers:

    HeaderTypeRequiredDescription
    AuthorizationstringNoBearer token for authentication (enables additional filters)

    Path Parameters:

    Parameter Type Required Description Validation
    shopId UUID Yes ID of the shop to filter in Valid UUID formatformat, shop must be accessible

    Query Parameters:

    Parameter Type Required Description Validation Default
    minPrice decimal No Minimum price filter Min: 00, Max: 8 digits None
    maxPrice decimal No Maximum price filter Min: 00, Max: 8 digits, must be >= minPrice None
    brand string[] No Brand names to filter (OR logic) Multiple values allowed None
    condition ProductCondition No Product condition filter NEW, USED_LIKE_NEW, etc.USED_GOOD, USED_FAIR, REFURBISHED, FOR_PARTS None
    categoryId UUID No Category filter Valid UUIDUUID, category must exist None
    tags string[] No Tag filters (OR logic) Multiple values allowed None
    inStock boolean No Filter by stock availability true/true (in stock), false (out of stock) None
    onSale boolean No Filter by sale status true/true (on sale), false (not on sale) None
    hasGroupBuying boolean No Filter by group buying availability true/true (has group buying), false (no group buying) None
    hasInstallments boolean No Filter by installment availability true/true (has installments), false (no installments) None
    hasMultipleColors boolean No Filter by color variations true/true (multiple colors), false (single/no colors) None
    isFeatured boolean No Filter by featured status true/true (featured), false (not featured) None
    status ProductStatus[] No Product status filter (OR logic) Multiple statuses allowed ACTIVE (public users)
    page integer No Page number (1-indexed) Min: 1 1
    size integer No Items per page Min: 1, Max: 50 10
    sortBy string No Sort field createdAt, updatedAt, productName, price, productName,stockQuantity, brand createdAt
    sortDir string No Sort direction asc, desc desc

    Request URL Examples:

    # Price range filter
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?minPrice=500&maxPrice=1500&brand=
    
    # Multiple brand filter (Apple&brand=Samsung&inStock=true OR Samsung)
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?onSale=brand=Apple&brand=Samsung&inStock=true&
    
    # Feature combination filter
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?hasGroupBuying=true&sortBy=pricehasInstallments=true&sortDir=asconSale=true
    
    # Category and condition filter
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?categoryId=123e4567-e89b-12d3-a456-426614174000&hasInstallments=truecondition=NEW&isFeatured=true
    
    # Complex filter with sorting
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?minPrice=100&maxPrice=2000&brand=Apple&brand=Dell&hasInstallments=true&sortBy=price&sortDir=asc
    
    # Tag-based filtering
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?tags=premium&tags=5g&inStock=true
    
    # Status filtering (requires authentication)
    GET /api/v1/shops/123e4567-e89b-12d3-a456-426614174000/products/advanced-filter?status=ACTIVE&status=DRAFT&hasGroupBuying=true
    

    Filter Logic & Combinations:

    Filter TypeLogicExample
    Price RangeAND (both minPrice AND maxPrice)Products between $500 AND $1500
    Multiple BrandsOR (Apple OR Samsung OR Dell)Products from any of the specified brands
    Multiple TagsOR (premium OR 5g OR wireless)Products with any of the specified tags
    Multiple StatusesOR (ACTIVE OR DRAFT)Products with any of the specified statuses
    Feature FlagsAND (all must be true/false)Products that have group buying AND installments
    Combined FiltersAND (between different filter types)Price range AND brand AND features

    Response JSON Sample:

    {
      "success": true,
      "message": "Found 1218 products matching your filters",
      "data": {
        "contents": {
          "shop": {
            "shopId": "123e4567-e89b-12d3-a456-426614174000",
            "shopName": "TechStore Pro",
            "shopSlug": "techstore-pro",
            "logoUrl": "https://example.com/logos/techstore.techstore-pro.png",
            "isVerified": truetrue,
            "isApproved": true,
            "isMyShop": false
          },
          "products": [
            {
              "productId": "456e7890-e89b-12d3-a456-426614174001",
              "productName": "iPhone 15 Pro"Pro Max 512GB",
              "productSlug": "iphone-15-pro-max-512gb",
              "shortDescription": "Premium 6.7-inch iPhone with A17 Pro chip",
              "primaryImage": "https://example.com/images/iphone15-pro-max.jpg",
              "price": 999.1199.00,
              "comparePrice": 1299.00,
              "finalPrice": 1199.00,
              "isOnSale": true,
              "discountPercentage": 7.69,
              "stockQuantity": 25,
              "isInStock": true,
              "isLowStock": false,
              "brand": "Apple",
              "sku": "SHP12345678-ELE-APP-512-0001",
              "condition": "NEW",
              "status": "ACTIVE",
              "isFeatured": true,
              "isDigital": false,
              "hasGroupBuying": true,
              "hasInstallments": true,
              "hasMultipleColors": true,
              "isFeatured"groupPrice": 1099.00,
              "startingFromPrice": 1199.00,
              "createdAt": "2025-09-23T10:30:00Z"
            },
            {
              "productId": "567e8901-e89b-12d3-a456-426614174002",
              "productName": "Samsung Galaxy S24 Ultra",
              "productSlug": "samsung-galaxy-s24-ultra",
              "shortDescription": "Premium Android flagship with S Pen",
              "primaryImage": "https://example.com/images/samsung-s24-ultra.jpg",
              "price": 1099.00,
              "comparePrice": 1199.00,
              "finalPrice": 1099.00,
              "isOnSale": true,
              "discountPercentage": 8.34,
              "stockQuantity": 12,
              "isInStock": true,
              "isLowStock": false,
              "brand": "Samsung",
              "sku": "SHP12345678-ELE-SAM-ULT-0007",
              "condition": "NEW",
              "status": "ACTIVE",
              "isFeatured": true,
              "isDigital": false,
              "hasGroupBuying": true,
              "hasInstallments": true,
              "hasMultipleColors": true,
              "groupPrice": 999.00,
              "startingFromPrice": 1099.00,
              "createdAt": "2025-09-22T14:15:00Z"
            }
          ],
          "totalProducts": 12,18,
          "filterMetadata": {
            "appliedFilters": {
              "minPrice": 500.800.00,
              "maxPrice": 1500.00,
              "brands": ["Apple", "Samsung"],
              "inStock": true,
              "onSale": true,
              "hasGroupBuying": true,
              "hasInstallments": true,
              "isFeatured": true
            },
            "userType": "PUBLIC",
            "searchedStatuses": ["ACTIVE"],
            "hasActiveFilters": true
          }
        },
        "currentPage": 1,
        "pageSize": 10,
        "totalElements": 12,18,
        "totalPages": 2,
        "hasNext": true,
        "hasPrevious": false
      }
    }
    

    Applied Filters Metadata: The appliedFilters object shows exactly which filters were applied:

    Filter CombinationsCategoryPossible ValuesLogic
    Price FiltersminPrice, maxPriceRange filtering (between values)
    Brand Filtersbrands arrayOR logic (any of the brands)
    Availability FiltersinStock, onSaleBoolean filtering
    Feature FiltershasGroupBuying, hasInstallments, hasMultipleColors, isFeaturedBoolean filtering
    Category FiltercategoryIdExact match
    Condition FilterconditionExact match
    Tag Filterstags arrayOR logic (any of the tags)
    Status Filtersstatus arrayOR logic (any of the statuses)

    Filter Validation Rules:

    FilterValidationError Behavior
    minPrice/maxPriceMust be positive numbers, maxPrice >= minPrice400 Bad Request
    brandMust be non-empty stringsIgnored if empty
    categoryIdMust be valid UUID and existing category404 Not Found
    tagsMust be non-empty stringsIgnored if empty
    conditionMust be valid ProductCondition enum400 Bad Request
    statusMust be valid ProductStatus enum values400 Bad Request
    Boolean filtersMust be true/false400 Bad Request

    Performance Considerations:

    • PriceFilters Range:use minPrice=100&maxPrice=500database filtersindexing productsfor betweenoptimal $100-$500performance
    • MultipleComplex Brands:filter brand=Apple&brand=Samsungcombinations showsare productsoptimized fromwith AppleJPA OR SamsungSpecifications
    • FeaturePage Combinations:size hasGroupBuying=true&hasInstallments=truelimited showsto products50 withitems bothto featuresprevent performance issues
    • Stock + Sale: inStock=true&onSale=true shows available products on sale
    • Category + Condition: Combine categoryPopular filter withcombinations productare conditioncached for better response times

    User Permission Differences:

    User TypeAvailable Status FiltersAdditional Features
    Public UserACTIVE onlyBasic filtering
    Shop Owner/AdminAll statusesCan filter draft, inactive, archived products
    System AdminAll statusesFull access to all filter combinations

    Error Responses:

    • 400 Bad Request: Invalid filter values, price range errors, or invalid parameters
    • 404 Not Found: Shop not foundfound, category not found, or shop not availableaccessible
    • 422 Unprocessable Entity: Filter combination validation errors

    Common Filter Use Cases:

    1. Price Shopping: minPrice=500&maxPrice=1000&sortBy=price&sortDir=asc
    2. Brand Comparison: brand=Apple&brand=Samsung&hasInstallments=true
    3. Feature Shopping: hasGroupBuying=true&hasInstallments=true&onSale=true
    4. Category Browsing: categoryId=UUID&inStock=true&sortBy=price
    5. Premium Products: isFeatured=true&hasMultipleColors=true&minPrice=500
    6. Sale Items: onSale=true&inStock=true&sortBy=discountPercentage&sortDir=desc

    Quick Reference Guide

    Common HTTP Status Codes

    • 200 OK: Successful GET/PUT/PATCH request with response data
    • 201 Created: Successful POST request, resource created
    • 204 No Content: Successful DELETE request (hard delete)
    • 400 Bad Request: Invalid request data, validation errors, or business rule violations
    • 401 Unauthorized: Authentication required/failedrequired, invalid token, or expired token
    • 403 Forbidden: Insufficient permissions (shop owner/owner or system admin required)
    • 404 Not Found: Resource not foundfound, shop not accessible, or product not available
    • 409 Conflict: Duplicate product name/SKUSKU, or business constraint violation
    • 422 Unprocessable Entity: Validation errors with detailed field-level messages
    • 429 Too Many Requests: Rate limit exceeded (search/filter endpoints)
    • 500 Internal Server Error: Server error during processing

    Authentication Types

    • Bearer Token: Include Authorization: Bearer your_token in headers
    • None: No authentication required for public product viewing
    • Optional: Enhanced features available with authentication

    User Access Levels & Permissions

    User TypeProduct ManagementSearch/FilterStatus AccessSpecial Features
    Public UserView active products onlyBasic search/filterACTIVE onlyNo management data
    Authenticated UserView active products onlyBasic search/filterACTIVE onlySame as public unless shop owner
    Shop OwnerFull CRUD on own shopEnhanced search/filterAll statusesManagement statistics, draft products
    System AdminFull CRUD on all shopsEnhanced search/filterAll statusesCross-shop access, system statistics

    Data Format Standards

    • Dates: Use ISO 8601 format (2025-09-23T14:30:00Z)
    • Prices: Use decimal with 2 decimal places (999.00), stored as BigDecimal
    • UUIDs: Use standard UUID format (123e4567-e89b-12d3-a456-426614174000)
    • Pagination: 1-indexed pages (page parameter starts from 1)
    • URLs: Must be valid URLHTTP/HTTPS formatURLs for product images and color images
    • Colors: Hex format (#1D1D1F) for color codescodes, case insensitive
    • Percentages: Decimal format (20.00 for 20%), max 2 decimal places
    • Currency: Use shop's base currency, no currency symbols in API

    Product Status Lifecycle

      DRAFT 
    • โ†’ ACTIVE โ†’ INACTIVE โ†’ ARCHIVED โ†‘ โ†“ โ†“ โ†‘ โ””โ”€โ”€ RESTORE โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ OUT_OF_STOCK โ†โ†’ ACTIVE (automatic based on inventory)
    • (notpublic) Product is live
    • Product temporarily
    • Product
    • Product no
      StatusDescriptionPublic VisibilityManagement Actions
      DRAFT: Product being created/edited Hidden Edit,
    • Publish, Hard Delete
    • ACTIVE: Live and available for purchase VisibleEdit, Deactivate, Soft Delete
      INACTIVE: Temporarily unavailable HiddenEdit, Activate, Soft Delete
      OUT_OF_STOCK: No isinventory outavailableVisible with "Out of stockStock" Restock (auto-activates)
      ARCHIVED: No longer sold butsold, kept for history HiddenRestore, View only

      Product Conditions

      • ConditionDescriptionTypical Use Case
        NEW: Brand newnew, unused product New retail items
        USED_LIKE_NEW: Minimal use, like newperfect condition Returns, demo units
        USED_GOOD: Good condition with minor wear Refurbished items
        USED_FAIR: Fair condition with noticeable wear Budget/economy items
        REFURBISHED: Professionally restored
      • to working order
      • Certified refurbished
        FOR_PARTS: Sold for parts/parts or repair only Non-functional items

        ReqAction Values & Effects

        • (status:DRAFT)
        • Saveshop
          ActionEffect on StatusUse Case
          SAVE_DRAFT: Sets status to DRAFTSave productwork asin draftprogress
          SAVE_PUBLISH: Sets and publish product (status: ACTIVE)

          Role-Based Access Control

          • Public Users: Can view active products, search, and filter
          • Shop Owners: Full CRUD operations on their shop products
          • System Admins: Full accessstatus to allACTIVE
          Immediate productspublication

          Advanced Features Overview

          Group Buying System

          Group Formation โ†’ Time Limit โ†’ Minimum Check โ†’ Price Activation
               โ†“               โ†“            โ†“               โ†“
            Users Join โ†’ Countdown Timer โ†’ Min Size Met โ†’ Discount Applied
          

          Requirements:

          • AllowsgroupMinSize: customersMinimum toparticipants (min: 2)
          • groupMaxSize: Maximum participants (must be >= groupMinSize)
          • groupPrice: Discounted price (must be < regular price)
          • groupTimeLimitHours: Formation time limit (1-8760 hours)
          • groupRequiresMinimum: Whether minimum size is mandatory

          Business Rules:

          • Group price must be less than regular price
          • Time limit starts when first user joins
          • If minimum not reached and required, group togetherfails
          • Successful groups lock in the discount for bulkall pricing
          • Requires minimum and maximum group size
          • Time-limited offers with countdown
          • Automatic price reduction when group requirements metparticipants

          Installment Payment System

          Product Price โ†’ Down Payment โ†’ Remaining Amount โ†’ Monthly Payments
                โ†“             โ†“              โ†“                    โ†“
             $1000.00    โ†’  $200.00    โ†’   $800.00         โ†’  $133.33 x 6
          

          Payment Intervals:

          • MultipleDAYS: paymentDaily plan optionspayments (3,short-term 6, 12, 24 months)financing)
          • ConfigurableWEEKS: interestWeekly ratespayments (flexible scheduling)
          • DownMONTHS: paymentMonthly supportpayments with(standard percentage requirements
          • Payment schedule generationinstallments)

          Calculation Formula:

          Down Payment = Product Price ร— (Min Down Payment % รท 100)
          Remaining Amount = Product Price - Down Payment
          Interest Amount = Remaining Amount ร— (Interest Rate รท 100)
          Total Installment Amount = Remaining Amount + Interest Amount
          Payment Per Interval = Total Installment Amount รท Duration
          

          Color Variations System

          Price Calculation:

          Base Price + Color Price Adjustment = Final Color Price
          $999.00 + $50.00 = $1049.00 (Premium Color)
          $999.00 + $0.00 = $999.00 (Standard Color)
          

          Price Range Calculation:

          • MultipleminPrice: Lowest price across all color options per productvariations
          • PricemaxPrice: adjustmentsHighest perprice across all color variations
          • SeparatestartingFromPrice: imageSame setsas minPrice for eachcustomer color
          • Price range calculations (starting from $X)

          Product Specifications

          • Key-value specification pairs
          • Used for product comparisons
          • Searchable attributes
          • Technical product detailsdisplay

          Validation Rules Summary

          Product Creation/Update Validation

          FieldValidation RulesError Handling
          productNameMin: 2, Max: 100 chars, unique in shop400 Bad Request with field error
          productDescriptionMin: 10, Max: 1000 chars422 Unprocessable Entity
          priceMin: 0.01, Max: 8 digits, 2 decimal places400 Bad Request
          stockQuantityMin: 0400 Bad Request
          comparePriceMust be > price if providedCustom validation error
          groupPriceMust be < price if group buying enabledCustom validation error
          categoryIdMust exist and be active404 Not Found
          productImagesAt least 1 valid URL required422 Unprocessable Entity
          colors[].hexValid 6-digit hex format (#RRGGBB)400 Bad Request
          installmentPlansRequired if installmentEnabled=trueCustom validation error

          Business Logic Validation

          • ProductGroup NameSize Logic: 2-100groupMaxSize characters,>= unique within shop
          • Description: 10-1000 characters requiredgroupMinSize
          • Price Logic: MinimumcomparePrice $0.01,> maximumprice 8AND digitsgroupPrice with< 2 decimalsprice
          • StockOrder Quantity Logic: Non-negativemaxOrderQuantity integer>= minOrderQuantity
          • GroupInstallment Buying: Group max size >= min size, group price < regular price
          • InstallmentsLogic: At least one plan required when enabled
          • ColorsPublishing Requirements: Valid hex color codes, optional price adjustments
          • Images: Valid URLs, at least one image required

          Search & Filter Features

          • Multi-word Search: "dell precision" matches products with both terms
          • Cross-field Search: Searches name,Name, description, brand, tags, specifications
          • Price Range Filtering: Min/max price boundaries
          • Multi-brand Filtering: OR logic for multiple brand selections
          • Feature Filtering: Group buying, installments, multiple colors
          • Availability Filtering: Inprice, stock, oncategory, sale,images featured products
          • Status Filtering: Available to shop owners/admins onlyrequired

          SKU Generation FormatSystem

          Format: SHP[SHOP-UUID-8]8-CHAR-UUID]-[CATEGORY-3]-[BRAND-3]-[ATTRIBUTE-3]-[SEQUENCE-4]

          Example:Components:

          1. Shop Prefix: SHP + first 8 characters of shop UUID (uppercase)
          2. Category Code: First 3 characters of category name (uppercase, alphanumeric only)
          3. Brand Code: First 3 characters of brand name (uppercase, alphanumeric only)
          4. Attribute Code: Main product attribute from specifications or name (3 chars)
          5. Sequence Number: 4-digit sequential number within shop (0001, 0002, etc.)

          Examples:

          • SHP12345678-ELE-APP-256-0001 (Apple iPhone with 256GB storage)
          • SHP87654321-LAP-DEL-PRE-0005 (Dell Precision laptop)
          • SHP11223344-CLO-NIK-XLA-0012 (Nike XL clothing)

          Search & Filter Capabilities

          Search Query Processing

          Query TypeProcessingExampleResult
          Single Word%word% pattern"iphone"Matches "iPhone 15 Pro"
          Multi-word%word1%word2% pattern"dell precision"Matches products with both "dell" AND "precision"
          Partial MatchAutomatic partial matching"macb"Matches "MacBook"
          Cross-fieldSearches multiple fields"apple"Matches brand, name, description, tags

          Filter Combinations Logic

          AND Logic (between different filter types):
          Price Range AND Brand Filter AND Feature Filters
          
          OR Logic (within same filter type):
          Brand: Apple OR Samsung OR Dell
          Tags: premium OR 5g OR wireless
          Status: ACTIVE OR DRAFT OR INACTIVE
          

          Performance Optimizations:

          • SHP12345678:Database Shopindexes prefixon: withshop_id, 8-charstatus, UUIDprice, brand, category_id
          • ELE:JPA ElectronicsSpecifications categoryfor dynamic query building
          • APP:Page Applesize brandlimits (max 50 for public, max 100 for management)
          • 256:Query 256GBresult storagecaching attribute
          • for
          • 0001:popular Sequentialfilter numbercombinations

          Error Handling Guidelines

          Error Response Format

          {
            "success": false,
            "message": "Human-readable error message",
            "error": {
              "code": "ERROR_CODE",
              "details": "Detailed error information",
              "field": "fieldName (if field-specific)",
              "timestamp": "2025-09-23T14:30:00Z"
            }
          }
          

          Common Error Scenarios

          ScenarioHTTP CodeResponse Strategy
          Invalid Product Name400Field-specific validation message
          Product Not Found404Generic "Product not found" (security)
          Insufficient Permissions403"Insufficient permissions" without details
          Duplicate Product409"Product with similar details already exists"
          Publishing Validation400List all missing required fields
          Rate Limiting429Include retry-after header

          Best Practices for API Usage

          Product Management Best Practices

          1. Always validate required fields before creating/updatingcreating products
          2. Use appropriateSAVE_DRAFT action during product statuscreation process
          3. Use SAVE_PUBLISH action basedonly onwhen readinessproduct is complete
          4. Set appropriate low stock thresholds for inventory alerts
          5. Enable group buying for bulk products to increase sales volume
          6. Set up installments for high-value items (>$500) to improve accessibility
          7. Add comprehensive specifications for better search resultsdiscoverability
          8. Use high-quality product images for(minimum better800x600 conversionpixels recommended)
          9. Implement proper inventory tracking to avoidprevent overselling
          10. Regular price updates to maintain competitiveness

          Search & Filter Optimization

          1. Use pagination for better performance and user experience
          2. Implement client-side caching for popular search queries
          3. Provide search suggestions based on common queries
          4. Use filter combinations intelligently to reduce result sets
          5. Sort by relevance for search results, by price for filters
          6. Implement infinite scroll for mobile applications
          7. Show filter result counts before applying filters
          8. Provide clear filter reset functionality
          9. Use debouncing for real-time search input
          10. Cache filter metadata for faster subsequent requests

          Security Best Practices

          1. Always validate user permissions before product operations
          2. Sanitize search queries to prevent injection attacks
          3. Rate limit search endpoints to prevent abuse
          4. Validate all file uploads (images) before processing
          5. Use HTTPS for all API requests containing sensitive data
          6. Implement proper session management for authenticated users
          7. Log all product management actions for audit trails
          8. Validate price inputs to prevent negative or invalid values
          9. Check shop ownership before allowing product modifications
          10. Implement request throttling for high-frequency operations

          Performance Optimization

          1. Use appropriate page sizes (10-20 for mobile, 50+ for desktop)
          2. Implement database indexing on frequently queried fields
          3. Cache expensive calculations (group buying status, installment calculations)
          4. Use CDN for product images to improve load times
          5. Implement lazy loading for non-critical product details
          6. Optimize database queries using JPA Specifications efficiently
          7. Use compression for large response payloads
          8. Implement response caching for public product listings
          9. Monitor API response times and optimize slow endpoints
          10. Use connection pooling for database connections

          Business Logic Guidelines

          1. Maintain price consistency across all product variations
          2. Validate group buying economics (ensure profitability)
          3. Set realistic installment terms based on product value
          4. Implement inventory alerts at appropriate thresholds
          5. Use soft delete for published products to maintain order history
          6. Hard delete only draft products to keep database clean
          7. Validate category assignments for proper product organization
          8. Implement price change logging for audit purposes
          9. Set appropriate lowproduct stockconditions thresholdsbased on actual state
          10. Maintain SEO-friendly slugs for reorderbetter alertsdiscoverability

          API Integration Examples

          Creating a Complete Product (Recommended Flow)

          1. POST /shops/{shopId}/products (action=SAVE_DRAFT)
             - Create basic product structure
             - Validate required fields
             
          2. PUT /shops/{shopId}/products/{productId} (action=SAVE_DRAFT)
             - Add advanced features (group buying, installments)
             - Upload and set product images
             - Add specifications and color variations
             
          3. PATCH /shops/{shopId}/products/{productId}/publish
             - Final validation check
             - Publish to make publicly available
          

          Search Implementation Pattern

          1. Basic Search: GET /shops/{shopId}/products/search?q=query
          2. Add Filters: GET /shops/{shopId}/products/advanced-filter?brand=X&minPrice=Y
          3. Combine Both: Use search for text matching, filters for refinement
          4. Pagination: Always include page and size parameters
          5. Sort Results: Use appropriate sortBy based on user intent
          

          Error Recovery Strategies

          400 Errors: Validate input client-side, show field-specific errors
          401 Errors: Refresh authentication token, redirect to login
          403 Errors: Show access denied message, don't retry automatically  
          404 Errors: Handle gracefully, suggest alternatives
          409 Errors: Show conflict resolution options to user
          429 Errors: Implement exponential backoff retry strategy
          500 Errors: Log error details, show generic error message to user