# Manual configuration

If you want to get deeper and understand the Commerce Layer Core API data model in detail, you may want to try to configure your organization manually, directly interacting with our APIs by leveraging the [Commerce Layer CLI](https://github.com/commercelayer/commercelayer-cli). 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. [This guide](#manual-seeding-reference-guide) 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.

{% hint style="info" %}
Please refer to Commerce Layer Core API [data model](https://commercelayer.io/docs/data-model) documentation to get an overview of the most relevant API entities, their mutual relationships, and common usage with the help of E-R diagrams.
{% endhint %}

As an alternative, if you want to go straight to the chase, you can [follow the wizard](https://docs.commercelayer.io/core/onboarding/guided-setup) available on the Dashboard UI when you create a new organization.

## Manual seeding reference guide

1. [Create an organization](#create-an-organization)
2. [Create integration API credentials](#create-integration-api-credentials)
3. [Install the Commerce Layer CLI](#install-the-commerce-layer-cli)
4. [Log in using the API credentials](#log-in-using-the-api-credentials)
5. [Install the resources plugin](#install-the-resources-plugin)
6. [Configure your organization](#configure-your-organization)
   * [x] **Markets**
     * [Address](#address)
     * [Merchant](#merchant)
     * [Stock location](#stock-location)
     * [Inventory model](#inventory-model)
     * [Inventory stock location](#inventory-stock-location)
     * [Price list](#price-list)
     * [Market](#market)
   * [x] **Shipping**
     * [Shipping category](#shipping-category)
     * [Shipping zone](#shipping-zone)
     * [Shipping method](#shipping-method)
   * [x] **Payments**
     * [Payment gateway](#payment-gateway)
     * [Payment method](#payment-method)
   * [x] **Products**
     * [SKUs](#skus)
     * [Stock items](#stock-items)
     * [Prices](#prices)
7. [Import additional resources](#import-additional-resources)
8. [Create an order](#create-an-order)
9. [Create sales channel API credentials](#create-sales-channel-api-credentials)
10. [Generate a checkout URL](#generate-a-checkout-url)

## Create an organization

As soon as you [sign up for free](https://dashboard.commercelayer.io/sign_up) 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 [organizations](https://commercelayer.io/docs/data-model/users-and-organizations) 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.

![](https://1360111082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgByaSP8eKjad-MIuHE%2Fuploads%2FyVtrLb0pEAvUKXY7kNFu%2Fdashboard-home-stats-org-dropdown.jpg?alt=media\&token=ce9acd50-291e-4572-921e-c68b0e1ce708)

<figure><img src="https://1360111082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgByaSP8eKjad-MIuHE%2Fuploads%2FQuSIptB8L5Y7tye7hACK%2Fnew-org.jpg?alt=media&#x26;token=faa22b99-afc9-43cf-9350-67526e156014" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
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 [support@commercelayer.io ](mailto:support@commercelayer.io)specifying the list of the organization slug you want to be deleted.
{% endhint %}

## Create integration API credentials

Follow [these steps](https://docs.commercelayer.io/core/api-credentials#create-an-integration) 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 [interact with the CLI](#log-in-using-the-api-credentials).

## Install the Commerce Layer CLI

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

```shell
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`.

{% hint style="info" %}
You can run `commercelayer help` at any point to learn about the available command options.
{% endhint %}

## Log in using the API credentials <a href="#log-in-using-the-api-credentials" id="log-in-using-the-api-credentials"></a>

Log in via the CLI using the [previously created](#create-integration-api-credentials) integration API credentials like so:

```shell
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

To get started, you need to install the [resources plugin](https://github.com/commercelayer/commercelayer-cli-plugin-resources) so that you can execute CRUD operations on the API resources. To do that, use the command below:

```shell
cl plugins:install resources
```

{% hint style="info" %}
You can run the command `cl resources` to list all the available Commerce Layer API [resources](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/RWJeylueWkzLadK710XZ/) and a link to the documentation of each one. Use `commercelayer resources --help` to see the available commands and what they do.
{% endhint %}

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.

{% hint style="info" %}
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).
{% endhint %}

#### Example

{% tabs %}
{% tab title="CLI command" %}
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:

```shell
commercelayer list skus --doc
```

{% endtab %}

{% tab title="cURL" %}
This is the corresponding cURL command to fetch a collection of SKUs:

```shell
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'
```

{% endtab %}

{% tab title="Node" %}
This is the corresponding Node command to fetch a collection of SKUs:

```javascript
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)
```

{% endtab %}
{% endtabs %}

## Configure your organization

To get your organization ready to receive orders, you need to create some resources. These resources are grouped into [Markets](#markets), [Shipping](#shipping), [Payments](#payments), and [Products](#products). The sections below describe each of these resources in sequential order, and how to create them using the [previously installed](#install-the-resources-plugin) 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 [API reference](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/RWJeylueWkzLadK710XZ/).
* The command for creating the resource.
* The output response of the successfully run command.
* A link to the related [data model](https://commercelayer.io/docs/data-model) where you can check the flowchart that illustrates how the specific resource relates to other API entities.

{% hint style="info" %}
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).
{% endhint %}

### Markets

#### Address

The [address](https://docs.commercelayer.io/developers/v/api-reference/addresses/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new address:

```shell
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"
```

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created address object information is prompted:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

#### Merchant

A [merchant](https://docs.commercelayer.io/developers/v/api-reference/merchants/object) 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 [previously created](#address) address resource.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new merchant and associates it with a billing address:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created merchant object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/merchants-and-customers>" %}

#### Stock location

[Stock locations](https://docs.commercelayer.io/developers/v/api-reference/stock_locations/object) 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 [the same method above](#address) and use the new address ID here. To keep it simple, we’ll use the merchant’s address.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new stock location and associates it with an address:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created stock location object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/stock-locations>" %}

#### Inventory model

An [inventory model](https://docs.commercelayer.io/developers/v/api-reference/inventory_models/object) 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 [inventory strategy](https://docs.commercelayer.io/developers/v/how-tos/inventory-model-strategies).

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new inventory model:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created inventory model object information is prompted:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/inventory-models>" %}

#### Inventory stock location

[Inventory stock locations](https://docs.commercelayer.io/developers/v/api-reference/inventory_stock_locations/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new inventory stock location and associates it with a stock location and an inventory model:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created inventory stock location object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

#### Price list

[Price lists](https://docs.commercelayer.io/developers/v/api-reference/price_lists/object) 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).

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new price list associated with the European currency, with tax included (default):

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created price list object information is prompted. You can see that the taxes have been included by default:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/price-lists-and-currencies>" %}

#### Market

A [market](https://docs.commercelayer.io/developers/v/api-reference/markets/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new market and associate it list associates it with a merchant, an inventory model, and a price list:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created market object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/markets-and-business-models>" %}

### Shipping

#### Shipping category

[Shipping categories](https://docs.commercelayer.io/developers/v/api-reference/shipping_categories/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new shipping category:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created shipping category object information is prompted:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/shipments-and-shipping-categories>" %}

#### Shipping zone

[Shipping zones](https://docs.commercelayer.io/developers/v/api-reference/shipping_zones/object) 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).

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new shipping zone to match Italy (IT), Spain (ES), Germany (DE), France (FR), and the United Kingdom (UK):

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created shipping zone object information is prompted:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/shipping-zones-and-methods>" %}

#### Shipping method

[Shipping methods](https://docs.commercelayer.io/developers/v/api-reference/shipping_methods/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new shipping method and associates it with a market, a shipping zone, and a shipping category.

```shell
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"
```

{% endtab %}

{% tab title="Response" %}
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:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/shipping-zones-and-methods>" %}

### Payments

#### Payment gateway

[Payment gateways](https://docs.commercelayer.io/developers/v/api-reference/payment_gateways/object) allow users to process payments through Commerce Layer's API. By default, we currently support [Adyen](https://docs.commercelayer.io/developers/v/api-reference/adyen_gateways/object), [Braintree](https://docs.commercelayer.io/developers/v/api-reference/braintree_gateways/object), [Checkout.com](https://docs.commercelayer.io/developers/v/api-reference/checkout_com_gateways/object), [Klarna](https://docs.commercelayer.io/developers/v/api-reference/klarna_gateways/object), [PayPal](https://docs.commercelayer.io/developers/v/api-reference/paypal_gateways), and [Stripe](https://docs.commercelayer.io/developers/v/api-reference/stripe_gateways/object). [Manual gateways](https://docs.commercelayer.io/developers/v/api-reference/manual_gateways/object) are also available (useful to process payments through wire transfer, cash, and other kinds of manual payment options). On top of that, [external gateways](https://docs.commercelayer.io/developers/v/api-reference/external_gateways/object) 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

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new manual payment gateway:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created manual payment gateway object information is prompted:

```javascript
{
  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
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
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.
{% endhint %}

{% embed url="<https://commercelayer.io/docs/data-model/payment-gateways>" %}

#### Payment method

[Payment methods](https://docs.commercelayer.io/developers/v/api-reference/payment_methods/object) 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: [Adyen payment](https://docs.commercelayer.io/developers/v/api-reference/adyen_payments/object), [Braintree payment](https://docs.commercelayer.io/developers/v/api-reference/braintree_payments/object), [Checkout.com payment](https://docs.commercelayer.io/developers/v/api-reference/checkout_com_payments/object), credit card, [PayPal payment](https://docs.commercelayer.io/developers/v/api-reference/paypal_payments/object), [Stripe payment](https://docs.commercelayer.io/developers/v/api-reference/stripe_payments/object), [external payment](https://docs.commercelayer.io/developers/v/api-reference/external_payments/object), or [wire transfer](https://docs.commercelayer.io/developers/v/api-reference/wire_transfers/object) — 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new payment method and associates it with a manual payment gateway and a wire transfer payment source:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created payment method object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/payment-methods>" %}

### Products

#### SKUs

[SKUs](https://docs.commercelayer.io/developers/v/api-reference/skus/object) 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 [previously created](#shipping-category) one. You can add any additional optional attribute that fits your needs.

{% tabs %}
{% tab title="CLI command" %}
The following command created a new SKU and associates it with a shipping category:

```shell
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"
```

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created SKU object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/skus>" %}

#### Stock items

A [stock item](https://docs.commercelayer.io/developers/v/api-reference/stock_items/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new stock item for a given SKU and associates it with a stock location:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created stock item object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/stock-items>" %}

#### Prices

[Prices](https://docs.commercelayer.io/developers/v/api-reference/prices/object) 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.

{% tabs %}
{% tab title="CLI command" %}
The following command creates a price for a given SKU and associates it with a price list:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created price object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% embed url="<https://commercelayer.io/docs/data-model/price-lists-and-currencies>" %}

## Import additional resources

Commerce Layer lets you import multiple resources (e.g. orders, coupons, SKUs, prices, stock items, customers, and more) in batches directly with our [imports API](https://docs.commercelayer.io/developers/v/api-reference/imports/object). 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.

{% content-ref url="../importing-resources" %}
[importing-resources](https://docs.commercelayer.io/core/importing-resources)
{% endcontent-ref %}

To do that using the CLI, first you need to install the [imports plugin](https://github.com/commercelayer/commercelayer-cli-plugin-imports):

```shell
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:

```json
[
  {
    "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:

```json
[
  {
    "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:

```json
[
  {
    "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:

{% tabs %}
{% tab title="CLI command" %}
The following command imports the SKUs specified in a file:

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

{% endtab %}

{% tab title="Response" %}
On successful run, a brief report of the import process is prompted:

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

Import of 2 skus completed.
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="CLI command" %}
The following command imports the stock items specified in a file and associates them with a stock location:

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

{% endtab %}

{% tab title="Response" %}
On successful run, a brief report of the import process is prompted:

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

Import of 2 stock items completed.
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="CLI command" %}
The following command imports the prices specified in a file and associates them with a price list:

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

{% endtab %}

{% tab title="Response" %}
On successful run, a brief report of the import process is prompted:

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

Import of 2 prices completed.
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
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.
{% endhint %}

## Create an order

An [order](https://docs.commercelayer.io/core/v/api-reference/orders) 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.

{% embed url="<https://commercelayer.io/docs/data-model/anatomy-of-an-order>" %}

{% hint style="success" %}
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 [here](#checkout-one-or-more-skus).
{% endhint %}

#### 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:

{% tabs %}
{% tab title="CLI command" %}
The following command will search for all SKUs and filter out the results:

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

{% endtab %}

{% tab title="Response" %}
On successful run, an array of SKUs that match the search query is prompted:

```javascript
[
  {
    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: {}
  },
  {
  ...
  }
]
```

{% endtab %}
{% endtabs %}

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

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 [previous section](#search-for-the-id-of-the-sku-you-intend-to-purchase) if the list of your markets is too long):

{% tabs %}
{% tab title="CLI command" %}
The following command will search for all existing markets:

```shell
cl resources:get markets
```

{% endtab %}

{% tab title="Response" %}
On successful run, an array of existing markets is prompted:

```javascript
[
  {
    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: {}
  }
]
```

{% endtab %}
{% endtabs %}

#### Create a new order

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

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new order and associates it with a market:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created order object information is prompted:

```javascript
{
  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
```

{% endtab %}
{% endtabs %}

#### 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:

{% tabs %}
{% tab title="CLI command" %}
The following command creates a line item and associates it with an order and an SKU:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created line item object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

#### Assign the order to a customer

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

{% tabs %}
{% tab title="CLI command" %}
The following command associates a customer email with an order:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the updated order object information is prompted:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

#### Create an address

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

{% tabs %}
{% tab title="CLI command" %}
The following command creates a new address:

```shell
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
```

{% endtab %}

{% tab title="Response" %}
On successful run, the created address object information is prompted:

```javascript
{
  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: {}
}

```

{% endtab %}
{% endtabs %}

#### 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:

{% tabs %}
{% tab title="CLI command" %}
The following command associates a shipping and billing address with an order:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the updated order object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
You can associate different addresses for shipping and billing. All you need to do is create another address as described in the [previous step](#create-an-address) and associate the ID here.
{% endhint %}

#### 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:

{% tabs %}
{% tab title="CLI command" %}
The following command fetches the shipments associated with an order and all the available shipping methods:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the order object information (with shipments and shipping methods) is prompted:

```javascript
{
  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: {}
        }
      ]
    }
  ]
}
```

{% endtab %}
{% endtabs %}

#### Update the shipment with a shipping method

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

{% tabs %}
{% tab title="CLI command" %}
The following command associates a selected shipping method with a shipment:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the updated shipments object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

#### Get the available payment methods

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

{% tabs %}
{% tab title="CLI command" %}
The following command fetches the payment methods associated with an order:

```shell
cl resources:get orders wjobhWrZka -i available_payment_methods
```

{% endtab %}

{% tab title="Response" %}
On successful run, the order object information (with the available payment methods) is prompted:

```javascript
{
  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: {}
    }
  ]
}
```

{% endtab %}
{% endtabs %}

#### Update the order with a payment methods

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

{% tabs %}
{% tab title="CLI Command" %}
The following command associates a selected payment method with an order:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the updated order object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

#### Update the order with a payment source

To place the order you need now to create a [payment source type](https://docs.commercelayer.io/core/v/how-tos/checkout/selecting-a-payment-method#payment-source-types) related to the selected payment method:

{% tabs %}
{% tab title="CLI command" %}
The following command creates a wire transfer payment source type and associates it with an order:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the newly created payment source type object information is prompted:

```javascript
{
  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: {}
  }
}
```

{% endtab %}
{% endtabs %}

#### Place the order

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

{% tabs %}
{% tab title="CLI Command" %}
The following command places the order:

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

{% endtab %}

{% tab title="Response" %}
On successful run, the updated order object information is prompted:

```javascript
{
  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: {}
}
```

{% endtab %}
{% endtabs %}

## Create sales channel API credentials

Follow [these steps](https://docs.commercelayer.io/core/api-credentials#create-a-sales-channel) 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 [interact with the checkout plugin of the CLI](#generate-a-checkout-url) later.

## Generate a checkout URL

You can create a checkout link using our [hosted checkout](https://github.com/commercelayer/commercelayer-react-checkout) application. With this, you can checkout an order in a web browser. To get started, you need to install the [checkout plugin](https://github.com/commercelayer/commercelayer-cli-plugin-checkout/) using the command below:

```shell
cl plugins:install checkout
```

{% hint style="info" %}
You can use the `cl checkout --help` command to see the list of available commands and what they do.
{% endhint %}

Only a [sales channel](https://docs.commercelayer.io/core/api-credentials#sales-channel) access token can be used to generate a checkout URL. So, use the command below to log with your [previously created](#create-sales-channel-api-credentials) sales channel API credentilas (similar to what you did [before](#log-in-using-the-api-credentials)):

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

Where:

* The `-S` flag is required for sales channels and allows you to pass in your [application scope](https://docs.commercelayer.io/core/authentication#authorization-scopes) as a parameter.

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

```shell
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:

{% tabs %}
{% tab title="CLI command" %}
The following command creates a checkout URL associated with an order:

```shell
cl checkout -O <order-id>
```

{% endtab %}

{% tab title="Response" %}
The checkout URL is returned:

```
Checkout URL for order wjobhWrZka:

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

{% endtab %}
{% endtabs %}

#### 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:

{% tabs %}
{% tab title="CLI command" %}
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:

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

{% endtab %}

{% tab title="Response" %}
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
```

{% endtab %}
{% endtabs %}

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

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 [API reference](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/lhTYC557IzGiJNS84RKD/), have a look at our recipe-like [how-tos](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/-Lk-ezuDClaMavTqnRi0/), and become a pro!

{% hint style="success" icon="chart-line-up" %}
Do you need to extract some kind of data information from your Commerce Layer's organization? We've got you covered. Check our [Metrics API](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/ASSiAvbL4nFnkl8plQy2/) 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.
{% endhint %}

{% hint style="success" icon="user" %}
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 [Provisioning API](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/xrdVVavnnBMHRCqrLp1y/).
{% endhint %}

{% hint style="success" icon="gear-complex" %}
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 [Rules Engine](https://app.gitbook.com/o/-Lfu_B3DKew-kvoEWzTk/s/hiqD9AvrD8A8IPj7QXPv/) and start setting up almost any kind of promotions to boost your sales, from the simplest to the most complex.
{% endhint %}

For everything else, [join us on Discord](https://discord.gg/commercelayer) and feel free to ask any questions to the team or get involved in the conversation with the rest of our developers' community.
