Create a market

How to create a market via API

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

Request

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

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.name

string

Required

attributes.code

string

Optional

attributes.facebook_pixel_id

string

Optional

attributes.checkout_url

string

Optional

attributes.external_prices_url

string

Optional

attributes.external_order_validation_url

string

Optional

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

attributes._disable

boolean

Optional

attributes._enable

boolean

Optional

relationships.merchant

object

Required

relationships.price_list

object

Required

relationships.inventory_model

object

Required

relationships.subscription_model

object

Optional

relationships.tax_calculator

object

Optional

relationships.customer_group

object

Optional

Example

The following request creates a new market:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/markets' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "markets",
    "attributes": {
      "name": "EU Market"
    },
    "relationships": {
      "merchant": {
        "data": {
          "type": "merchants",
          "id": "ABCRtyUpBa"
        }
      },
      "price_list": {
        "data": {
          "type": "price_lists",
          "id": "BCDRtyUpBa"
        }
      },
      "inventory_model": {
        "data": {
          "type": "inventory_models",
          "id": "CDERtyUpBa"
        }
      }
    }
  }
}'

Last updated