Products API

Create, read, update, and delete products. Manage variants, attributes, inventory, and SEO metadata.

Endpoints

MethodEndpointDescription
GET/productsList all products
POST/productsCreate a product
GET/products/:idGet a product
PUT/products/:idUpdate a product
DELETE/products/:idDelete a product (soft delete)
GET/products/attributesGet all attribute keys/values
GET/products/by-attributesFilter products by attributes
GET/products/by-variant-groupGet all variants in a group

All endpoints are prefixed with /stores/{storeId}.

The Product Object

{
  "id": "prod_abc123",
  "storeId": "store_xyz789",
  "title": "Wireless Headphones",
  "slug": "wireless-headphones",
  "status": "published",
  "publishedAt": "2024-01-15T10:30:00.000Z",
  "description": "Premium wireless headphones with noise cancellation.",
  "price": "199.99",
  "compareAtPrice": "249.99",
  "sku": "WH-001",
  "barcode": "1234567890123",
  "variantGroupId": "headphones-color-variants",
  "attributes": {
    "color": "Black",
    "connectivity": "Bluetooth 5.0"
  },
  "trackStock": true,
  "stock": 50,
  "allowBackorder": false,
  "categoryIds": ["cat_electronics", "cat_audio"],
  "primaryMediaId": "media_img001",
  "mediaIds": ["media_img001", "media_img002", "media_img003"],
  "seoTitle": "Wireless Headphones - Premium Audio",
  "seoDescription": "Shop premium wireless headphones with active noise cancellation.",
  "seoKeywords": "headphones, wireless, bluetooth, noise cancelling",
  "seoImageId": "media_img001",
  "createdAt": "2024-01-10T08:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}

Field Reference

FieldTypeDescription
idstringUnique identifier (UUID)
titlestringProduct title (1-255 chars, required)
slugstringURL-friendly identifier (unique per store)
statusenumdraft, published, archived, deleted
pricestringPrice as decimal string (e.g., "99.99")
compareAtPricestring?Original price for sale display
skustring?Stock Keeping Unit (unique per store)
barcodestring?UPC, EAN, or ISBN
variantGroupIdstring?Groups related variants together
attributesobjectKey-value pairs (e.g., color, size)
trackStockbooleanEnable inventory tracking
stockintegerAvailable quantity
allowBackorderbooleanAllow orders when out of stock
categoryIdsstring[]Array of category IDs
primaryMediaIdstring?Main product image
mediaIdsstring[]All product images (ordered)

List Products

GET /stores/{storeId}/products

Query Parameters

ParameterTypeDescription
limitintegerResults per page (1-200, default: 50)
offsetintegerNumber of items to skip (default: 0)
statusstringFilter by status (draft, published, archived)
slugstringFind by exact slug
skustringFind by exact SKU
variantGroupIdstringFilter by variant group
searchstringSearch in title, description, SKU

Example

curl "https://api.barecommercecore.com/stores/{storeId}/products?status=published&limit=20" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"

Response

{
  "items": [
    {
      "id": "prod_abc123",
      "title": "Wireless Headphones",
      "slug": "wireless-headphones",
      "status": "published",
      "price": "199.99"
    }
  ],
  "total": 42
}

Create Product

POST /stores/{storeId}/products

Requires products:write scope.

Required Fields

  • title — Product name (1-255 characters)
  • slug — URL-friendly identifier (unique per store)
  • price — Price as decimal string (e.g., "99.99")

Example

curl -X POST "https://api.barecommercecore.com/stores/{storeId}/products" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Wireless Headphones",
    "slug": "wireless-headphones",
    "price": "199.99",
    "compareAtPrice": "249.99",
    "description": "Premium wireless headphones with noise cancellation.",
    "status": "draft",
    "sku": "WH-001",
    "trackStock": true,
    "stock": 100,
    "attributes": {
      "color": "Black",
      "connectivity": "Bluetooth 5.0"
    },
    "categoryIds": ["cat_electronics", "cat_audio"]
  }'

Get Product

GET /stores/{storeId}/products/{productId}

Update Product

PUT /stores/{storeId}/products/{productId}

Only include fields you want to change.

Example: Publish a Product

curl -X PUT "https://api.barecommercecore.com/stores/{storeId}/products/prod_abc123" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "published" }'

When you set status to "published" for the first time, publishedAt is automatically set.

Delete Product

DELETE /stores/{storeId}/products/{productId}

Soft-delete (sets status to "deleted"). Returns 204 No Content.

Specialized Endpoints

Get Attributes

GET /stores/{storeId}/products/attributes

Returns all attribute keys and their unique values across your product catalog.

{
  "keys": ["color", "size", "material"],
  "values": {
    "color": ["Black", "White", "Navy"],
    "size": ["S", "M", "L", "XL"],
    "material": ["Cotton", "Polyester"]
  }
}

Filter by Attributes

GET /stores/{storeId}/products/by-attributes?color=Black&size=L

Get Variants

GET /stores/{storeId}/products/by-variant-group?variantGroupId=tshirt-basic

Working with Variants

BareCommerce models variants as separate products linked by variantGroupId.

// Create the base product
await createProduct({
  title: "Basic T-Shirt - Black",
  slug: "basic-tshirt-black",
  variantGroupId: "basic-tshirt",
  price: "29.99",
  sku: "TSHIRT-BLK-M",
  attributes: { color: "Black", size: "M" },
});
 
// Create additional variant
await createProduct({
  title: "Basic T-Shirt - White",
  slug: "basic-tshirt-white",
  variantGroupId: "basic-tshirt",
  price: "29.99",
  sku: "TSHIRT-WHT-M",
  attributes: { color: "White", size: "M" },
});

Inventory Management

FieldDescription
trackStockEnable to validate stock during orders
stockCurrent available quantity
allowBackorderAllow orders even when stock is 0

Stock is automatically decremented when orders are created. See Inventory for more details.

Error Responses

400 Validation Error

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "details": [{ "field": "price", "message": "Invalid price format" }]
  }
}

409 Conflict (Duplicate)

{
  "error": {
    "code": "CONFLICT",
    "message": "slug already exists"
  }
}

Webhooks

  • product.created — When a product is created
  • product.updated — When a product is modified
  • product.deleted — When a product is deleted

Related Guides