Search Documentation

Search for a documentation page...

Products

Browse, create, update, and delete products using the Commerce SDK.

Browse Products

Fetch a paginated list of products:

const products = await commerce.productBrowse({
limit: 10,
offset: 0,
});

Parameters

ParameterTypeDescription
limitnumberMax items to return (default: 20)
offsetnumberNumber of items to skip
collectionSlugstringFilter by collection
categorySlugstringFilter by category

Get a Product

Fetch a single product by ID or slug:

const product = await commerce.productGet({
idOrSlug: "classic-tee",
});

Response

{
id: "prod_abc123",
name: "Classic Tee",
slug: "classic-tee",
summary: "A comfortable everyday tee",
description: "Full markdown description...",
images: ["https://..."],
variants: [
{
id: "var_xyz",
sku: "CT-SM-BLK",
price: "2500", // in cents
name: "Small / Black",
inventory: 42,
}
],
collections: [...],
categories: [...],
}

Create a Product

const product = await commerce.productCreate({
name: "New Product",
slug: "new-product",
summary: "A great new product",
description: "Detailed description in markdown",
});

Update a Product

const updated = await commerce.productUpdate(
{ idOrSlug: "new-product" },
{ name: "Updated Product Name" },
);

Delete a Product

await commerce.productDelete({ idOrSlug: "new-product" });

Working with Variants

Products have variants for different options (size, color, etc.). Manage variants with dedicated methods:

// Create a variant
await commerce.variantCreate(
{ idOrSlug: "classic-tee" },
{ sku: "CT-LG-RED", price: "2500", name: "Large / Red" },
);

// Update a variant
await commerce.variantUpdate(
{ idOrSku: "CT-LG-RED" },
{ price: "2900" },
);

// Delete a variant
await commerce.variantDelete({ idOrSku: "CT-LG-RED" });