Introduction

Inventory provides a composable approach to setting the inventory of items. The modular design provides businesses the flexibility to integrate with various other systems, adapt to changing business requirements and scale efficiently. Leveraging REST APIs, Inventory allows developers to have granular control over data, enabling a more customized user experience.

Quick Start

  1. Ingestion API Setup

Setup a custom data source for the ingestion API.

The Ingestion API REST endpoints require 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.

  1. Create Inventory Item

Use the generated ingest token to make a PUT request to the Ingest Inventory Item endpoint. This will create an Inventory Item linking it to a product variant in your system. Here is an example:

const fetch = require('node-fetch');

const url = 'https://ingest.api.nacelle.com/v1/inventory-item';
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: 'aSourceItemId1a',
        sourceVariantId: 'aVariantEntryId',
        sku: 'aSKU',
        key: 'aKey',
        createdAt: '2011-10-05T14:48:00.000Z',
        updatedAt: '2011-10-05T14:48:00.000Z',
      }
    ]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));
  1. Create Inventory Location

Use the generated ingest token to make a PUT request to the Ingest Inventory Location endpoint. Here is an example:

const fetch = require('node-fetch');

const url = 'https://ingest.api.nacelle.com/v1/inventory-location';
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: 'aSourceLocationId1a',
        name: 'iventoryItem1a',
        address1: '123 address line1 st.',
        address2: 'apt address line 2',
        city: 'aCity',
        region: 'Arizona',
        regionCode: 'AZ',
        country: 'USA',
        countryCode: 'US',
        postalCode: 'aPostalCode',
        phone: '555-555-5555',
        coordinates: {
          latitude: 90,
          longitude: -120
        },
        createdAt: '2011-10-05T14:48:00.000Z',
        updatedAt: '2011-10-05T14:48:00.000Z',
      }
    ]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));
  1. Create Inventory Level

Use the generated ingest token to make a PUT request to the Ingest Inventory Level endpoint. This will create an Inventory Level linking the previously created Inventory Item and Inventory Location. Here is an example:

const fetch = require('node-fetch');

const url = 'https://ingest.api.nacelle.com/v1/inventory-level';
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: 'sSourceEntryId',
        sourceInventoryItemId: 'aSourceItemId1a',
        sourceInventoryLocationId: 'aSourceLocationId1a',
        quantityAvailable: 123,
        availableForPickup: true,
        createdAt: '2011-10-05T14:48:00.000Z',
        updatedAt: '2011-10-05T14:48:00.000Z',
      }
    ]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));
  1. Query Inventory on a Product Variant:
    You can retrieve order details anytime by using our Storefront API endpoint.
query allProducts {
  allProducts {
    edges {
      node {
        sourceEntryId
        variants {
          sourceEntryId
          inventory (filter: {"regionCode": "AZ"}) {
            key
            sku
            levels {
              availableForPickup
              quantityAvailable
              location {
                name
                address1
                address2
                city
                region
                regionCode
                country
                countryCode
                postalCode
                phone
                coordinates {
                  latitude
                  longitude
                }
              }
            }
          }
        }
      }
    }
  }
}