Introduction
Standalone Price Books provide a composable approach to setting the pricing of items for internationalization and B2B. The modular design provides businesses the flexibility to integrate with various other systems, adapt to changing business requirements and scale efficiently. Leveraging REST APIs, Standalone Price Books allows developers to have granular control over data, enabling a more customized user experience.
Quick Start
-
Ingestion API Setup - API Reference
First, setup a custom data source for the ingestion API. Instructions can be found here.
The Ingestion API REST endpoint is
https://ingest.api.nacelle.com/v1/price-book
.
To make use of it, you must provide the following headers in your requests:x-nacelle-space-id
x-nacelle-source-id
x-nacelle-ingest-token
You can find the values of these headers on the API Details page. To get there, select a space, navigate to Space Settings, then go to the API Details tab.
The
x-nacelle-ingest-token
can be generated by clicking on the Create New Key button. -
Create Price Book - API Reference
Use the generated ingest token to make a PUT request to the Ingest Price Book endpoint. Here is an example:
const fetch = require('node-fetch'); const url = 'https://ingest.api.nacelle.com/v1/price-book'; const options = { method: 'PUT', headers: { accept: 'application/json', 'x-nacelle-space-id': '1234', 'x-nacelle-source-id': '1234', 'x-nacelle-ingest-token': '1234', 'content-type': 'application/json' }, body: JSON.stringify({ entries: [ { sourceEntryId: '3858f62230ac3c915f300c664312c63g', createdAt: '2023-09-16T00:00:00', updatedAt: '2023-09-16T00:00:00', name: 'Japanese Experience', key: 'japan', currencyCode: 'JPY', countryCodes: [ 'JP' ] } ] }) }; fetch(url, options) .then(res => res.json()) .then(json => console.log(json)) .catch(err => console.error('error:' + err));
-
Create Pricing - API Reference
Use the generated ingest token to make a PUT request to the Ingest Pricing endpoint. This will create a pricing linking it to the previously created Price Book and a variant in your system. Here is an example:
const fetch = require('node-fetch'); const url = 'https://ingest.api.nacelle.com/v1/pricing'; const options = { method: 'PUT', headers: { accept: 'application/json', 'x-nacelle-space-id': '1234', 'x-nacelle-source-id': '1234', 'x-nacelle-ingest-token': '1234', 'content-type': 'application/json' }, body: JSON.stringify({ entries: [ { sourceEntryId: '3858f62230ac3c915f300c664312c63f', sourcePriceBookId: '2855f62230ac3c915f300c664312c62g', sourceVariantId: '3352f62230ac3c915f300c664312b18a', createdAt: '2023-09-16T00:00:00', updatedAt: '2023-09-16T00:00:00', price: { amount: 1200, currencyCode: 'JPY' } } ] }) }; fetch(url, options) .then(res => res.json()) .then(json => console.log(json)) .catch(err => console.error('error:' + err));
Updated 9 months ago