Skip to content

Sync a product catalogue into BIRP

Create and update the products of a shop in BIRP, without duplicates, one by one or in batches.

Version v1.1, updated

On this page

You will keep the products of a shop or another system in step with BIRP. Each product is linked to its id in your system, so every sync updates it instead of creating a copy.

Before you start

  • A key with products:write and products:read, plus categories:write if you create categories.

  • A source name for your system, such as woocommerce. Keep it the same forever: it is part of every external id.

  • For each product, its kind: goods for resale goods bought and sold as they are, finished_product for what the company makes. The kind never changes.

Steps

Send each product with an upsert

PUT /v1/products/external/{source}/{external_id} creates the product when the external id is new, and updates it otherwise. The answer is 201 for a new product and 200 for an update.

PUT /v1/products/external/{source}/{external_id}
curl -X PUT "https://api.birp.io/v1/products/external/woocommerce/1042" \
  -H "Authorization: Bearer $BIRP_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"currency":"MDL","kind":"goods","name":"Wheat flour 25 kg","price":"12.50","sku":"SP-FLOUR-25","unit":"kg"}'

Match the products BIRP already has

When the body has a sku that a product of the same kind already has, the upsert links your external id to that product. It updates that product and creates no duplicate, even on the first sync.

A write refuses a SKU that another product of the company already has, of either kind. Leave sku out on a create and BIRP gives the product a reference from the company numbering.

Send many products at once

POST /v1/products/batch takes up to 100 products, each matched by external id, SKU or id. See Batch operations.

POST /v1/products/batch
curl -X POST "https://api.birp.io/v1/products/batch" \
  -H "Authorization: Bearer $BIRP_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"data":{"currency":"MDL","kind":"goods","name":"Wheat flour 25 kg","price":"12.50","sku":"SP-FLOUR-25","unit":"kg"},"match":{"external_id":"1042","source":"woocommerce"}},{"data":{"kind":"finished_product","name":"White bread 500 g","price":"3.20"},"match":{"sku":"FP-BREAD-500"}},{"data":{"kind":"goods","name":"Rye flour 25 kg"},"match":{"id":"00000000-0000-4000-8000-000000000099"}}]}'

Archive what you no longer sell

Send "status": "archived" in an upsert or a PATCH, and "active" to restore it. Nothing is deleted through the API.

What BIRP does not take

The API writes the name, SKU, barcode, unit, category, price, currency and status of a product. Purchase prices, suppliers, images, storage conditions and recipes are managed in BIRP only, and a body that sends them answers 422 validation_failed.

A price has at most two decimals. Use prices up to 99 999.99: a larger price can be refused with 422 validation_failed.

Check the result

Find a product by its external id with GET /v1/products?source=woocommerce&external_id=1042. After a sync, updated_since with the start time of the sync lists every product it changed.

What can go wrong

Answer

Cause

Fix

409 sku_taken

Another product of the company has the SKU.

Use another SKU, or link the external id to that product.

409 kind_mismatch

The external id is linked to a product of the other kind.

Keep the kind of the product, or use a new external id.

409 barcode_taken

Another product of the company has the barcode.

Correct the barcode in one of the two systems.

409 external_id_conflict

An external id in external_ids already belongs to another product.

Remove it from that product first, or send another one.

422 reference_not_found

The category names no category of that kind.

Create the category first, or fix the reference.

  • references-and-external-ids
  • batches
  • products
  • categories