Manage products
Keep your catalog in sync from your own system: create products, update prices and stock, and publish them when they are ready.
This guide shows a typical workflow for managing a catalog through the API. It uses the Products API.
Before you begin
- Create an API key with
products:readandproducts:write. See Authentication. - Choose a stable SKU for every product. The SKU is how you refer to a product from your own system.
1. Create products as drafts
Create each product as a draft, so that nobody sees it before it is complete:
const API = process.env.WAFLE_API;
const headers = {
'X-Wafle-Store-Key': process.env.WAFLE_KEY,
'Content-Type': 'application/json',
};
async function createDraft(product) {
const res = await fetch(`${API}/stores/your-store/v2/products`, {
method: 'POST',
headers,
body: JSON.stringify({ ...product, status: 'draft' }),
});
if (res.status === 409) return 'exists'; // SKU already in the store
if (!res.ok) throw new Error(`Create failed: ${res.status}`);
return 'created';
}
await createDraft({ sku: 'CANDLE-8OZ', name: 'Classic Candle, 8 oz', price: 24, stock: 50 });
A 409 means the SKU is already taken. Nothing was changed, so you can switch to an update instead.
2. Publish when ready
Set the status to active to make the product visible:
await fetch(`${API}/stores/your-store/v2/products/CANDLE-8OZ`, {
method: 'PATCH',
headers,
body: JSON.stringify({ status: 'active' }),
});
3. Update prices and stock
Send only the fields that changed:
import os, requests
API = os.environ["WAFLE_API"]
H = {"X-Wafle-Store-Key": os.environ["WAFLE_KEY"], "Content-Type": "application/json"}
def update(sku, **fields):
r = requests.patch(f"{API}/stores/your-store/v2/products/{sku}", json=fields, headers=H, timeout=30)
r.raise_for_status()
update("CANDLE-8OZ", price=26, stock=42)
Show a sale by sending a higher compare_at_price than price. Remove it by sending null.
4. Import in bulk
For large catalogs, use the bulk endpoint instead of one request per product, and keep a short pause between batches to stay within rate limits.
5. Handle errors
| Status | What to do |
| --- | --- |
| 401 / 403 | Check your key and its permissions. |
| 409 | The SKU already exists. Update it instead. |
| 422 | A value is not acceptable, for example compare_at_price is not greater than price. Fix the value. |
| 429 | Wait for Retry-After, then retry. |
Tips
- Treat your own system as the source of truth for SKUs, and the store as the place customers see.
- Test with a draft product and check it in the dashboard before you automate at scale.
- Do not store your key in code. Use environment variables.
Related
Need help with an integration? Contact support.