> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Commerce & products

Manage a Shopify store's catalog, read, refund, cancel and edit its orders, create draft orders and look up its customers through the Commerce API, and the deprecated Products API.

## Commerce

A connected store is a Commerce store. Pass this account's id as `accountId` to the [Commerce API](/guides/commerce) at `/v1/commerce`.

It creates and edits products, variants, images, stock, collections, discounts, sales channel publishing, market prices, metafields, metaobjects, pages, menus, redirects and marketing activities.

It reads orders, refunds, cancels and edits them, creates draft orders and looks up customers, which is what a help desk needs.

It can also sync the store into a Meta catalog for catalog ads.

Products, collections, metafields and pages work on every install.

Stock, sales channels, discounts, navigation, metaobjects, markets, marketing activities, image removal, orders, refunds, cancels, order edits, draft orders and customers need optional scopes.

`GET /v1/commerce/store` lists them in `missingCapabilities` and returns `grantPermissionsUrl`, where the merchant approves them without reinstalling. See [Grant optional permissions](#grant-optional-permissions).

```bash
curl "https://zernio.com/api/v1/commerce/store?accountId=66b2e19d8c3f5a7e9d0b1c2d" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

## Grant optional permissions

Send the owner to `grantPermissionsUrl`. It approves the missing scopes on the existing install in the Shopify admin, with no reinstall, and the owner can revoke them later.

Call [Get a store](/commerce/get-commerce-store) again to read the new `capabilities`.

- **Blogs-only stores** are never asked for the optional scopes.
- **`grantPermissionsUrl` is `null`** when nothing is missing, and on a store connected with a custom-app token. That token carries the custom app's scopes, so the merchant adds the scopes to their custom app.
- **Older connections:** a store connected before product access existed lacks the required product scopes, which the link does not cover. [Reconnect](/platforms/shopify#connect) it.
- **Orders:** without `read_all_orders` Shopify returns only the last 60 days, so a store with only `read_orders` still lists `orders.read` as missing.

| Capability | Shopify scope |
|------------|---------------|
| `products.read`, `collections.read`, `metafields.read` | `read_products` (always granted) |
| `products.create`, `products.update`, `products.status`, `products.price`, `products.variants`, `products.images`, `collections.write`, `collections.metafields`, `metafields.write` | `write_products` (always granted) |
| `pages.read` / `pages.write` | `read_content` / `write_content` (always granted) |
| `products.images_remove` | `write_files` |
| `inventory.read` | `write_inventory` and `read_locations` |
| `inventory.write` | `write_inventory` and `read_locations` |
| `channels.read`, `channels.write` | `write_publications` |
| `discounts.read`, `discounts.write`, `discounts.codes` | `write_discounts` |
| `navigation.read`, `navigation.write` | `write_online_store_navigation` |
| `metaobjects.read`, `metaobjects.write` | `write_metaobjects` |
| `markets.read` | `write_markets` |
| `markets.write` | `write_markets` and `write_products` |
| `marketing.write` | `write_marketing_events` |
| `orders.read` | `read_orders` and `read_all_orders` |
| `orders.refund`, `orders.cancel` | `write_orders` |
| `customers.read` | `read_customers` |
| `orders.edit` | `write_order_edits` |
| `draft_orders.read`, `draft_orders.write` | `write_draft_orders` |

## Read orders

[List orders](/commerce/list-commerce-orders) and [Get an order](/commerce/get-commerce-order) read the store's orders with line items, discounts, tax, shipping, payment status and refunds. See [Sync orders](/guides/commerce#sync-orders) for paging and webhooks.

```bash
curl "https://zernio.com/api/v1/commerce/orders?accountId=66b2e19d8c3f5a7e9d0b1c2d&updatedAfter=2026-10-20T08:00:00Z" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

Orders need `orders.read`, which takes the optional scopes `read_orders` and `read_all_orders`. Until the store grants both, `GET /v1/commerce/store` lists `orders.read` in `missingCapabilities` and its `grantPermissionsUrl` asks for them.

A page holds at most 25 orders. `customer`, `billingAddress` and `shippingAddress` are `null` when the store's approval does not cover buyer data.

Each order's `attribution` carries the first and last visit from Shopify's customer journey, with landing page, referrer and UTM parameters, plus the cart attributes. See [Order attribution](/guides/commerce#order-attribution).

Once the store grants the scopes, Zernio subscribes it to Shopify's order webhooks, which reach your [webhooks](/webhooks) as `commerce.order.created`, `commerce.order.updated` and `commerce.order.refunded`.

Paid orders are stored as `Purchase` events. To also send them to your ad platforms, turn on `forwardOrders` with `PATCH /v1/accounts/{accountId}/store-settings`, or "Forward orders" on the connection.

Orders paid after you turn it on go out with the Zernio Shopify pixel's event id, so a platform counts each once. Meta and TikTok get them only from a rule whose sources list `shopify`.

Filter the list by buyer with `customerId` or `email`, for example to show a support agent the orders behind a ticket.

## Refund an order

[Refund an order](/commerce/create-commerce-refund) returns line items, shipping or an amount of money to the buyer's original payment methods. It needs `orders.refund`.

Preview first with `validateOnly: true`: the response shows what the buyer gets back and to which payments, and nothing is refunded.

```bash
curl -X POST "https://zernio.com/api/v1/commerce/orders/5823117459731/refunds" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "lineItems": [{ "lineItemId": "14512301457683", "quantity": 1, "restock": true }],
    "validateOnly": true
  }'
```

Send the same body without `validateOnly`, with an `Idempotency-Key` header, to refund. The response (`201`) has the `refund` and the updated `order`.

```bash
curl -X POST "https://zernio.com/api/v1/commerce/orders/5823117459731/refunds" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 8f14e45f-ceea-467f-a0e6-5e4b0c8d2a31" \
  -d '{
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "lineItems": [{ "lineItemId": "14512301457683", "quantity": 1, "restock": true }],
    "note": "Wrong size, returned",
    "notifyCustomer": true
  }'
```

- **What to refund:** `lineItems` (each optionally restocked), `shipping` (`{ "full": true }` or `{ "amount": "5.00" }`), or `amount` alone for a goodwill refund. `amount` with lines restocks the lines and refunds that much money.
- **`Idempotency-Key`** is required: a retry with the same key never refunds twice, even after a timeout.
- **Currency:** every amount, sent or returned, is in the currency the buyer paid in. Send `currency` to have a mismatch refused instead of guessed.

## Cancel an order

[Cancel an order](/commerce/cancel-commerce-order) needs `orders.cancel` and a `reason`: `customer`, `declined`, `fraud`, `inventory`, `staff` or `other`. By default it refunds the payments and restocks the items.

```bash
curl -X POST "https://zernio.com/api/v1/commerce/orders/5823117459731/cancel" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accountId": "66b2e19d8c3f5a7e9d0b1c2d", "reason": "customer", "notifyCustomer": true }'
```

Shopify cancels in the background. The call waits a few seconds and answers `200` with `cancelled: true`, or `202` with `cancelled: false` while it is still running; `commerce.order.updated` reports the outcome.

## Edit an order

[Edit an order](/commerce/create-commerce-order-edit) adds products and changes or removes lines (`quantity: 0`). It needs `orders.edit`.

Preview with `validateOnly: true` to see the new totals and what the buyer would owe, then send the same body without it and with an `Idempotency-Key` header.

```bash
curl -X POST "https://zernio.com/api/v1/commerce/orders/5823117459731/edits" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 3c9d2b7a-51e4-4f0b-9a63-2f8e1d6c4b10" \
  -d '{
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "add": [{ "variantId": "45123456789012", "quantity": 1 }],
    "quantities": [{ "lineItemId": "14512301457683", "quantity": 0, "restock": true }],
    "notifyCustomer": true
  }'
```

The response has the updated `order` and the `edit` totals. When the edit raises the total, the buyer owes `outstanding` and `notifyCustomer` emails them the change. When it lowers it, [refund](#refund-an-order) the difference.

## Create a draft order

[Create a draft order](/commerce/create-commerce-draft-order) builds an order for a customer: a replacement, a phone order or a custom quote. It needs `draft_orders.write`.

```bash
curl -X POST "https://zernio.com/api/v1/commerce/draft-orders" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "customerId": "7390214561937",
    "lineItems": [
      { "variantId": "45123456789012", "quantity": 1 },
      { "title": "Gift wrapping", "price": "5.00", "quantity": 1, "requiresShipping": false }
    ],
    "discount": { "type": "percentage", "value": 100, "title": "Replacement" }
  }'
```

- **Line items** are product variants (`variantId`) or custom items (`title` and `price`, in the store currency).
- **Address:** with `customerId` and no `shippingAddress`, the customer's default address is used.
- **Payment:** [send the invoice](/commerce/send-commerce-draft-order-invoice) to email the buyer the checkout link; the draft becomes an order once they pay. [Get a draft order](/commerce/get-commerce-draft-order) returns `orderId` then.

## Look up a customer

[List customers](/commerce/list-commerce-customers) finds the buyer behind a ticket by `email`, `phone` or `search` (name, email or phone), and [Get a customer](/commerce/get-commerce-customer) reads one. Both need `customers.read`.

```bash
curl "https://zernio.com/api/v1/commerce/customers?accountId=66b2e19d8c3f5a7e9d0b1c2d&email=ana%40example.com" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

Each customer has their order count, total spent, tags, note and default address. Read their orders with `GET /v1/commerce/orders?customerId=`.

## Shopify-only operations

These answer `400 platform_not_supported` on WooCommerce. Everything else in the [Commerce API reference](/commerce/get-commerce-store) works on both platforms.

- **Collections:** [reorder products](/commerce/reorder-commerce-collection-products); collection metafields: [list](/commerce/list-commerce-collection-metafields), [set](/commerce/set-commerce-collection-metafields), [delete](/commerce/delete-commerce-collection-metafields).
- **Discounts:** [add codes](/commerce/add-commerce-discount-codes).
- **Orders:** [refund](/commerce/create-commerce-refund), [cancel](/commerce/cancel-commerce-order), [edit](/commerce/create-commerce-order-edit), filter by `email`.
- **Draft orders:** [create](/commerce/create-commerce-draft-order), [get](/commerce/get-commerce-draft-order), [send the invoice](/commerce/send-commerce-draft-order-invoice).
- **Customers:** [list](/commerce/list-commerce-customers), [get](/commerce/get-commerce-customer).
- **Sales channels:** [list channels](/commerce/list-commerce-channels), [publish or unpublish a product](/commerce/change-commerce-product-channels), [publish or unpublish a collection](/commerce/change-commerce-collection-channels).
- **Markets and price lists:** [list markets](/commerce/list-commerce-markets), [list price lists](/commerce/list-commerce-price-lists), [set fixed prices](/commerce/set-commerce-price-list-prices), [remove fixed prices](/commerce/delete-commerce-price-list-prices).
- **Metaobjects:** [list definitions](/commerce/list-commerce-metaobject-definitions), [list of a type](/commerce/list-commerce-metaobjects), [get](/commerce/get-commerce-metaobject), [create](/commerce/create-commerce-metaobject), [update](/commerce/update-commerce-metaobject), [delete](/commerce/delete-commerce-metaobject).
- **Navigation menus:** [list](/commerce/list-commerce-menus), [get](/commerce/get-commerce-menu), [create](/commerce/create-commerce-menu), [replace](/commerce/update-commerce-menu), [delete](/commerce/delete-commerce-menu).
- **URL redirects:** [list](/commerce/list-commerce-redirects), [create](/commerce/create-commerce-redirect), [update](/commerce/update-commerce-redirect), [delete](/commerce/delete-commerce-redirect).

**Marketing activities** record a post, ad or message you ran for the merchant in the store's Marketing section, with its link and UTM parameters for attribution.

Use your own id (for example the Zernio post id) as `remoteId`.

- [Record a marketing activity](/commerce/upsert-commerce-marketing-activity), [delete one](/commerce/delete-commerce-marketing-activity), [report daily engagement](/commerce/add-commerce-marketing-engagement).

## Products

The Products API below is deprecated in favor of the [Commerce API](/guides/commerce), which returns the same catalog in the platform-neutral shape.

It keeps working for existing integrations. List and read products with their variants, options and images, and edit a product's own fields and variant prices.

All data lives on Shopify. Zernio proxies it and stores nothing.

### List products

Call `GET /v1/accounts/{accountId}/products`. Filter with `status` (`active`, `draft` or `archived`) and `query`, Shopify's product search syntax, which is passed through verbatim:

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: page } = await zernio.products.listProducts({
  path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d' },
  query: { status: 'active', query: 'vendor:Acme tag:summer', limit: 20 }
});

for (const product of page.products) {
  console.log(product.id, product.title, product.variants[0]?.price);
}
```
</Tab>
<Tab value="Python">
```python
page = client.products.list_products(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    status="active",
    query="vendor:Acme tag:summer",
    limit=20,
)

for product in page["products"]:
    print(product["id"], product["title"])
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/products?status=active&query=vendor%3AAcme%20tag%3Asummer" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "platform": "shopify",
  "products": [
    {
      "id": "8214569812345",
      "platform": "shopify",
      "title": "Linen shirt",
      "handle": "linen-shirt",
      "descriptionHtml": "<p>Breathable linen for warm days.</p>",
      "vendor": "Acme",
      "productType": "Shirts",
      "tags": ["summer", "linen"],
      "status": "active",
      "featuredImage": { "url": "https://cdn.shopify.com/s/files/1/.../linen-front.jpg", "altText": "Linen shirt, front" },
      "images": [{ "url": "https://cdn.shopify.com/s/files/1/.../linen-front.jpg", "altText": "Linen shirt, front" }],
      "options": [{ "name": "Size", "values": ["S", "M", "L"] }],
      "variants": [
        {
          "id": "45123456789012",
          "title": "S",
          "sku": "LINEN-S",
          "barcode": null,
          "price": "59.00",
          "compareAtPrice": "79.00",
          "inventoryQuantity": 12,
          "availableForSale": true,
          "selectedOptions": [{ "name": "Size", "value": "S" }]
        }
      ],
      "seo": { "title": "Linen shirt | Acme", "description": null },
      "totalInventory": 31,
      "onlineStoreUrl": "https://acme.com/products/linen-shirt",
      "createdAt": "2026-05-02T10:12:00Z",
      "updatedAt": "2026-09-01T08:30:00Z",
      "publishedAt": "2026-05-02T10:15:00Z"
    }
  ],
  "nextCursor": "eyJsYXN0X2lkIjo4MjE0NTY5ODEyMzQ1fQ=="
}
```

Pagination is the same cursor scheme as the Blogs API: `limit` 1 to 50 (default 20) and `nextCursor`, null on the last page.

The response carries the first 100 variants and the first 20 images of each product.

### Update a product

Call `PATCH /v1/accounts/{accountId}/products/{productId}` with any subset of `title`, `descriptionHtml`, `handle`, `vendor`, `productType`, `tags`, `status`, `seo` and `variants`.

- `tags` replaces the whole list.
- `variants` changes the price and compare-at price of the listed variant ids only. A variant that belongs to another product is a `400`.

The response is the product as it reads after the update.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: updated } = await zernio.products.updateProduct({
  path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d', productId: '8214569812345' },
  body: {
    descriptionHtml: '<p>Breathable linen for warm days. Now in three sizes.</p>',
    tags: ['summer', 'linen', 'new'],
    seo: { title: 'Linen shirt | Acme', description: 'A breathable linen shirt in S, M and L.' },
    variants: [{ id: '45123456789012', price: 54.0, compareAtPrice: 79.0 }]
  }
});

console.log(updated.product.variants[0].price); // "54.00"
```
</Tab>
<Tab value="Python">
```python
updated = client.products.update_product(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    product_id="8214569812345",
    description_html="<p>Breathable linen for warm days. Now in three sizes.</p>",
    tags=["summer", "linen", "new"],
    seo={"title": "Linen shirt | Acme", "description": "A breathable linen shirt in S, M and L."},
    variants=[{"id": "45123456789012", "price": "54.00", "compareAtPrice": "79.00"}],
)

print(updated["product"]["variants"][0]["price"])  # "54.00"
```
</Tab>
<Tab value="curl">
```bash
curl -X PATCH "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/products/8214569812345" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "descriptionHtml": "<p>Breathable linen for warm days. Now in three sizes.</p>",
    "tags": ["summer", "linen", "new"],
    "seo": { "title": "Linen shirt | Acme", "description": "A breathable linen shirt in S, M and L." },
    "variants": [{ "id": "45123456789012", "price": "54.00", "compareAtPrice": "79.00" }]
  }'
```
</Tab>
</Tabs>

Prices are decimal strings in the store currency. A number is accepted and formatted to two decimals.

Send `"compareAtPrice": null` to take a variant off sale.

`status: "draft"` unpublishes a product without deleting it, and `status: "archived"` hides it everywhere. Both are reversible with `status: "active"`.

### Every product operation

| Operation | Endpoint |
|-----------|----------|
| List products | `GET /v1/accounts/{accountId}/products` |
| Get a product | `GET /v1/accounts/{accountId}/products/{productId}` |
| Update a product | `PATCH /v1/accounts/{accountId}/products/{productId}` |

## How it behaves

- **Order attribution:** Shopify attributes a new order shortly after it is placed. Until then `ready` is `false` and both visits are `null`. No webhook fires when it becomes `true`, so read the order again later.
- **`customAttributes`** on an order's `attribution` holds the cart and note attributes.
- **Product changes** reach Zernio through Shopify's product webhooks, so catalog syncs refresh within minutes.

## Related

- [Commerce guide](/guides/commerce): the cross-store recipe.
- [WooCommerce commerce](/platforms/wordpress/commerce): what differs on WooCommerce.