Skip to content

Add Product

Description

The Add Product API allows businesses to add new products to their eCommerce platform. During the product creation process, you can specify product details such as name, description, price, color, specifications, variations, and more. The API also allows you to manage different colors and variations for your products.

Endpoint

POST /v1/products

Required Headers

json
{
  "Authorization": "Bearer JWT_TOKEN",
  "X-MerchantApiKey": "MERCHANT_API_KEY",
  "Content-Type": "application/json"
}

📥 Request Body

Here is a breakdown of each field in the ProductRequest DTO:

ProductRequest DTO

FieldTypeRequiredDescription
namestringYesThe name of the product.
descriptionstringYesThe product's detailed description (min 50 characters).
summarystringNoA brief product summary (min 10, max 255 characters).
imagestringYesThe main image URL for the product.
thumbnailstringYesThe thumbnail image URL for the product.
imageListlistNoA list of additional image URLs for the product.
featureslistNoA list of product features or specifications.
pricedoubleYesThe price of the product (must be greater than 1).
ramSizestringNoThe RAM size of the product (e.g., 4GB, 512MB, 12KB, 1TB).
storagestringNoThe storage capacity of the product.
sizestringNoThe size of the product (e.g., Large, Medium).
skustringNoStock Keeping Unit (SKU) identifier.
quantityInStockintegerYesThe quantity of the product available in stock.
brandIdstringNoThe brand ID for the product.
discountdoubleNoDiscount on the product (0-100%).
categoryIdstringYesThe category ID the product belongs to.
tenantIdstringYesMerchant API KEY for your business account.
colorIdstringNoColor ID for the product. Available colors can be found here. You can also specify a custom color using the customColor field.
customColorstringNoCustom color for the product (e.g., "Deep Red").
specificationslistNoList of product specifications. Each specification must have a key and value. More Info
variationslistYesVariations of the product (e.g., color, size). More Info

ProductSpecification DTO

Available specifications can be found here.

Product Specification
FieldTypeRequiredDescription
keystringYesThe specification key (e.g., "Battery Capacity").
valuestringYesThe specification value (e.g., "4000mAh").

ProductVariation DTO

Product Variation
FieldTypeRequiredDescription
colorstringYesThe color of the variation (use color from available options or `customColor`).
imagestringNoImage URL for the color variant.
priceDetailslistYesList of price details for this variation. [More Info](#productpricedetail-dto)

ProductPriceDetail DTO

Product PriceDetail
FieldTypeRequiredDescription
pricedoubleYesPrice for this variation.
newPricedoubleNoDiscounted price for this variation.
ramSizestringNoRAM size for this variation.
skustringYesSKU for this variation.
quantityInStockintegerYesQuantity in stock for this variation.
discountdoubleNoDiscount percentage for this variation.

Available Colors and Brands

  • To view available colors, visit the Color API.
  • To view available brands, visit the Brand API.
  • To view available Specifications, visit the Brand API.
  • You can use the customColor field to specify your own color if the color you desire isn't listed.

Example API Call (Fetch or Axios)

javascript
fetch('https://api.yourdomain.com/v1/products', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer JWT_TOKEN',
    'X-MerchantApiKey': 'MERCHANT_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: "LG 45 Inch Signature OLed TV",
    description: "A high-end 45 inch OLED smart TV.",
    summary: "LG 45 inch 4K Smart TV",
    image: "https://example.com/images/lg-tv.jpg",
    thumbnail: "https://example.com/images/lg-tv-thumb.jpg",
    features: ["OLED", "4K", "Smart TV"],
    price: 20000.00,
    ramSize: "4GB",
    storage: "500GB",
    size: "Large",
    sku: "TV12345",
    quantityInStock: 10,
    brandId: "brand123",
    discount: 10.0,
    categoryId: "category123",
    colorId: "color123",
    customColor: "Deep Red",
    specifications: [{ key: "Screen Size", value: "45 inches" }],
    variations: [{
      color: "Red",
      image: "https://example.com/images/red-tv.jpg",
      priceDetails: [{
        price: 20000,
        newPrice: 18000,
        sku: "TV-RED123",
        quantityInStock: 5,
        discount: 10
      }]
    }]
  })
})
.then(response => response.json())
.then(data => console.log(data));

📥 Request Samples

Here are the sample requests for different product creation scenarios:

1. Creating a Simple Product

json
{
  "name": "Smartphone",
  "description": "A high-end smartphone with great features.",
  "summary": "Smartphone 64GB",
  "image": "https://example.com/images/smartphone.jpg",
  "thumbnail": "https://example.com/images/smartphone-thumb.jpg",
  "price": 500.00,
  "ramSize": "4GB",
  "storage": "64GB",
  "size": "Medium",
  "sku": "SP12345",
  "quantityInStock": 50,
  "categoryId": "category123",
  "colorId": "color123",
  "customColor": "Black",
  "specifications": [
    {
      "key": "Battery Capacity",
      "value": "4000mAh"
    }
  ],
  "variations": []
}

2. Creating a Product with Specifications

json
{
  "name": "Laptop",
  "description": "High-performance laptop for professionals.",
  "summary": "Laptop 16GB RAM",
  "image": "https://example.com/images/laptop.jpg",
  "thumbnail": "https://example.com/images/laptop-thumb.jpg",
  "price": 1200.00,
  "ramSize": "16GB",
  "storage": "1TB",
  "size": "Large",
  "sku": "LT12345",
  "quantityInStock": 30,
  "categoryId": "category123",
  "colorId": "color123",
  "customColor": "Silver",
  "specifications": [
    {
      "key": "Display",
      "value": "15.6 inches"
    },
    {
      "key": "Processor",
      "value": "Intel i7"
    }
  ],
  "variations": []
}

3. Creating a Product with Specifications and Variations

json
{
  "name": "Smartwatch",
  "description": "A stylish smartwatch with fitness tracking features.",
  "summary": "Smartwatch 42mm",
  "image": "https://example.com/images/smartwatch.jpg",
  "thumbnail": "https://example.com/images/smartwatch-thumb.jpg",
  "price": 200.00,
  "ramSize": "1GB",
  "storage": "16GB",
  "size": "Small",
  "sku": "SW12345",
  "quantityInStock": 100,
  "categoryId": "category123",
  "colorId": "color123",
  "customColor": "Blue",
  "specifications": [
    {
      "key": "Water Resistance",
      "value": "50 meters"
    },
    {
      "key": "Battery Life",
      "value": "24 hours"
    }
  ],
  "variations": [
    {
      "color": "Black",
      "image": "https://example.com/images/smartwatch-black.jpg",
      "priceDetails": [
        {
          "price": 200.00,
          "newPrice": 180.00,
          "sku": "SW-BLK123",
          "quantityInStock": 50,
          "discount": 10
        }
      ]
    },
    {
      "color": "White",
      "image": "https://example.com/images/smartwatch-white.jpg",
      "priceDetails": [
        {
          "price": 200.00,
          "newPrice": 180.00,
          "sku": "SW-WHT123",
          "quantityInStock": 50,
          "discount": 10
        }
      ]
    }
  ]
}

4. Creating a Simple Product with Specifications and Variations

json
{
  "name": "Wireless Headphones",
  "description": "Comfortable wireless headphones with noise cancellation.",
  "summary": "Wireless Headphones 40mm",
  "image": "https://example.com/images/headphones.jpg",
  "thumbnail": "https://example.com/images/headphones-thumb.jpg",
  "price": 150.00,
  "ramSize": "N/A",
  "storage": "N/A",
  "size": "One Size",
  "sku": "HP12345",
  "quantityInStock": 75,
  "categoryId": "category123",
  "colorId": "color123",
  "customColor": "Black",
  "specifications": [
    {
      "key": "Noise Cancellation",
      "value": "Active Noise Cancellation"
    },
    {
      "key": "Battery Life",
      "value": "20 hours"
    }
  ],
  "variations": [
    {
      "color": "Black",
      "image": "https://example.com/images/headphones-black.jpg",
      "priceDetails": [
        {
          "price": 150.00,
          "newPrice": 135.00,
          "sku": "HP-BLK123",
          "quantityInStock": 40,
          "discount": 10
        }
      ]
    },
    {
      "color": "White",
      "image": "https://example.com/images/headphones-white.jpg",
      "priceDetails": [
        {
          "price": 150.00,
          "newPrice": 135.00,
          "sku": "HP-WHT123",
          "quantityInStock": 35,
          "discount": 10
        }
      ]
    }
  ]
}

Build with joy