Introducing our brand new Rules Engine —
Read the docs
LogoLogo
Core APIOther APIsChangelog
Getting started
Getting started
  • Welcome to Commerce Layer
    • Guided setup
    • Manual configuration
  • API specification
  • API credentials
  • Authentication
    • Client credentials
    • Password
    • Authorization code
    • Refresh token
    • JWT bearer
    • Revoking a token
  • Roles and permissions
  • Fetching resources
  • Fetching relationships
  • Including associations
  • Sparse fieldsets
  • Sorting results
  • Pagination
  • Filtering data
  • Creating resources
  • Updating resources
  • Tagging resources
  • Deleting resources
  • Importing resources
  • Exporting resources
  • Cleaning up resources
  • External resources
    • External order validation
    • External prices
    • External shipping costs
    • External payment gateways
    • External promotions
    • External tax calculators
  • Rate limits
  • Handling errors
  • Real-time webhooks
  • Callbacks security
On this page
  • Manual seeding reference guide
  • Create an organization
  • Create integration API credentials
  • Install the Commerce Layer CLI
  • Log in using the API credentials
  • Install the resources plugin
  • Configure your organization
  • Markets
  • Shipping
  • Payments
  • Products
  • Import additional resources
  • Create an order
  • Create sales channel API credentials
  • Generate a checkout URL
  • Further resources
  1. Welcome to Commerce Layer

Manual configuration

A step-by-step guide on how to set up an organization from scratch, using our CLI

PreviousGuided setupNextAPI specification

Last updated 21 days ago

If you want to get deeper and understand the Commerce Layer data model in detail, you may want to try to configure your organization manually, directly interacting with our APIs by leveraging the . The manual configuration involves creating all the necessary resources, linking them based on their mutual relationships, and properly populating your environment with sample (or real) data. will walk you through the process of setting up a new organization using the command line from start to finish and is a good opportunity to learn (by doing) how Commerce Layer works, in deep.

Please refer to Commerce Layer documentation to get an overview of the most relevant API entities, their mutual relationships, and common usage with the help of E-R diagrams.

As an alternative, if you want to go straight to the chase, you can available on the Dashboard UI when you create a new organization.

Manual seeding reference guide

Create an organization

Create integration API credentials

Install the Commerce Layer CLI

Run the command below on your terminal to install the CLI using your favorite package manager:

npm install -g @commercelayer/cli
yarn global add @commercelayer/cli

Installing the CLI provides access to the commercelayer command, which can also be accessed with the aliases clayer and cl.

You can run commercelayer help at any point to learn about the available command options.

Log in using the API credentials

cl applications:login -o <organizationSlug> -i <clientId> -s <clientSecret> -a <applicationAlias>

Here’s a breakdown of each of the command options:

  • The applications:login command lets you manage the login with the CLI using your API credentials.

  • The -o flag allows you to pass in an organization slug as a parameter.

  • <organizationSlug> represents the slug from your organization’s base endpoint (e.g. sample-shop from https://sample-shop.commercelayer.io).

  • The -i flag allows you to pass in a client ID as a parameter.

  • <clientId> represents your client ID (you can find it on the API credentials details page on the dashboard).

  • The -s flag allows you to pass in a client secret as a parameter.

  • <clientSecret> represents your client secret (you can find it on the API credentials details page on the dashboard).

  • The -a flag allows you to pass in an alias that will be associated with the credentials you want to log with on your terminal (this is useful when switching between different API credentials).

Install the resources plugin

cl plugins:install resources

For this guide, we would be using:

  • The commercelayer resources:create [RESOURCE] command to create new resources.

  • The -r, --relationship=<value> flag which defines a relationship with another resource(s).

  • The -a, --attribute=<value> flag which defines the attributes of a resource that will be used.

Please note that a live documentation option is also available on the command line: just append --doc to any CLI command of the resources plugin to show the command in a specific language of your choice (cURL and Node currently available, more to come).

Example

The following command fetches a collection of SKUs using the CLI, prompting you the options to select a format to show the command live documentation:

commercelayer list skus --doc

This is the corresponding cURL command to fetch a collection of SKUs:

curl -g -X GET \
  'https://your-organization.commercelayer.io/api/skus' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Content-Type: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token'

This is the corresponding Node command to fetch a collection of SKUs:

import commercelayer from '@commercelayer/sdk'

const organization = 'your-organization'
const accessToken = 'your-access-token'

const cl = commercelayer({ organization, accessToken })

cl.skus.list().then(console.log)

Configure your organization

  • The command for creating the resource.

  • The output response of the successfully run command.

When you successfully create a new resource, you can confirm this by running cl resources:list <resource_type> and checking if the resource is in the returned list (e.g. cl resources:list payment_gateways will list all the payment gateways that have been created).

Markets

Address

The following command creates a new address:

cl resources:create address -a \
  business="true" \
  company="Sample Shop SRL" \
  line_1="Via Roma 123" \
  city="Firenze" \
  zip_code="50123" \
  state_code="FI" \
  country_code="IT" \
  phone="+39 055 1234567890" \
  email="sample-shop@example.com"

On successful run, the newly created address object information is prompted:

{
  id: 'dqJkunqnQa',
  type: 'addresses',
  business: true,
  first_name: null,
  last_name: null,
  company: 'Sample Shop SRL',
  full_name: 'Sample Shop SRL',
  line_1: 'Via Roma 123',
  line_2: null,
  city: 'Firenze',
  zip_code: '50123',
  state_code: 'FI',
  country_code: 'IT',
  phone: '+39 055 1234567890',
  full_address: 'Via Roma 123, 50123 Firenze FI (IT) +39 055 1234567890',
  name: 'Sample Shop SRL, Via Roma 123, 50123 Firenze FI (IT) +39 055 1234567890',
  email: 'sample-shop@example.com',
  notes: null,
  lat: null,
  lng: null,
  is_localized: false,
  is_geocoded: false,
  provider_name: null,
  map_url: null,
  static_map_url: null,
  billing_info: null,
  created_at: '2022-03-17T14:27:26.526Z',
  updated_at: '2022-03-17T14:27:26.526Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Merchant

The following command creates a new merchant and associates it with a billing address:

cl resources:create merchants -a \
  name="Sample Shop Manager" -r \
  address="dqJkunqnQa"

On successful run, the newly created merchant object information is prompted:

{
  id: 'qnzZLHrgmn',
  type: 'merchants',
  name: 'Sample Shop Manager',
  created_at: '2022-03-17T14:28:27.008Z',
  updated_at: '2022-03-17T14:28:27.008Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  address: {
    id: 'dqJkunqnQa',
    type: 'addresses',
    business: true,
    first_name: null,
    last_name: null,
    company: 'Sample Shop SRL',
    full_name: 'Sample Shop SRL',
    line_1: 'Via Roma 123',
    line_2: null,
    city: 'Firenze',
    zip_code: '50123',
    state_code: 'FI',
    country_code: 'IT',
    phone: '+39 055 1234567890',
    full_address: 'Via Roma 123, 50123 Firenze FI (IT) +39 055 1234567890',
    name: 'Sample Shop SRL, Via Roma 123, 50123 Firenze FI (IT) +39 055 1234567890',
    email: 'sample-shop@example.com',
    notes: null,
    lat: null,
    lng: null,
    is_localized: false,
    is_geocoded: false,
    provider_name: null,
    map_url: null,
    static_map_url: null,
    billing_info: null,
    created_at: '2022-03-17T14:27:26.526Z',
    updated_at: '2022-03-17T14:27:26.526Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Stock location

The following command creates a new stock location and associates it with an address:

cl resources:create stock_locations -a \
  name="Europe Warehouse" -r \
  address="dqJkunqnQa"

On successful run, the newly created stock location object information is prompted:

{
  id: 'okdYzuXRDM',
  type: 'stock_locations',
  number: 8207,
  name: 'Europe Warehouse',
  label_format: 'PDF',
  suppress_etd: null,
  created_at: '2022-03-17T14:29:43.763Z',
  updated_at: '2022-03-17T14:29:43.763Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  address: {
    id: 'dqJkunqnQa',
    type: 'addresses',
    business: true,
    first_name: null,
    last_name: null,
    company: 'Sample Shop SRL',
    full_name: 'Sample Shop SRL',
    line_1: 'Via Roma 123',
    line_2: null,
    city: 'Firenze',
    zip_code: '50123',
    state_code: 'FI',
    country_code: 'IT',
    phone: '+39 055 1234567890',
    full_address: 'Via Roma 123, 50123 Firenze FI (IT) +39 055 1234567890',
    name: 'Sample Shop SRL, Via Roma 123, 50123 Firenze FI (IT) +39 055 1234567890',
    email: 'sample-shop@example.com',
    notes: null,
    lat: null,
    lng: null,
    is_localized: false,
    is_geocoded: false,
    provider_name: null,
    map_url: null,
    static_map_url: null,
    billing_info: null,
    created_at: '2022-03-17T14:27:26.526Z',
    updated_at: '2022-03-17T14:27:26.526Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Inventory model

The following command creates a new inventory model:

cl resources:create inventory_models -a name="EUR Inventory"

On successful run, the newly created inventory model object information is prompted:

{
  id: 'kZXEvSYlra',
  type: 'inventory_models',
  name: 'EUR Inventory',
  strategy: 'split_shipments',
  stock_locations_cutoff: 2,
  created_at: '2022-03-17T14:32:17.869Z',
  updated_at: '2022-03-17T14:32:17.869Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Inventory stock location

The following command creates a new inventory stock location and associates it with a stock location and an inventory model:

cl resources:create inventory_stock_locations -r \
  inventory_model="kZXEvSYlra" \
  stock_location="okdYzuXRDM" -a \
  priority="4"

On successful run, the newly created inventory stock location object information is prompted:

{
  id: 'aWDOVSOBzj',
  type: 'inventory_stock_locations',
  priority: 4,
  on_hold: false,
  created_at: '2022-03-17T14:33:20.771Z',
  updated_at: '2022-03-17T14:33:20.771Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  stock_location: {
    id: 'okdYzuXRDM',
    type: 'stock_locations',
    number: 8207,
    name: 'Europe Warehouse',
    label_format: 'PDF',
    suppress_etd: null,
    created_at: '2022-03-17T14:29:43.763Z',
    updated_at: '2022-03-17T14:29:43.763Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  inventory_model: {
    id: 'kZXEvSYlra',
    type: 'inventory_models',
    name: 'EUR Inventory',
    strategy: 'split_shipments',
    stock_locations_cutoff: 2,
    created_at: '2022-03-17T14:32:17.869Z',
    updated_at: '2022-03-17T14:32:17.869Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Price list

The following command creates a new price list associated with the European currency, with tax included (default):

cl resources:create price_lists -a \
  name="Euros Price List" \
  currency_code="EUR"

On successful run, the newly created price list object information is prompted. You can see that the taxes have been included by default:

{
  id: 'dlwQyCXnqB',
  type: 'price_lists',
  name: 'Euros Price List',
  currency_code: 'EUR',
  tax_included: true,
  created_at: '2022-03-17T14:37:44.720Z',
  updated_at: '2022-03-17T14:37:44.720Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Market

The following command creates a new market and associate it list associates it with a merchant, an inventory model, and a price list:

cl resources:create markets -r \
  merchant="qnzZLHrgmn" \
  inventory_model="kZXEvSYlra" \
  price_list="dlwQyCXnqB" -a \
  name="Europe"

On successful run, the newly created market object information is prompted:

{
  id: 'BjydJhAPko',
  type: 'markets',
  number: 9656,
  name: 'Europe',
  facebook_pixel_id: null,
  checkout_url: null,
  external_prices_url: null,
  private: false,
  created_at: '2022-03-17T14:39:47.525Z',
  updated_at: '2022-03-17T14:39:47.525Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  merchant: {
    id: 'qnzZLHrgmn',
    type: 'merchants',
    name: 'Sample Shop Manager',
    created_at: '2022-03-17T14:28:27.008Z',
    updated_at: '2022-03-17T14:28:27.008Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  price_list: {
    id: 'dlwQyCXnqB',
    type: 'price_lists',
    name: 'Euros Price List',
    currency_code: 'EUR',
    tax_included: true,
    created_at: '2022-03-17T14:37:44.720Z',
    updated_at: '2022-03-17T14:37:44.720Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  inventory_model: {
    id: 'kZXEvSYlra',
    type: 'inventory_models',
    name: 'EUR Inventory',
    strategy: 'split_shipments',
    stock_locations_cutoff: 2,
    created_at: '2022-03-17T14:32:17.869Z',
    updated_at: '2022-03-17T14:32:17.869Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Shipping

Shipping category

The following command creates a new shipping category:

cl resources:create shipping_categories -a name="Demo Shipping Category"

On successful run, the newly created shipping category object information is prompted:

{
  id: 'MWjgYFbYVK',
  type: 'shipping_categories',
  name: 'Demo Shipping Category',
  created_at: '2022-03-17T14:41:06.380Z',
  updated_at: '2022-03-17T14:41:06.380Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Shipping zone

The following command creates a new shipping zone to match Italy (IT), Spain (ES), Germany (DE), France (FR), and the United Kingdom (UK):

cl resources:create shipping_zones -a \
  name="European Countries" \
  country_code_regex="IT|ES|DE|FR|UK"

On successful run, the newly created shipping zone object information is prompted:

{
  id: 'kKwxmtNVYv',
  type: 'shipping_zones',
  name: 'European Countries',
  country_code_regex: 'IT|ES|DE|FR|UK',
  not_country_code_regex: null,
  state_code_regex: null,
  not_state_code_regex: null,
  zip_code_regex: null,
  not_zip_code_regex: null,
  created_at: '2022-03-17T14:41:39.794Z',
  updated_at: '2022-03-17T14:41:39.794Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Shipping method

The following command creates a new shipping method and associates it with a market, a shipping zone, and a shipping category.

cl resources:create shipping_methods -r \
  market="BjydJhAPko" \
  shipping_zone="kKwxmtNVYv" \
  shipping_category="MWjgYFbYVK" -a \
  name="Express Delivery" \
  price_amount_cents="960" \
  free_over_amount_cents="8900"

On successful run, the newly created shipping method object information is prompted. You can see that the currency code (EUR) has been inherited by the market's price list:

{
  id: 'bVlBrFyGKO',
  type: 'shipping_methods',
  name: 'Express Delivery',
  currency_code: 'EUR',
  disabled_at: null,
  price_amount_cents: 960,
  price_amount_float: 9.6,
  formatted_price_amount: '€9,60',
  free_over_amount_cents: 8900,
  free_over_amount_float: 89,
  formatted_free_over_amount: '€89,00',
  price_amount_for_shipment_cents: 960,
  price_amount_for_shipment_float: 9.6,
  formatted_price_amount_for_shipment: '€9,60',
  created_at: '2022-03-17T14:44:22.650Z',
  updated_at: '2022-03-17T14:44:22.650Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  market: {
    id: 'BjydJhAPko',
    type: 'markets',
    number: 9656,
    name: 'Europe',
    facebook_pixel_id: null,
    checkout_url: null,
    external_prices_url: null,
    private: false,
    created_at: '2022-03-17T14:39:47.525Z',
    updated_at: '2022-03-17T14:39:47.525Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  shipping_zone: {
    id: 'kKwxmtNVYv',
    type: 'shipping_zones',
    name: 'European Countries',
    country_code_regex: 'IT|ES|DE|FR|UK',
    not_country_code_regex: null,
    state_code_regex: null,
    not_state_code_regex: null,
    zip_code_regex: null,
    not_zip_code_regex: null,
    created_at: '2022-03-17T14:41:39.794Z',
    updated_at: '2022-03-17T14:41:39.794Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  shipping_category: {
    id: 'MWjgYFbYVK',
    type: 'shipping_categories',
    name: 'Demo Shipping Category',
    created_at: '2022-03-17T14:41:06.380Z',
    updated_at: '2022-03-17T14:41:06.380Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Payments

Payment gateway

The following command creates a new manual payment gateway:

cl resources:create manual_gateways -a name="Manual Gateway"

On successful run, the newly created manual payment gateway object information is prompted:

{
  id: 'ExJwlspqmv',
  type: 'manual_gateways',
  name: 'Manual Gateway',
  created_at: '2022-03-17T14:45:27.063Z',
  updated_at: '2022-03-17T14:45:27.063Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  require_capture: null
}

You can use the command cl resources:list payment_gateways to list all the payment gateway(s) created or cl resources:list <gateway_type>_gateways to list only the specified ’s payment gateways created.

Payment method

The following command creates a new payment method and associates it with a manual payment gateway and a wire transfer payment source:

cl resources:create payment_methods -r \
  market="BjydJhAPko" \
  payment_gateway="ExJwlspqmv" -a \
  payment_source_type="WireTransfer"

On successful run, the newly created payment method object information is prompted:

{
  id: 'lMAeGsQQWM',
  type: 'payment_methods',
  payment_source_type: 'wire_transfers',
  name: 'Wire Transfer',
  currency_code: 'EUR',
  moto: false,
  disabled_at: null,
  price_amount_cents: 0,
  price_amount_float: 0,
  formatted_price_amount: '€0,00',
  created_at: '2022-03-17T14:50:17.021Z',
  updated_at: '2022-03-17T14:50:17.021Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  market: {
    id: 'BjydJhAPko',
    type: 'markets',
    number: 9656,
    name: 'Europe',
    facebook_pixel_id: null,
    checkout_url: null,
    external_prices_url: null,
    private: false,
    created_at: '2022-03-17T14:39:47.525Z',
    updated_at: '2022-03-17T14:39:47.525Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  payment_gateway: {
    id: 'ExJwlspqmv',
    type: 'payment_gateways',
    name: 'Manual Gateway',
    created_at: '2022-03-17T14:45:27.063Z',
    updated_at: '2022-03-17T14:45:27.063Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Products

SKUs

The following command created a new SKU and associates it with a shipping category:

cl resources:create skus -r \
  shipping_category="MWjgYFbYVK" -a \
  code="SKUCODE0001XLXX" \
  name="Grey Aeron Ergonomic Office Chair" \
  description="Aeron office chair is a revolutionized office seating with its defining design qualities and its patented PostureFit SL back support..." \
  image_url="https://images.hermanmiller.group/m/7b7b8463a1433d26/W-REK_18179_20160811174200565.png" \
  reference="SKUCODE0001" \
  do_not_ship="false" \
  do_not_track="false" \
  weight="500" \
  unit_of_weight="gr"

On successful run, the newly created SKU object information is prompted:

{
  id: 'BorzSOKrYq',
  type: 'skus',
  code: 'SKUCODE0001XLXX',
  name: 'Grey Aeron Ergonomic Office Chair',
  description: 'Aeron office chair is a revolutionized office seating with its defining design qualities and its patented PostureFit SL back support...',
  image_url: 'https://images.hermanmiller.group/m/7b7b8463a1433d26/W-REK_18179_20160811174200565.png',
  pieces_per_pack: null,
  weight: 500,
  unit_of_weight: 'gr',
  hs_tariff_number: null,
  do_not_ship: false,
  do_not_track: false,
  created_at: '2022-03-17T14:54:33.123Z',
  updated_at: '2022-03-17T14:54:33.123Z',
  reference: 'SKUCODE0001',
  reference_origin: null,
  metadata: {},
  shipping_category: {
    id: 'MWjgYFbYVK',
    type: 'shipping_categories',
    name: 'Demo Shipping Category',
    created_at: '2022-03-17T14:41:06.380Z',
    updated_at: '2022-03-17T14:41:06.380Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Stock items

The following command creates a new stock item for a given SKU and associates it with a stock location:

cl resources:create stock_items -a \
  sku_code="SKUCODE0001XLXX" \
  quantity="100" -r \
  stock_location="okdYzuXRDM"

On successful run, the newly created stock item object information is prompted:

{
  id: 'YqAwfbkwlk',
  type: 'stock_items',
  sku_code: 'SKUCODE0001XLXX',
  quantity: 100,
  created_at: '2022-03-17T14:56:11.749Z',
  updated_at: '2022-03-17T14:56:11.749Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  stock_location: {
    id: 'okdYzuXRDM',
    type: 'stock_locations',
    number: 8207,
    name: 'Europe Warehouse',
    label_format: 'PDF',
    suppress_etd: null,
    created_at: '2022-03-17T14:29:43.763Z',
    updated_at: '2022-03-17T14:29:43.763Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Prices

The following command creates a price for a given SKU and associates it with a price list:

cl resources:create prices -a \
  sku_code="SKUCODE0001LXXX" \
  amount_cents="4990" \
  compare_at_amount_cents="4500" -r \
  sku="BorzSOKrYq" \
  price_list="dlwQyCXnqB"

On successful run, the newly created price object information is prompted:

{
  id: 'anOlUkBkyE',
  type: 'prices',
  currency_code: 'EUR',
  sku_code: 'SKUCODE0001XLXX',
  amount_cents: 4990,
  amount_float: 49.9,
  formatted_amount: '€49,90',
  compare_at_amount_cents: 4990,
  compare_at_amount_float: 49.9,
  formatted_compare_at_amount: '€49,90',
  created_at: '2022-03-17T14:57:14.467Z',
  updated_at: '2022-03-17T14:57:14.467Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  price_list: {
    id: 'dlwQyCXnqB',
    type: 'price_lists',
    name: 'Euros Price List',
    currency_code: 'EUR',
    tax_included: true,
    created_at: '2022-03-17T14:37:44.720Z',
    updated_at: '2022-03-17T14:37:44.720Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  sku: {
    id: 'BorzSOKrYq',
    type: 'skus',
    code: 'SKUCODE0001XLXX',
    name: 'Grey Aeron Ergonomic Office Chair',
    description: 'Aeron office chair is a revolutionized office seating with its defining design qualities and its patented PostureFit SL back support...',
    image_url: 'https://images.hermanmiller.group/m/7b7b8463a1433d26/W-REK_18179_20160811174200565.png',
    pieces_per_pack: null,
    weight: 500,
    unit_of_weight: 'gr',
    hs_tariff_number: null,
    do_not_ship: false,
    do_not_track: false,
    created_at: '2022-03-17T14:54:33.123Z',
    updated_at: '2022-03-17T14:54:33.123Z',
    reference: 'SKUCODE0001',
    reference_origin: null,
    metadata: {}
  }
}

Import additional resources

cl plugins:install imports

Then create a JSON file named skus.json with an array containing the list of additional SKUs you want to import:

[
  {
    "code": "BEACHBAGFFFFFF000000XXXX",
    "name": "White Beach Bag with Black Logo",
    "description": "Meet your companion for a sunny summer day — our beach bag! It's large, comfy, and you can match it with our towel to create the perfect beach combo.",
    "image_url": "https://data.commercelayer.app/seed/images/skus/BEACHBAGFFFFFF000000XXXX_FLAT.png",
    "reference": "BEACHBAGFFFFFF000000",
    "shipping_category_id": "MWjgYFbYVK"
  },
  {
    "code": "BEANIEXX000000FFFFFFXXXX",
    "name": "Black Beanie with White Logo",
    "description": "Soft double-layered customizable beanie. 95% polyester, 5% spandex. Regular fit. Accurately printed, cut, and hand-sewn.",
    "image_url": "https://data.commercelayer.app/seed/images/skus/BEANIEXX000000FFFFFFXXXX_FLAT.png",
    "reference": "BEANIEXX000000FFFFFF",
    "shipping_category_id": "MWjgYFbYVK"
  }
]

Also, create a JSON file named stock_items.json with an array containing the list of the related stock items:

[
  {
    "sku_code": "BEACHBAGFFFFFF000000XXXX",
    "quantity": 200
  },
  {
    "sku_code": "BEANIEXX000000FFFFFFXXXX",
    "quantity": 95
  }
]

Lastly, create a JSON file named prices.json with an array containing the list of the related prices:

[
  {
    "sku_code": "BEACHBAGFFFFFF000000XXXX",
    "amount_cents": 3990,
    "compare_at_amount_cents": 5000
  },
  {
    "sku_code": "BEANIEXX000000FFFFFFXXXX",
    "amount_cents": 3490,
    "compare_at_amount_cents": 4700
  }
]

Now you can import the two SKUs with their prices and stock items as seen in the snippets below:

The following command imports the SKUs specified in a file:

cl imports:create -t skus -i <input-file-path>

On successful run, a brief report of the import process is prompted:

|     ID     |Items|   %  |    Status   | TBP↓ | Prc. | Wrn. | Err. |
---------------------------------------------------------------------
| mLGpILVVvg | 1-2 | 100% | completed   |    0 |    2 |    0 |

Import of 2 skus completed.

The following command imports the stock items specified in a file and associates them with a stock location:

cl imports:create -t stock_items -p <stock_location-id> -i <input-file-path>

On successful run, a brief report of the import process is prompted:

|     ID     |Items|   %  |    Status   | TBP↓ | Prc. | Wrn. | Err. |
---------------------------------------------------------------------
| qKnWIaQQlP | 1-2 | 100% | completed   |    0 |    2 |    0 |

Import of 2 stock items completed.

The following command imports the prices specified in a file and associates them with a price list:

cl imports:create -t prices -p <price-list-id> -i <input-file-path>

On successful run, a brief report of the import process is prompted:

|     ID     |Items|   %  |    Status   | TBP↓ | Prc. | Wrn. | Err. |
---------------------------------------------------------------------
| AJNpIpDDGy | 1-2 | 100% | completed   |    0 |    2 |    0 |

Import of 2 prices completed.

If you run into any error, you can run cl imports:details <ID> -l to view the error log for that import process using the process ID.

Create an order

Search for the ID of the SKU you intend to purchase

You can find the ID of the SKU you want to purchase in the dashboard. Alternatively, you can use the CLI:

The following command will search for all SKUs and filter out the results:

cl resources:get skus -w name_i_cont_all=t-shirt,black -w name_not_i_cont_all=women,white

On successful run, an array of SKUs that match the search query is prompted:

[
  {
    id: 'WKjRSOlEOP',
    type: 'skus',
    code: 'TSHIRTMSB0B0B2000000LXXX',
    name: 'Men's Gray T-Shirt with Black Logo (L)',
    description: "This is THE classic t-shirt. Its fine jersey cotton construction makes it extremely soft and comfortable to wear, so it's a good choice for a day-to-day outfit — it's durable and can withstand several washings while retaining its shape and color.",
    image_url: 'https://data.commercelayer.app/seed/images/skus/TSHIRTMSB0B0B2000000LXXX_FLAT.png',
    pieces_per_pack: null,
    weight: null,
    unit_of_weight: null,
    hs_tariff_number: null,
    do_not_ship: false,
    do_not_track: false,
    created_at: '2022-02-22T04:13:02.232Z',
    updated_at: '2022-02-22T04:13:02.232Z',
    reference: 'sku_219',
    reference_origin: 'CLI',
    metadata: {}
  },
  {
    id: 'WJoqSjvNjw',
    type: 'skus',
    code: 'TSHIRTMSB0B0B2000000MXXX',
    name: 'Men's Gray T-Shirt with Black Logo (M)',
    description: "This is THE classic t-shirt. Its fine jersey cotton construction makes it extremely soft and comfortable to wear, so it's a good choice for a day-to-day outfit — it's durable and can withstand several washings while retaining its shape and color.",
    image_url: 'https://data.commercelayer.app/seed/images/skus/TSHIRTMSB0B0B2000000MXXX_FLAT.png',
    pieces_per_pack: null,
    weight: null,
    unit_of_weight: null,
    hs_tariff_number: null,
    do_not_ship: false,
    do_not_track: false,
    created_at: '2022-02-22T04:13:05.219Z',
    updated_at: '2022-02-22T04:13:05.219Z',
    reference: 'sku_220',
    reference_origin: 'CLI',
    metadata: {}
  },
  {
    id: 'WaDeSyLbyg',
    type: 'skus',
    code: 'TSHIRTMSB0B0B2000000SXXX',
    name: 'Men's Gray T-Shirt with Black Logo (S)',
    description: "This is THE classic t-shirt. Its fine jersey cotton construction makes it extremely soft and comfortable to wear, so it's a good choice for a day-to-day outfit — it's durable and can withstand several washings while retaining its shape and color.",
    image_url: 'https://data.commercelayer.app/seed/images/skus/TSHIRTMSB0B0B2000000SXXX_FLAT.png',
    pieces_per_pack: null,
    weight: null,
    unit_of_weight: null,
    hs_tariff_number: null,
    do_not_ship: false,
    do_not_track: false,
    created_at: '2022-02-22T04:13:08.246Z',
    updated_at: '2022-02-22T04:13:08.246Z',
    reference: 'sku_221',
    reference_origin: 'CLI',
    metadata: {}
  },
  {
  ...
  }
]

Search for the ID of the market you intend to purchase from

The following command will search for all existing markets:

cl resources:get markets

On successful run, an array of existing markets is prompted:

[
  {
    id: 'QlNQVhWxbg',
    type: 'markets',
    number: 9479,
    name: 'Europe',
    facebook_pixel_id: null,
    checkout_url: '',
    external_prices_url: '',
    private: false,
    created_at: '2022-02-22T04:01:30.274Z',
    updated_at: '2022-05-31T08:58:18.202Z',
    reference: 'market_1',
    reference_origin: 'CLI',
    metadata: {}
  },
  {
    id: 'YlqxGhKrQg',
    type: 'markets',
    number: 9480,
    name: 'USA',
    facebook_pixel_id: null,
    checkout_url: '',
    external_prices_url: '',
    private: false,
    created_at: '2022-02-22T04:01:34.336Z',
    updated_at: '2022-05-31T08:57:24.446Z',
    reference: 'market_2',
    reference_origin: 'CLI',
    metadata: {}
  },
  {
    id: 'bgOEQhEyQo',
    type: 'markets',
    number: 9481,
    name: 'UK',
    facebook_pixel_id: null,
    checkout_url: '',
    external_prices_url: '',
    private: false,
    created_at: '2022-02-22T04:01:38.524Z',
    updated_at: '2022-05-31T08:58:10.390Z',
    reference: 'market_3',
    reference_origin: 'CLI',
    metadata: {}
  }
]

Create a new order

Now you can create a new order for the market you selected:

The following command creates a new order and associates it with a market:

cl resources:create orders -r market=markets/QlNQVhWxbg

On successful run, the newly created order object information is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'draft',
  payment_status: 'unpaid',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: true,
  customer_email: null,
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: null,
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 0,
  subtotal_amount_float: 0,
  formatted_subtotal_amount: '€0,00',
  shipping_amount_cents: 0,
  shipping_amount_float: 0,
  formatted_shipping_amount: '€0,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 0,
  total_amount_float: 0,
  formatted_total_amount: '€0,00',
  total_taxable_amount_cents: 0,
  total_taxable_amount_float: 0,
  formatted_total_taxable_amount: '€0,00',
  subtotal_taxable_amount_cents: 0,
  subtotal_taxable_amount_float: 0,
  formatted_subtotal_taxable_amount: '€0,00',
  shipping_taxable_amount_cents: 0,
  shipping_taxable_amount_float: 0,
  formatted_shipping_taxable_amount: '€0,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 0,
  total_amount_with_taxes_float: 0,
  formatted_total_amount_with_taxes: '€0,00',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 0,
  line_item_options_count: 0,
  shipments_count: 0,
  tax_calculations_count: 0,
  payment_source_details: null,
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: null,
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: null,
  fulfillment_updated_at: null,
  refreshed_at: null,
  archived_at: null,
  expires_at: '2022-12-03T19:11:30.589Z',
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-03T19:11:30.582Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  market: {
    id: 'QlNQVhWxbg',
    type: 'markets',
    number: 9479,
    name: 'Europe',
    facebook_pixel_id: null,
    checkout_url: '',
    external_prices_url: '',
    private: false,
    created_at: '2022-02-22T04:01:30.274Z',
    updated_at: '2022-05-31T08:58:18.202Z',
    reference: 'market_1',
    reference_origin: 'CLI',
    metadata: {}
  }
}je

Create a line item

Now you can add the SKU to the newly created order by associating the related line item. Use the quantity attribute to add multiple units of the same product:

The following command creates a line item and associates it with an order and an SKU:

cl resources:create line_items -a quantity=5 -r order=orders/wjobhWrZka -r item=skus/WKjRSOlEOP

On successful run, the newly created line item object information is prompted:

{
  id: 'yKlZtAGoLP',
  type: 'line_items',
  sku_code: 'TSHIRTMSB0B0B2000000LXXX',
  bundle_code: null,
  quantity: 5,
  currency_code: 'EUR',
  unit_amount_cents: 3470,
  unit_amount_float: 34.7,
  formatted_unit_amount: '€34,70',
  options_amount_cents: 0,
  options_amount_float: 0,
  formatted_options_amount: '€0,00',
  discount_cents: 0,
  discount_float: 0,
  formatted_discount: '€0,00',
  total_amount_cents: 17350,
  total_amount_float: 173.5,
  formatted_total_amount: '€173,50',
  tax_amount_cents: 0,
  tax_amount_float: 0,
  formatted_tax_amount: '€0,00',
  name: 'Men's Gray T-Shirt with Black Logo (L)',
  image_url: 'https://data.commercelayer.app/seed/images/skus/TSHIRTMSB0B0B2000000LXXX_FLAT.png',
  discount_breakdown: {},
  tax_rate: 0,
  tax_breakdown: {},
  item_type: 'skus',
  created_at: '2022-10-03T19:17:11.883Z',
  updated_at: '2022-10-03T19:17:11.883Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  order: {
    id: 'wjobhWrZka',
    type: 'orders',
    number: 28117000,
    autorefresh: true,
    status: 'draft',
    payment_status: 'unpaid',
    fulfillment_status: 'unfulfilled',
    guest: true,
    editable: true,
    customer_email: null,
    language_code: 'en',
    currency_code: 'EUR',
    tax_included: true,
    tax_rate: null,
    freight_taxable: null,
    requires_billing_info: false,
    country_code: null,
    shipping_country_code_lock: null,
    coupon_code: null,
    gift_card_code: null,
    gift_card_or_coupon_code: null,
    subtotal_amount_cents: 17350,
    subtotal_amount_float: 173.5,
    formatted_subtotal_amount: '€173,50',
    shipping_amount_cents: 0,
    shipping_amount_float: 0,
    formatted_shipping_amount: '€0,00',
    payment_method_amount_cents: 0,
    payment_method_amount_float: 0,
    formatted_payment_method_amount: '€0,00',
    discount_amount_cents: 0,
    discount_amount_float: 0,
    formatted_discount_amount: '€0,00',
    adjustment_amount_cents: 0,
    adjustment_amount_float: 0,
    formatted_adjustment_amount: '€0,00',
    gift_card_amount_cents: 0,
    gift_card_amount_float: 0,
    formatted_gift_card_amount: '€0,00',
    total_tax_amount_cents: 0,
    total_tax_amount_float: 0,
    formatted_total_tax_amount: '€0,00',
    subtotal_tax_amount_cents: 0,
    subtotal_tax_amount_float: 0,
    formatted_subtotal_tax_amount: '€0,00',
    shipping_tax_amount_cents: 0,
    shipping_tax_amount_float: 0,
    formatted_shipping_tax_amount: '€0,00',
    payment_method_tax_amount_cents: 0,
    payment_method_tax_amount_float: 0,
    formatted_payment_method_tax_amount: '€0,00',
    adjustment_tax_amount_cents: 0,
    adjustment_tax_amount_float: 0,
    formatted_adjustment_tax_amount: '€0,00',
    total_amount_cents: 17350,
    total_amount_float: 173.5,
    formatted_total_amount: '€173,50',
    total_taxable_amount_cents: 17350,
    total_taxable_amount_float: 173.5,
    formatted_total_taxable_amount: '€173,50',
    subtotal_taxable_amount_cents: 17350,
    subtotal_taxable_amount_float: 173.5,
    formatted_subtotal_taxable_amount: '€173,50',
    shipping_taxable_amount_cents: 0,
    shipping_taxable_amount_float: 0,
    formatted_shipping_taxable_amount: '€0,00',
    payment_method_taxable_amount_cents: 0,
    payment_method_taxable_amount_float: 0,
    formatted_payment_method_taxable_amount: '€0,00',
    adjustment_taxable_amount_cents: 0,
    adjustment_taxable_amount_float: 0,
    formatted_adjustment_taxable_amount: '€0,00',
    total_amount_with_taxes_cents: 17350,
    total_amount_with_taxes_float: 173.5,
    formatted_total_amount_with_taxes: '€173,50',
    fees_amount_cents: 0,
    fees_amount_float: 0,
    formatted_fees_amount: '€0,00',
    duty_amount_cents: null,
    duty_amount_float: null,
    formatted_duty_amount: null,
    skus_count: 5,
    line_item_options_count: 0,
    shipments_count: 0,
    tax_calculations_count: 0,
    payment_source_details: null,
    token: '8dae3a32b28749d63d8edc0ab155797c',
    cart_url: null,
    return_url: null,
    terms_url: null,
    privacy_url: null,
    checkout_url: null,
    placed_at: null,
    approved_at: null,
    cancelled_at: null,
    payment_updated_at: null,
    fulfillment_updated_at: null,
    refreshed_at: null,
    archived_at: null,
    expires_at: null,
    created_at: '2022-10-03T19:11:30.582Z',
    updated_at: '2022-10-03T19:17:11.895Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  item: {
    id: 'WKjRSOlEOP',
    type: 'skus',
    code: 'TSHIRTMSB0B0B2000000LXXX',
    name: 'Men's Gray T-Shirt with Black Logo (L)',
    description: "This is THE classic t-shirt. Its fine jersey cotton construction makes it extremely soft and comfortable to wear, so it's a good choice for a day-to-day outfit — it's durable and can withstand several washings while retaining its shape and color.",
    image_url: 'https://data.commercelayer.app/seed/images/skus/TSHIRTMSB0B0B2000000LXXX_FLAT.png',
    pieces_per_pack: null,
    weight: null,
    unit_of_weight: null,
    hs_tariff_number: null,
    do_not_ship: false,
    do_not_track: false,
    created_at: '2022-02-22T04:13:02.232Z',
    updated_at: '2022-02-22T04:13:02.232Z',
    reference: 'sku_219',
    reference_origin: 'CLI',
    metadata: {}
  }
}

Assign the order to a customer

The order must now be updated to be associated with a customer using the customer's email:

The following command associates a customer email with an order:

cl resources:update orders/wjobhWrZka -a customer_email=bolaji@commercelayer.io

On successful run, the updated order object information is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'pending',
  payment_status: 'unpaid',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: true,
  customer_email: 'bolaji@commercelayer.io',
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: null,
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 17350,
  subtotal_amount_float: 173.5,
  formatted_subtotal_amount: '€173,50',
  shipping_amount_cents: 0,
  shipping_amount_float: 0,
  formatted_shipping_amount: '€0,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 17350,
  total_amount_float: 173.5,
  formatted_total_amount: '€173,50',
  total_taxable_amount_cents: 17350,
  total_taxable_amount_float: 173.5,
  formatted_total_taxable_amount: '€173,50',
  subtotal_taxable_amount_cents: 17350,
  subtotal_taxable_amount_float: 173.5,
  formatted_subtotal_taxable_amount: '€173,50',
  shipping_taxable_amount_cents: 0,
  shipping_taxable_amount_float: 0,
  formatted_shipping_taxable_amount: '€0,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 17350,
  total_amount_with_taxes_float: 173.5,
  formatted_total_amount_with_taxes: '€173,50',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 5,
  line_item_options_count: 0,
  shipments_count: 0,
  tax_calculations_count: 0,
  payment_source_details: null,
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: null,
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: null,
  fulfillment_updated_at: null,
  refreshed_at: null,
  archived_at: null,
  expires_at: null,
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-04T02:19:14.615Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Create an address

Now you need to create an address that will be use used to checkout the order:

The following command creates a new address:

cl resources:create addresses -a first_name=Bolaji last_name=Ayodeji line_1="Undefined Street, Commerce Rd" line_2="Lorem Ipsum" city=Florence state_code=FI country_code=IT phone=33812345678 zip_code=50100

On successful run, the created address object information is prompted:

{
  id: 'BvoVuxgyvk',
  type: 'addresses',
  business: false,
  first_name: 'Bolaji',
  last_name: 'Ayodeji',
  company: null,
  full_name: 'Bolaji Ayodeji',
  line_1: 'Undefined Street, Commerce Rd',
  line_2: 'Lorem Ipsum',
  city: 'Florence',
  zip_code: '50100',
  state_code: 'FI',
  country_code: 'IT',
  phone: '33812345678',
  full_address: 'Undefined Street, Commerce Rd Lorem Ipsum, 50100 Florence FI (IT) 33812345678',
  name: 'Bolaji Ayodeji, Undefined Street, Commerce Rd Lorem Ipsum, 50100 Florence FI (IT) 33812345678',
  email: null,
  notes: null,
  lat: null,
  lng: null,
  is_localized: false,
  is_geocoded: false,
  provider_name: null,
  map_url: null,
  static_map_url: null,
  billing_info: null,
  created_at: '2022-10-04T02:38:22.195Z',
  updated_at: '2022-10-04T02:38:22.195Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Update the order with a shipping and billing address

The previously created address will be used both as the billing and the shipping address of the order:

The following command associates a shipping and billing address with an order:

cl resources:update orders/wjobhWrZka -r billing_address=addresses/BvoVuxgyvk shipping_address=addresses/BvoVuxgyvk

On successful run, the updated order object information is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'pending',
  payment_status: 'unpaid',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: true,
  customer_email: 'bolaji@commercelayer.io',
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: 'IT',
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 17350,
  subtotal_amount_float: 173.5,
  formatted_subtotal_amount: '€173,50',
  shipping_amount_cents: 0,
  shipping_amount_float: 0,
  formatted_shipping_amount: '€0,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 17350,
  total_amount_float: 173.5,
  formatted_total_amount: '€173,50',
  total_taxable_amount_cents: 17350,
  total_taxable_amount_float: 173.5,
  formatted_total_taxable_amount: '€173,50',
  subtotal_taxable_amount_cents: 17350,
  subtotal_taxable_amount_float: 173.5,
  formatted_subtotal_taxable_amount: '€173,50',
  shipping_taxable_amount_cents: 0,
  shipping_taxable_amount_float: 0,
  formatted_shipping_taxable_amount: '€0,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 17350,
  total_amount_with_taxes_float: 173.5,
  formatted_total_amount_with_taxes: '€173,50',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 5,
  line_item_options_count: 0,
  shipments_count: 1,
  tax_calculations_count: 0,
  payment_source_details: null,
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: null,
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: null,
  fulfillment_updated_at: null,
  refreshed_at: null,
  archived_at: null,
  expires_at: null,
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-04T02:42:57.246Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  shipping_address: {
    id: 'BvoVuxgyvk',
    type: 'addresses',
    business: false,
    first_name: 'Bolaji',
    last_name: 'Ayodeji',
    company: null,
    full_name: 'Bolaji Ayodeji',
    line_1: 'Undefined Street, Commerce Rd',
    line_2: 'Lorem Ipsum',
    city: 'Florence',
    zip_code: '50100',
    state_code: 'FI',
    country_code: 'IT',
    phone: '33812345678',
    full_address: 'Undefined Street, Commerce Rd Lorem Ipsum, 50100 Florence FI (IT) 33812345678',
    name: 'Bolaji Ayodeji, Undefined Street, Commerce Rd Lorem Ipsum, 50100 Florence FI (IT) 33812345678',
    email: null,
    notes: null,
    lat: null,
    lng: null,
    is_localized: false,
    is_geocoded: false,
    provider_name: null,
    map_url: null,
    static_map_url: null,
    billing_info: null,
    created_at: '2022-10-04T02:38:22.195Z',
    updated_at: '2022-10-04T02:38:22.195Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  },
  billing_address: {
    id: 'BvoVuxgyvk',
    type: 'addresses',
    business: false,
    first_name: 'Bolaji',
    last_name: 'Ayodeji',
    company: null,
    full_name: 'Bolaji Ayodeji',
    line_1: 'Undefined Street, Commerce Rd',
    line_2: 'Lorem Ipsum',
    city: 'Florence',
    zip_code: '50100',
    state_code: 'FI',
    country_code: 'IT',
    phone: '33812345678',
    full_address: 'Undefined Street, Commerce Rd Lorem Ipsum, 50100 Florence FI (IT) 33812345678',
    name: 'Bolaji Ayodeji, Undefined Street, Commerce Rd Lorem Ipsum, 50100 Florence FI (IT) 33812345678',
    email: null,
    notes: null,
    lat: null,
    lng: null,
    is_localized: false,
    is_geocoded: false,
    provider_name: null,
    map_url: null,
    static_map_url: null,
    billing_info: null,
    created_at: '2022-10-04T02:38:22.195Z',
    updated_at: '2022-10-04T02:38:22.195Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Get the order shipments and the available shipping methods

To choose a shipping method for the shipment(s) associated with your order, you need first to check what are the available ones:

The following command fetches the shipments associated with an order and all the available shipping methods:

cl resources:get orders wjobhWrZka -i shipments,shipments.available_shipping_methods

On successful run, the order object information (with shipments and shipping methods) is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'pending',
  payment_status: 'unpaid',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: true,
  customer_email: 'bolaji@commercelayer.io',
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: 'IT',
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 17350,
  subtotal_amount_float: 173.5,
  formatted_subtotal_amount: '€173,50',
  shipping_amount_cents: 0,
  shipping_amount_float: 0,
  formatted_shipping_amount: '€0,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 17350,
  total_amount_float: 173.5,
  formatted_total_amount: '€173,50',
  total_taxable_amount_cents: 17350,
  total_taxable_amount_float: 173.5,
  formatted_total_taxable_amount: '€173,50',
  subtotal_taxable_amount_cents: 17350,
  subtotal_taxable_amount_float: 173.5,
  formatted_subtotal_taxable_amount: '€173,50',
  shipping_taxable_amount_cents: 0,
  shipping_taxable_amount_float: 0,
  formatted_shipping_taxable_amount: '€0,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 17350,
  total_amount_with_taxes_float: 173.5,
  formatted_total_amount_with_taxes: '€173,50',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 5,
  line_item_options_count: 0,
  shipments_count: 1,
  tax_calculations_count: 0,
  payment_source_details: null,
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: null,
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: null,
  fulfillment_updated_at: null,
  refreshed_at: null,
  archived_at: null,
  expires_at: null,
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-04T02:42:57.246Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  shipments: [
    {
      id: 'PabvCqgnAw',
      type: 'shipments',
      number: '28117000/S/001',
      status: 'draft',
      currency_code: 'EUR',
      cost_amount_cents: 0,
      cost_amount_float: 0,
      formatted_cost_amount: '$0.00',
      skus_count: 5,
      selected_rate_id: null,
      rates: [],
      purchase_error_code: null,
      purchase_error_message: null,
      get_rates_errors: [],
      get_rates_started_at: null,
      get_rates_completed_at: null,
      purchase_started_at: null,
      purchase_completed_at: null,
      purchase_failed_at: null,
      created_at: '2022-10-04T02:42:57.233Z',
      updated_at: '2022-10-04T02:42:57.233Z',
      reference: null,
      reference_origin: null,
      metadata: {},
      available_shipping_methods: [
        {
          id: 'wEvWBFqejO',
          type: 'shipping_methods',
          name: 'Standard Shipping',
          scheme: 'flat',
          currency_code: 'EUR',
          disabled_at: null,
          price_amount_cents: 700,
          price_amount_float: 7,
          formatted_price_amount: '€7,00',
          free_over_amount_cents: 9900,
          free_over_amount_float: 99,
          formatted_free_over_amount: '€99,00',
          price_amount_for_shipment_cents: 0,
          price_amount_for_shipment_float: 0,
          formatted_price_amount_for_shipment: '€0,00',
          min_weight: null,
          max_weight: null,
          unit_of_weight: null,
          created_at: '2022-02-22T04:01:53.103Z',
          updated_at: '2022-02-22T04:01:53.103Z',
          reference: 'shipping_method_1',
          reference_origin: 'CLI',
          metadata: {}
        },
        {
          id: 'XOzWbFmJyN',
          type: 'shipping_methods',
          name: 'Express Delivery',
          scheme: 'flat',
          currency_code: 'EUR',
          disabled_at: null,
          price_amount_cents: 1200,
          price_amount_float: 12,
          formatted_price_amount: '€12,00',
          free_over_amount_cents: null,
          free_over_amount_float: null,
          formatted_free_over_amount: null,
          price_amount_for_shipment_cents: 1200,
          price_amount_for_shipment_float: 12,
          formatted_price_amount_for_shipment: '€12,00',
          min_weight: null,
          max_weight: null,
          unit_of_weight: null,
          created_at: '2022-02-22T04:01:57.142Z',
          updated_at: '2022-02-22T04:01:57.142Z',
          reference: 'shipping_method_2',
          reference_origin: 'CLI',
          metadata: {}
        }
      ]
    }
  ]
}

Update the shipment with a shipping method

Now you can associate the desired shipping method with the shipment:

The following command associates a selected shipping method with a shipment:

cl resources:update shipments/PabvCqgnAw -r shipping_method=shipping_methods/XOzWbFmJyN

On successful run, the updated shipments object information is prompted:

{
  id: 'PabvCqgnAw',
  type: 'shipments',
  number: '28117000/S/001',
  status: 'draft',
  currency_code: 'EUR',
  cost_amount_cents: 0,
  cost_amount_float: 0,
  formatted_cost_amount: '$0.00',
  skus_count: 5,
  selected_rate_id: null,
  rates: [],
  purchase_error_code: null,
  purchase_error_message: null,
  get_rates_errors: [],
  get_rates_started_at: null,
  get_rates_completed_at: null,
  purchase_started_at: null,
  purchase_completed_at: null,
  purchase_failed_at: null,
  created_at: '2022-10-04T02:42:57.233Z',
  updated_at: '2022-10-04T03:00:42.015Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  shipping_method: {
    id: 'XOzWbFmJyN',
    type: 'shipping_methods',
    name: 'Express Delivery',
    scheme: 'flat',
    currency_code: 'EUR',
    disabled_at: null,
    price_amount_cents: 1200,
    price_amount_float: 12,
    formatted_price_amount: '€12,00',
    free_over_amount_cents: null,
    free_over_amount_float: null,
    formatted_free_over_amount: null,
    price_amount_for_shipment_cents: 1200,
    price_amount_for_shipment_float: 12,
    formatted_price_amount_for_shipment: '€12,00',
    min_weight: null,
    max_weight: null,
    unit_of_weight: null,
    created_at: '2022-02-22T04:01:57.142Z',
    updated_at: '2022-02-22T04:01:57.142Z',
    reference: 'shipping_method_2',
    reference_origin: 'CLI',
    metadata: {}
  }
}

Get the available payment methods

To choose a payment method for your order, you need first to check what are the available ones:

The following command fetches the payment methods associated with an order:

cl resources:get orders wjobhWrZka -i available_payment_methods

On successful run, the order object information (with the available payment methods) is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'pending',
  payment_status: 'unpaid',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: true,
  customer_email: 'bolaji@commercelayer.io',
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: 'IT',
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 17350,
  subtotal_amount_float: 173.5,
  formatted_subtotal_amount: '€173,50',
  shipping_amount_cents: 1200,
  shipping_amount_float: 12,
  formatted_shipping_amount: '€12,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 18550,
  total_amount_float: 185.5,
  formatted_total_amount: '€185,50',
  total_taxable_amount_cents: 18550,
  total_taxable_amount_float: 185.5,
  formatted_total_taxable_amount: '€185,50',
  subtotal_taxable_amount_cents: 17350,
  subtotal_taxable_amount_float: 173.5,
  formatted_subtotal_taxable_amount: '€173,50',
  shipping_taxable_amount_cents: 1200,
  shipping_taxable_amount_float: 12,
  formatted_shipping_taxable_amount: '€12,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 18550,
  total_amount_with_taxes_float: 185.5,
  formatted_total_amount_with_taxes: '€185,50',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 5,
  line_item_options_count: 0,
  shipments_count: 1,
  tax_calculations_count: 0,
  payment_source_details: null,
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: null,
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: null,
  fulfillment_updated_at: null,
  refreshed_at: null,
  archived_at: null,
  expires_at: null,
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-04T03:00:42.030Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  available_payment_methods: [
    {
      id: 'qMgwNsoxaM',
      type: 'payment_methods',
      payment_source_type: 'wire_transfers',
      name: 'Wire Transfer',
      currency_code: 'EUR',
      moto: false,
      disabled_at: null,
      price_amount_cents: 0,
      price_amount_float: 0,
      formatted_price_amount: '€0,00',
      created_at: '2022-02-22T04:02:13.694Z',
      updated_at: '2022-02-22T04:02:13.694Z',
      reference: 'payment_method_1',
      reference_origin: 'CLI',
      metadata: {}
    }
  ]
}

Update the order with a payment methods

Now you can associate the desired payment method with the order:

The following command associates a selected payment method with an order:

cl resources:update orders/wjobhWrZka -r payment_method=payment_methods/qMgwNsoxaM

On successful run, the updated order object information is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'pending',
  payment_status: 'unpaid',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: true,
  customer_email: 'bolaji@commercelayer.io',
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: 'IT',
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 17350,
  subtotal_amount_float: 173.5,
  formatted_subtotal_amount: '€173,50',
  shipping_amount_cents: 1200,
  shipping_amount_float: 12,
  formatted_shipping_amount: '€12,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 18550,
  total_amount_float: 185.5,
  formatted_total_amount: '€185,50',
  total_taxable_amount_cents: 18550,
  total_taxable_amount_float: 185.5,
  formatted_total_taxable_amount: '€185,50',
  subtotal_taxable_amount_cents: 17350,
  subtotal_taxable_amount_float: 173.5,
  formatted_subtotal_taxable_amount: '€173,50',
  shipping_taxable_amount_cents: 1200,
  shipping_taxable_amount_float: 12,
  formatted_shipping_taxable_amount: '€12,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 18550,
  total_amount_with_taxes_float: 185.5,
  formatted_total_amount_with_taxes: '€185,50',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 5,
  line_item_options_count: 0,
  shipments_count: 1,
  tax_calculations_count: 0,
  payment_source_details: null,
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: null,
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: null,
  fulfillment_updated_at: null,
  refreshed_at: null,
  archived_at: null,
  expires_at: null,
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-04T03:08:27.260Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  payment_method: {
    id: 'qMgwNsoxaM',
    type: 'payment_methods',
    payment_source_type: 'wire_transfers',
    name: 'Wire Transfer',
    currency_code: 'EUR',
    moto: false,
    disabled_at: null,
    price_amount_cents: 0,
    price_amount_float: 0,
    formatted_price_amount: '€0,00',
    created_at: '2022-02-22T04:02:13.694Z',
    updated_at: '2022-02-22T04:02:13.694Z',
    reference: 'payment_method_1',
    reference_origin: 'CLI',
    metadata: {}
  }
}

Update the order with a payment source

The following command creates a wire transfer payment source type and associates it with an order:

cl resources:create wire_transfer -r order=orders/wjobhWrZka

On successful run, the newly created payment source type object information is prompted:

{
  id: 'OAbkTVPePn',
  type: 'wire_transfers',
  created_at: '2022-10-04T03:16:34.288Z',
  updated_at: '2022-10-04T03:16:34.288Z',
  reference: null,
  reference_origin: null,
  metadata: {},
  order: {
    id: 'wjobhWrZka',
    type: 'orders',
    number: 28117000,
    autorefresh: true,
    status: 'pending',
    payment_status: 'unpaid',
    fulfillment_status: 'unfulfilled',
    guest: true,
    editable: true,
    customer_email: 'bolaji@commercelayer.io',
    language_code: 'en',
    currency_code: 'EUR',
    tax_included: true,
    tax_rate: null,
    freight_taxable: null,
    requires_billing_info: false,
    country_code: 'IT',
    shipping_country_code_lock: null,
    coupon_code: null,
    gift_card_code: null,
    gift_card_or_coupon_code: null,
    subtotal_amount_cents: 17350,
    subtotal_amount_float: 173.5,
    formatted_subtotal_amount: '€173,50',
    shipping_amount_cents: 1200,
    shipping_amount_float: 12,
    formatted_shipping_amount: '€12,00',
    payment_method_amount_cents: 0,
    payment_method_amount_float: 0,
    formatted_payment_method_amount: '€0,00',
    discount_amount_cents: 0,
    discount_amount_float: 0,
    formatted_discount_amount: '€0,00',
    adjustment_amount_cents: 0,
    adjustment_amount_float: 0,
    formatted_adjustment_amount: '€0,00',
    gift_card_amount_cents: 0,
    gift_card_amount_float: 0,
    formatted_gift_card_amount: '€0,00',
    total_tax_amount_cents: 0,
    total_tax_amount_float: 0,
    formatted_total_tax_amount: '€0,00',
    subtotal_tax_amount_cents: 0,
    subtotal_tax_amount_float: 0,
    formatted_subtotal_tax_amount: '€0,00',
    shipping_tax_amount_cents: 0,
    shipping_tax_amount_float: 0,
    formatted_shipping_tax_amount: '€0,00',
    payment_method_tax_amount_cents: 0,
    payment_method_tax_amount_float: 0,
    formatted_payment_method_tax_amount: '€0,00',
    adjustment_tax_amount_cents: 0,
    adjustment_tax_amount_float: 0,
    formatted_adjustment_tax_amount: '€0,00',
    total_amount_cents: 18550,
    total_amount_float: 185.5,
    formatted_total_amount: '€185,50',
    total_taxable_amount_cents: 18550,
    total_taxable_amount_float: 185.5,
    formatted_total_taxable_amount: '€185,50',
    subtotal_taxable_amount_cents: 17350,
    subtotal_taxable_amount_float: 173.5,
    formatted_subtotal_taxable_amount: '€173,50',
    shipping_taxable_amount_cents: 1200,
    shipping_taxable_amount_float: 12,
    formatted_shipping_taxable_amount: '€12,00',
    payment_method_taxable_amount_cents: 0,
    payment_method_taxable_amount_float: 0,
    formatted_payment_method_taxable_amount: '€0,00',
    adjustment_taxable_amount_cents: 0,
    adjustment_taxable_amount_float: 0,
    formatted_adjustment_taxable_amount: '€0,00',
    total_amount_with_taxes_cents: 18550,
    total_amount_with_taxes_float: 185.5,
    formatted_total_amount_with_taxes: '€185,50',
    fees_amount_cents: 0,
    fees_amount_float: 0,
    formatted_fees_amount: '€0,00',
    duty_amount_cents: null,
    duty_amount_float: null,
    formatted_duty_amount: null,
    skus_count: 5,
    line_item_options_count: 0,
    shipments_count: 1,
    tax_calculations_count: 0,
    payment_source_details: { type: 'wire_transfer' },
    token: '8dae3a32b28749d63d8edc0ab155797c',
    cart_url: null,
    return_url: null,
    terms_url: null,
    privacy_url: null,
    checkout_url: null,
    placed_at: null,
    approved_at: null,
    cancelled_at: null,
    payment_updated_at: null,
    fulfillment_updated_at: null,
    refreshed_at: null,
    archived_at: null,
    expires_at: null,
    created_at: '2022-10-03T19:11:30.582Z',
    updated_at: '2022-10-04T03:16:34.302Z',
    reference: null,
    reference_origin: null,
    metadata: {}
  }
}

Place the order

Finally, you can place the order by triggering the _place method:

The following command places the order:

cl resources:update orders/wjobhWrZka -a _place=true

On successful run, the updated order object information is prompted:

{
  id: 'wjobhWrZka',
  type: 'orders',
  number: 28117000,
  autorefresh: true,
  status: 'placed',
  payment_status: 'authorized',
  fulfillment_status: 'unfulfilled',
  guest: true,
  editable: false,
  customer_email: 'bolaji@commercelayer.io',
  language_code: 'en',
  currency_code: 'EUR',
  tax_included: true,
  tax_rate: null,
  freight_taxable: null,
  requires_billing_info: false,
  country_code: 'IT',
  shipping_country_code_lock: null,
  coupon_code: null,
  gift_card_code: null,
  gift_card_or_coupon_code: null,
  subtotal_amount_cents: 17350,
  subtotal_amount_float: 173.5,
  formatted_subtotal_amount: '€173,50',
  shipping_amount_cents: 1200,
  shipping_amount_float: 12,
  formatted_shipping_amount: '€12,00',
  payment_method_amount_cents: 0,
  payment_method_amount_float: 0,
  formatted_payment_method_amount: '€0,00',
  discount_amount_cents: 0,
  discount_amount_float: 0,
  formatted_discount_amount: '€0,00',
  adjustment_amount_cents: 0,
  adjustment_amount_float: 0,
  formatted_adjustment_amount: '€0,00',
  gift_card_amount_cents: 0,
  gift_card_amount_float: 0,
  formatted_gift_card_amount: '€0,00',
  total_tax_amount_cents: 0,
  total_tax_amount_float: 0,
  formatted_total_tax_amount: '€0,00',
  subtotal_tax_amount_cents: 0,
  subtotal_tax_amount_float: 0,
  formatted_subtotal_tax_amount: '€0,00',
  shipping_tax_amount_cents: 0,
  shipping_tax_amount_float: 0,
  formatted_shipping_tax_amount: '€0,00',
  payment_method_tax_amount_cents: 0,
  payment_method_tax_amount_float: 0,
  formatted_payment_method_tax_amount: '€0,00',
  adjustment_tax_amount_cents: 0,
  adjustment_tax_amount_float: 0,
  formatted_adjustment_tax_amount: '€0,00',
  total_amount_cents: 18550,
  total_amount_float: 185.5,
  formatted_total_amount: '€185,50',
  total_taxable_amount_cents: 18550,
  total_taxable_amount_float: 185.5,
  formatted_total_taxable_amount: '€185,50',
  subtotal_taxable_amount_cents: 17350,
  subtotal_taxable_amount_float: 173.5,
  formatted_subtotal_taxable_amount: '€173,50',
  shipping_taxable_amount_cents: 1200,
  shipping_taxable_amount_float: 12,
  formatted_shipping_taxable_amount: '€12,00',
  payment_method_taxable_amount_cents: 0,
  payment_method_taxable_amount_float: 0,
  formatted_payment_method_taxable_amount: '€0,00',
  adjustment_taxable_amount_cents: 0,
  adjustment_taxable_amount_float: 0,
  formatted_adjustment_taxable_amount: '€0,00',
  total_amount_with_taxes_cents: 18550,
  total_amount_with_taxes_float: 185.5,
  formatted_total_amount_with_taxes: '€185,50',
  fees_amount_cents: 0,
  fees_amount_float: 0,
  formatted_fees_amount: '€0,00',
  duty_amount_cents: null,
  duty_amount_float: null,
  formatted_duty_amount: null,
  skus_count: 5,
  line_item_options_count: 0,
  shipments_count: 1,
  tax_calculations_count: 0,
  payment_source_details: { type: 'wire_transfer' },
  token: '8dae3a32b28749d63d8edc0ab155797c',
  cart_url: null,
  return_url: null,
  terms_url: null,
  privacy_url: null,
  checkout_url: null,
  placed_at: '2022-10-04T04:13:20.918Z',
  approved_at: null,
  cancelled_at: null,
  payment_updated_at: '2022-10-04T04:13:20.893Z',
  fulfillment_updated_at: null,
  refreshed_at: '2022-10-04T03:45:44.726Z',
  archived_at: null,
  expires_at: null,
  created_at: '2022-10-03T19:11:30.582Z',
  updated_at: '2022-10-04T04:13:20.925Z',
  reference: null,
  reference_origin: null,
  metadata: {}
}

Create sales channel API credentials

Generate a checkout URL

cl plugins:install checkout

You can use the cl checkout --help command to see the list of available commands and what they do.

cl applications:login -o <organizationSlug> -i <clientId> -S <scope> -a <applicationAlias>

Where:

If you have already logged in, you can just switch to the sales channel API credentials using the command below:

cl app:switch -a <applicationAlias>

Place an order with the order ID

If you have the ID of an order ready to be placed, you can generate a valid checkout URL like so:

The following command creates a checkout URL associated with an order:

cl checkout -O <order-id>

The checkout URL is returned:

Checkout URL for order wjobhWrZka:

https://cake-store.checkout.commercelayer.app/wjobhWrZka?accessToken=eyJhbGciOiJIUzUxMiJ9.eyJvcmdhbml6YXRpb24iOnsiaWQiOiJFbnBWT0ZyS3Z5Iiwic2x1ZyI6ImNha2Utc3RvcmUiLCJlbnRlcnByaXNlIjpmYWxzZX0sImFwcGxpY2F0aW9uIjp7ImlkIjoid05iam1pd0JvTiIsImtpbmQiOiJzYWxlc19jaGFubmVsIiwicHVibGljIjp0cnVlfSwidGVzdCI6dHJ1ZSwiZXhwIjoxNjk2MzkxMTMwLCJtYXJrZXQiOnsiaWQiOlsiWWxxeEdoS3JRZyJdLCJwcmljZV9saXN0X2lkIjoid2xacnZDWXJLbCIsInN0b2NrX2xvY2F0aW9uX2lkcyI6WyJ6bkJqeHVsTFZuIiwiWmtZcVh1ZFZkayJdLCJnZW9jb2Rlcl9pZCI6bnVsbCwiYWxsb3dzX2V4dGVybmFsX3ByaWNlcyI6ZmFsc2V9LCJyYW5kIjowLjExNTQ0NjUyOTM2MjgzMn0.Bh-DuqgqgxLHy8QhdcTj8rf2SS3xeu5NECyZSWsJw3ZwTyVqB5U9oSx3tki2vwFbAyxcLLHv-U69nCWqy2FbtA

Checkout one or more SKUs

Alternatively, you can add new items to an order or directly create a new one and then place it, like so:

The following command creates an order and the related line items, associated with one or more SKUs. It also creates a checkout URL associated with the order:

cl checkout -S 5PANECAP000000FFFFFFXXXX -S BACKPACKFFFFFF000000XXXX -S BEACHBAG000000FFFFFFXXXX -m QlNQVhWxbg -e bolaji@commercelayer.io

The created order ID, line items ID, and checkout URL are returned:

Created order wnlKhYmZEE
Created line item NMlZtWKbKw for SKU BEACHBAG000000FFFFFFXXXX and associated to order wnlKhYmZEE
Created line item yeYRtdQmQE for SKU 5PANECAP000000FFFFFFXXXX and associated to order wnlKhYmZEE
Created line item vbmetaMdMP for SKU BACKPACKFFFFFF000000XXXX and associated to order wnlKhYmZEE

Checkout URL for order wnlKhYmZEE:

https://cake-store.checkout.commercelayer.app/wnlKhYmZEE?accessToken=eyJhbGciOiJIUzUxMiJ9.eyJvcmdhbml6YXRpb24iOnsiaWQiOiJFbnBWT0ZyS3Z5Iiwic2x1ZyI6ImNha2Utc3RvcmUiLCJlbnRlcnByaXNlIjpmYWxzZX0sImFwcGxpY2F0aW9uIjp7ImlkIjoid05iam1pd0JvTiIsImtpbmQiOiJzYWxlc19jaGFubmVsIiwicHVibGljIjp0cnVlfSwidGVzdCI6dHJ1ZSwiZXhwIjoxNjk2MzkxMTMwLCJtYXJrZXQiOnsiaWQiOlsiWWxxeEdoS3JRZyJdLCJwcmljZV9saXN0X2lkIjoid2xacnZDWXJLbCIsInN0b2NrX2xvY2F0aW9uX2lkcyI6WyJ6bkJqeHVsTFZuIiwiWmtZcVh1ZFZkayJdLCJnZW9jb2Rlcl9pZCI6bnVsbCwiYWxsb3dzX2V4dGVybmFsX3ByaWNlcyI6ZmFsc2V9LCJyYW5kIjowLjExNTQ0NjUyOTM2MjgzMn0.Bh-DuqgqgxLHy8QhdcTj8rf2SS3xeu5NECyZSWsJw3ZwTyVqB5U9oSx3tki2vwFbAyxcLLHv-U69nCWqy2FbtA

Here’s a breakdown of each of the command options:

  • The checkout command uses the installed checkout plugin.

  • The -O flag allows you to pass in an order ID.

  • The -S flag allows you to pass in an SKU code.

  • The -m flag allows you to pass in a market ID.

  • The -e flag allows you to pass in a customer email.

  • The -c flag allows you to pass in a coupon code.

  • The -B flag allows you to pass in a bundle code.

Further resources

As soon as you and your account is successfully confirmed, you will be prompted to create your first organization. Otherwise, if you already have an account, click on your current organization name in the left upper corner of your dashboard homepage to access your list of and select + New organization from the dropdown to create a new one for your business. Then, on the following page, enter a name and select the region where your data will be stored, as seen in the screenshots below.

Once the organization is created, the chosen data storage location cannot be changed anymore. If — for whatever reason — you need to delete one or more of the organizations you created, please ask the organization owner to reach out to our support team and send a specific request to specifying the list of the organization slug you want to be deleted.

Follow to create new integration API credentials (client ID, client secret, and base endpoint) from the Dashboard with an Admin role. Remember to save them as we'll use them later to .

Log in via the CLI using the integration API credentials like so:

To get started, you need to install the so that you can execute CRUD operations on the API resources. To do that, use the command below:

You can run the command cl resources to list all the available Commerce Layer API and a link to the documentation of each one. Use commercelayer resources --help to see the available commands and what they do.

To get your organization ready to receive orders, you need to create some resources. These resources are grouped into , , , and . The sections below describe each of these resources in sequential order, and how to create them using the resources plugin of the CLI. All the resources will be created using sample data, and we will add the following for each of them:

A description of the resource with a link to the related object details in the .

A link to the related where you can check the flowchart that illustrates how the specific resource relates to other API entities.

The resource is the foundation of users and merchants in Commerce Layer. It includes the literal details of a physical address of a person. An address can be associated with other resources or orders as their shipping or billing addresses.

A is a fiscal representative that is selling in a specific market. Tax calculators use the merchant's address to determine the tax rate for an order. The merchant needs to be associated with a billing address. To do that we will use the ID from the address resource.

contain the inventory of the SKUs (stock items) that are to be sold. A new stock location needs to be associated with an address. If the address is different from the merchant's one, then you should create a new address following and use the new address ID here. To keep it simple, we’ll use the merchant’s address.

An defines a list of stock locations ordered by priority. The priority determines how the availability of SKUs gets calculated within a market. If an order contains line items from two or more stock locations, the order can be split into two or more shipments, according to the selected .

build a hierarchy of stock locations within an inventory model. In cases where an SKU is available in more stock locations, it gets shipped from the one with the highest priority. You can decide to put the associated shipments on hold if fulfilled from a specific stock location (false by default). This is useful to manage use cases like back-orders, pre-orders, or personalized orders that need to be customized before being fulfilled. To create a new inventory stock location, you need to associate it with a stock location and an inventory model. We will use the ones we created earlier.

determine the SKU prices and their currency within a market. When you create a price list you have to specify the related currency and you can decide whether the associated prices include taxes or not (by default taxes are included).

A is an aggregation of business rules, often determined by a geographical region where merchants can sell items and customers can purchase. An organization may have one or more markets associated with a merchant, inventory model, SKUs, price lists, stock items, customer groups, and more. When you create a new market you need at least to associate it with a merchant, an inventory model, and a price list. We will use the ones we created earlier.

determine which shipping methods are available for the associated SKUs. With this, an order will be split into multiple shipments if it contains line items belonging to more than one shipping category.

determine the available shipping method(s) for a given shipping address. The match is evaluated against a set of regular expressions on the address (country, state, or zip code) of a customer. Now let’s create a new shipping zone to match Italy (IT), Spain (ES), Germany (DE), France (FR), and the United Kingdom (UK).

are used to provide customers with delivery options. Each shipping method can have a price and can be free if the order total is over a certain amount or based on some specific promotion rules. When you create a new shipping method you need to specify its cost (amount) and the currency code. If you associate the shipping method with a market, the currency will be inherited from the market's price list. You need also to associate it with a shipping zone and a shipping category. We will use the previously created ones.

allow users to process payments through Commerce Layer's API. By default, we currently support , , , , , and . are also available (useful to process payments through wire transfer, cash, and other kinds of manual payment options). On top of that, let you integrate any payment service that is not available out-of-the-box (even your custom one). You can check the API references of each of them to understand the attributes/relationships required for their creation. For the purpose of this guide, we will create a manual gateway

represent the type of payment sources (e.g. credit card, PayPal, or Apple Pay) offered in a market. They can have a price and must be present before placing an order. By default, we currently support the following payment source types: , , , credit card, , , , or — based on the payment gateway to be associated with. The manual payment gateway only accepts the wire transfer payment source type and that's the one we will use to create the payment method, associated with the previously created payment gateway.

describe specific product variations that are being sold. To create an SKU you need to associate it with a shipping category that determines the available shipping options for that SKU. We will use the one. You can add any additional optional attribute that fits your needs.

A keeps the available inventory of an SKU in a given stock location. When you create a stock item, you must specify its quantity, and the associated SKU must be available in one of the market's stock locations.

are the defined cost price of an SKU associated with a currency and price list. When a customer purchases an SKU, it gets the price associated with the order's price list for that market. When you create a price, you must specify the amount and the compare-at amount. The currency is defined by the associated price list.

Commerce Layer lets you import multiple resources (e.g. orders, coupons, SKUs, prices, stock items, customers, and more) in batches directly with our . All you have to do is create a new import resource, specify the resource type you want to import, and populate the inputs attribute with a JSON list of items. Each element of the inputs array contains the resource attributes and relationships. You can learn more about importing resources in our documentation.

To do that using the CLI, first you need to install the :

An consists of a customer, some line items (SKUs, shipping method, payment method, taxes, etc.), a billing address, a shipping address, discount(s) calculated from active promotions, redeemed gift card(s), a payment method, and a payment source type. The sections below will walk you through the process of creating an order by associating it with the required resources, step by step.

Remember that to place and checkout an order you can also leverage our hosted checkout application (automatically enabled for every Commerce Layer account) — if you want to learn more about how to generate a checkout URL using our CLI, feel free to skip the manual steps below and jump directly .

You can find the ID of the market you want to purchase from in the dashboard. Alternatively, you can use the CLI (feel free to filter out the results as shown in the if the list of your markets is too long):

You can associate different addresses for shipping and billing. All you need to do is create another address as described in the and associate the ID here.

To place the order you need now to create a related to the selected payment method:

Follow to create new sales channel API credentials (client ID and base endpoint) from the dashboard. Remember to save them as we'll use them to later.

You can create a checkout link using our application. With this, you can checkout an order in a web browser. To get started, you need to install the using the command below:

Only a access token can be used to generate a checkout URL. So, use the command below to log with your sales channel API credentilas (similar to what you did ):

The -S flag is required for sales channels and allows you to pass in your as a parameter.

Now that your first organization is properly configured and you managed to place your first order, you can take the time to explore the rest of this getting started section, check the , have a look at our recipe-like , and become a pro!

Do you need to extract some kind of data information from your Commerce Layer's organization? We've got you covered. Check our and see how it can enable you to gather and aggregate useful data that you can leverage to measure the health and performance of your ecommerce business.

If you want to exercise greater control over your organizational structure and user roles and be able to manage provisioning tasks programmatically instead of manually, leverage our .

Would you like to benefit from a DSL that enables you to define promotional rules? If you're an enterprise customer, you can ask to test our and start setting up almost any kind of promotions to boost your sales, from the simplest to the most complex.

For everything else, and feel free to ask any questions to the team or get involved in the conversation with the rest of our developers' community.

sign up for free
organizations
support@commercelayer.io
resources plugin
data model
address
inventory model
inventory strategy
Inventory stock locations
Price lists
market
Shipping categories
Shipping zones
Shipping methods
Payment gateways
Adyen
Braintree
Checkout.com
Klarna
PayPal
Stripe
Manual gateways
external gateways
Payment methods
Adyen payment
Braintree payment
Checkout.com payment
PayPal payment
Stripe payment
external payment
wire transfer
stock item
Prices
imports API
Importing resources
imports plugin
order
payment source type
hosted checkout
checkout plugin
join us on Discord
Commerce Layer CLI
data model
follow the wizard
This guide
Create an organization
Create integration API credentials
Install the Commerce Layer CLI
Log in using the API credentials
Install the resources plugin
Configure your organization
Address
Merchant
Stock location
Inventory model
Inventory stock location
Price list
Market
Shipping category
Shipping zone
Shipping method
Payment gateway
Payment method
SKUs
Stock items
Prices
Import additional resources
Create an order
Create sales channel API credentials
Generate a checkout URL
previously created
Markets
Shipping
Payments
Products
previously installed
merchant
previously created
Stock locations
the same method above
SKUs
previously created
here
previous section
previous step
LogoMerchants and Customers | Commerce Layer Data ModelCommerce Layer
LogoStock Locations | Commerce Layer Data ModelCommerce Layer
LogoInventory Models | Commerce Layer Data ModelCommerce Layer
LogoPrice Lists and Currencies | Commerce Layer Data ModelCommerce Layer
LogoPrice Lists and Currencies | Commerce Layer Data ModelCommerce Layer
LogoMarkets and Business Models | Commerce Layer Data ModelCommerce Layer
LogoShipments and Shipping Categories | Commerce Layer Data ModelCommerce Layer
LogoShipping Zones and Methods | Commerce Layer Data ModelCommerce Layer
LogoShipping Zones and Methods | Commerce Layer Data ModelCommerce Layer
LogoPayment Gateways | Commerce Layer Data ModelCommerce Layer
LogoPayment Methods | Commerce Layer Data ModelCommerce Layer
LogoSKUs | Commerce Layer Data ModelCommerce Layer
LogoStock Items | Commerce Layer Data ModelCommerce Layer
LogoAnatomy of an Order | Commerce Layer Data ModelCommerce Layer
resources
API reference
Rules Engine
application scope
interact with the CLI
these steps
interact with the checkout plugin of the CLI
these steps
previously created
before
sales channel
how-tos
API reference
Metrics API
Provisioning API