Create an order

How to create an order via API

To create a new order, send a POST request to the /api/orders endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/orders

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.number

string

Optional, default to numeric id

attributes.affiliate_code

string

Optional

attributes.autorefresh

boolean

Optional, default is 'true'

attributes.place_async

boolean

Optional, default is 'false'

attributes.guest

boolean

Optional

attributes.customer_email

string

Optional

attributes.customer_password

string

Optional

attributes.language_code

string

Optional, default is 'en'

attributes.freight_taxable

boolean

Optional, default is 'false' or set by tax calculator

attributes.payment_method_taxable

boolean

Optional, default is 'false' or set by tax calculator

attributes.adjustment_taxable

boolean

Optional, default is 'false' or set by tax calculator

attributes.gift_card_taxable

boolean

Optional, default is 'false' or set by tax calculator

attributes.shipping_country_code_lock

string

Optional

attributes.coupon_code

string

Optional

attributes.gift_card_code

string

Optional

attributes.cart_url

string

Optional

attributes.return_url

string

Optional

attributes.terms_url

string

Optional

attributes.privacy_url

string

Optional

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.market

object

Required, unless in scope

relationships.customer

object

Optional

relationships.shipping_address

object

Optional

relationships.billing_address

object

Optional

relationships.store

object

Optional, set by scope

relationships.payment_method

object

Optional

relationships.payment_source

object

Optional

relationships.tags

array

Optional

Example

The following request creates a new order:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/orders' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "orders",
    "attributes": {
      "language_code": "it"
    }
  }
}'

Last updated