API reference
Search
K
Links
Comment on page

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 Parameter
Type
Required
type
string
Required
attributes.name
string
Required
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
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

Request
Response
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"
}
}
}
}
}'
On success, the API responds with a 201 Created status code, returning the created resource object:
{
"data": {
"id": "xYZkjABcde",
"type": "markets",
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde"
},
"attributes": {
"number": 1234,
"name": "EU Market",
"facebook_pixel_id": "1234567890",
"checkout_url": "https://checkout.yourbrand.com/:order_id",
"external_prices_url": "https://external_prices.yourbrand.com",
"external_order_validation_url": "https://external_validation.yourbrand.com",
"shared_secret": "1c0994cc4e996e8c6ee56a2198f66f3c",
"private": true,
"disabled_at": "2018-01-01T12:00:00.000Z",
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": "ANY-EXTERNAL-REFEFERNCE",
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
"metadata": {
"foo": "bar"
}
},
"relationships": {
"merchant": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/merchant",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/merchant"
}
},
"price_list": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/price_list",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/price_list"
}
},
"inventory_model": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/inventory_model",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/inventory_model"
}
},
"subscription_model": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/subscription_model",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/subscription_model"
}
},
"tax_calculator": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/tax_calculator",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/tax_calculator"
}
},
"customer_group": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/customer_group",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/customer_group"
}
},
"attachments": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/attachments",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/attachments"
}
},
"versions": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/versions",
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/versions"
}
}
},
"meta": {
"mode": "test"
}
}
}