Search…
API Reference
Resources
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.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.tax_calculator
object
Optional
relationships.customer_group
object
Optional

Example

Request
Response
The following request creates a new market:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/markets' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token' \
5
-H 'Content-Type: application/vnd.api+json' \
6
-d '{
7
"data": {
8
"type": "markets",
9
"attributes": {
10
"name": "EU Market"
11
},
12
"relationships": {
13
"merchant": {
14
"data": {
15
"type": "merchants",
16
"id": "QWERtyUpBa"
17
}
18
},
19
"price_list": {
20
"data": {
21
"type": "price_lists",
22
"id": "QWERtyUpBa"
23
}
24
},
25
"inventory_model": {
26
"data": {
27
"type": "inventory_models",
28
"id": "QWERtyUpBa"
29
}
30
}
31
}
32
}
33
}'
Copied!
On success, the API responds with a 201 Created status code, returning the created resource object:
1
{
2
"data": {
3
"id": "xYZkjABcde",
4
"type": "markets",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde"
7
},
8
"attributes": {
9
"number": 1234,
10
"name": "EU Market",
11
"facebook_pixel_id": "1234567890",
12
"checkout_url": "https://checkout.yourbrand.com/:order_id",
13
"external_prices_url": "https://external_prices.yourbrand.com",
14
"private": true,
15
"created_at": "2018-01-01T12:00:00.000Z",
16
"updated_at": "2018-01-01T12:00:00.000Z",
17
"reference": "ANY-EXTERNAL-REFEFERNCE",
18
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
19
"metadata": {
20
"foo": "bar"
21
}
22
},
23
"relationships": {
24
"merchant": {
25
"links": {
26
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/merchant",
27
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/merchant"
28
}
29
},
30
"price_list": {
31
"links": {
32
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/price_list",
33
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/price_list"
34
}
35
},
36
"inventory_model": {
37
"links": {
38
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/inventory_model",
39
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/inventory_model"
40
}
41
},
42
"tax_calculator": {
43
"links": {
44
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/tax_calculator",
45
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/tax_calculator"
46
}
47
},
48
"customer_group": {
49
"links": {
50
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/customer_group",
51
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/customer_group"
52
}
53
},
54
"attachments": {
55
"links": {
56
"self": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/relationships/attachments",
57
"related": "https://yourdomain.commercelayer.io/api/markets/xYZkjABcde/attachments"
58
}
59
}
60
},
61
"meta": {
62
"mode": "test"
63
}
64
}
65
}
Copied!
Last modified 23d ago
Copy link