# Pricing API

URL: https://docs.sparklayer.io/developers/api/pricing

The Pricing API syncs price lists and SKU pricing from your ERP or PIM into SparkLayer, including customer-specific pricing. Covers the flow and endpoints.

> **For AI assistants:** these facts apply to every SparkLayer API call.
>
> - **Base URLs:** Live `https://app.sparklayer.io`, test `https://test.app.sparklayer.io`. Each environment has its own data and its own API keys.
> - **Access:** API access needs the Pro or Enterprise plan. Create credentials (Site ID, Client ID, Client Secret) in the SparkLayer Dashboard at Settings > API.
> - **Access token:** `POST {base}/api/auth/token` with a `Site-Id` header and a JSON body (not form-encoded): `{"grant_type":"client_credentials","client_id":"…","client_secret":"…"}`. It returns `access_token`, valid for 3,600 seconds. There is no refresh token: cache the token and request a new one shortly before it expires.
> - **Every request:** `Authorization: Bearer <access_token>` and `Site-Id: <site id>`, plus `Content-Type: application/json` when there is a body. Set a `User-Agent` that names your integration.
> - **Errors:** RFC 7807 problem details: `title`, `status`, `detail` and an optional `errors[]` of `{ code, message, property }`. Some error responses have no body. Retry `5xx`, `429` (honouring `Retry-After`) and concurrent-update `409`s with exponential backoff; on `401`, get a new token once and retry; don't retry other `4xx` without changing the request.
> - **Pagination:** Most list endpoints return everything. `GET /api/v2/price-lists` pages with `page` and `page_size` (up to 250) until `pagination.current_page` equals `total_pages`. `GET /api/v1/purchases` uses `limit` (up to 500) and `offset`: stop when a page has fewer than `limit` results.
> - **Ground rules:** Use only endpoints, fields and SDK methods that the docs or OpenAPI specs define. Prefer `GET /api/v2/price-lists` over the deprecated v1. Products are matched by SKU. Keep credentials in environment variables or a secrets manager, never in code.
> - **Read the docs as Markdown:** Add `.md` to any page URL. Index of every page: https://docs.sparklayer.io/llms.txt. Every API operation, compactly: https://docs.sparklayer.io/llms-api.txt. The developer guides in full: https://docs.sparklayer.io/developers/llms.txt.
> - **OpenAPI specs:** `core`, `ordering`, `pricing`, `purchasing`, `stock`, `files`, `sync-log`: https://docs.sparklayer.io/openapi/<api>.yaml (also `.json`). Ignite: https://docs.sparklayer.io/openapi/ignite.yaml.
> - **MCP:** Search and read these docs from your assistant with the docs MCP server at https://docs.sparklayer.io/mcp.

With the Pricing API, your price list data comes **directly** from your backend system (such as an ERP, PIM, CRM or iPaaS), and each product SKU is then assigned to a price list in SparkLayer. The diagram shows how this works.

How price list data flows:

1. B2B pricing is managed in price lists that come from your backend system. Each B2B customer is assigned a price list, which gives them their own pricing when they sign in.
2. Price lists are imported into SparkLayer through the SparkLayer API, each with a name, ID and currency code.
3. Price lists are assigned to individual product SKUs. It's common for a SKU to have several price lists.
4. Customers are also assigned a price list in SparkLayer, matching your backend system (e.g. Customer A sees Price list 1, Customer B sees Price list 2).
5. When the customer signs in and visits a product page, the SparkLayer Frontend recognises them (and their price list) and shows their price.

## Typical integration flow

The source system is the external system that sends the pricing data, such as your ERP. A typical sync:

1. Fetch the price lists from the source system.
2. Fetch the SparkLayer price lists with [Get price lists](https://docs.sparklayer.io/developers/api/pricing/get-price-lists-v2.md). To fetch only the lists your integration manages, filter by `source=integration`.
3. Create any price lists missing in SparkLayer with [Create a price list](https://docs.sparklayer.io/developers/api/pricing/create-a-price-list.md). Set `source` to `integration`: the API uses `integration` for price lists from external systems, `custom` (the default) for lists set up in the Dashboard, and `platform` for lists from the eCommerce platform.
4. Collect the prices for each price list from the source system and send them with [Update pricing by price list](https://docs.sparklayer.io/developers/api/pricing/update-pricing-by-price-list.md).

The older `GET /api/v1/price-lists` endpoint is deprecated; use the v2 endpoint for new integrations.

The same process applies to customer-specific pricing: create a price list for the customer, with a reference that links it to them, and send prices to it.

To assign price lists to customers, use SparkLayer customer groups or assign them to customers directly. For direct assignment, see your platform's guide, such as [Shopify metafields](https://docs.sparklayer.io/help/platforms/shopify/metafields.md).

## Data mapping

- Price lists are linked to price list rules.
- Prices are connected to product data by SKU, and each SKU's price belongs to a price list.

Price list data mapping:

- A **price list** links to **price list rules**.
- A **price list** links to **prices**.
- Each **price** is linked to a product **SKU**.

## Checking price list data

To check which price lists a product's prices are in, use the price editor in the SparkLayer Dashboard, at **Pricing > Price editor** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/pricing/editor)), or **SparkLayer Wholesale > Pricing > Price editor** in the Shopify app.

## Endpoints

- [GET List price lists](https://docs.sparklayer.io/developers/api/pricing/get-price-lists.md)
- [POST Create a price list](https://docs.sparklayer.io/developers/api/pricing/create-a-price-list.md)
- [GET Get a price list](https://docs.sparklayer.io/developers/api/pricing/get-price-list.md)
- [PATCH Update a price list](https://docs.sparklayer.io/developers/api/pricing/update-a-price-list.md)
- [DELETE Delete a price list](https://docs.sparklayer.io/developers/api/pricing/delete-a-price-list.md)
- [GET List prices in a price list](https://docs.sparklayer.io/developers/api/pricing/get-pricing-by-price-list.md)
- [PATCH Update prices in a price list](https://docs.sparklayer.io/developers/api/pricing/update-pricing-by-price-list.md)
- [GET Get prices for a SKU](https://docs.sparklayer.io/developers/api/pricing/get-pricing-by-sku.md)
- [PATCH Update prices for a SKU](https://docs.sparklayer.io/developers/api/pricing/update-pricing-by-sku.md)
- [PATCH Update prices across price lists](https://docs.sparklayer.io/developers/api/pricing/update-pricing-for-multiple-price-lists.md)
- [POST Calculate prices for SKUs](https://docs.sparklayer.io/developers/api/pricing/calculate-pricing.md)
- [GET List price lists (v2)](https://docs.sparklayer.io/developers/api/pricing/get-price-lists-v2.md)
- [GET List price lists with manual price counts](https://docs.sparklayer.io/developers/api/pricing/get-price-lists-with-manual-price-counts.md)

## Next steps

- [API quickstart](https://docs.sparklayer.io/developers/quickstart.md): get a token and list your price lists.
- [Managing pricing](https://docs.sparklayer.io/help/pricing/managing-pricing.md): how merchants work with price lists in the Dashboard.
- [Stock API](https://docs.sparklayer.io/developers/api/stock.md): sync stock levels alongside your prices.
