Search…
API Reference
Resources
Create an inventory model
How to create an inventory model via API
To create a new inventory model, send a POST request to the /api/inventory_models endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.name
string
Required
attributes.strategy
string
Required
attributes.stock_locations_cutoff
integer
Optional, default is 2
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional

Example

Request
Response
The following request creates a new inventory model:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/inventory_models' \
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": "inventory_models",
9
"attributes": {
10
"name": "EU Inventory Model",
11
"strategy": "split_shipments"
12
}
13
}
14
}'
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": "inventory_models",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde"
7
},
8
"attributes": {
9
"name": "EU Inventory Model",
10
"strategy": "split_shipments",
11
"stock_locations_cutoff": 3,
12
"created_at": "2018-01-01T12:00:00.000Z",
13
"updated_at": "2018-01-01T12:00:00.000Z",
14
"reference": "ANY-EXTERNAL-REFEFERNCE",
15
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
16
"metadata": {
17
"foo": "bar"
18
}
19
},
20
"relationships": {
21
"inventory_stock_locations": {
22
"links": {
23
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/inventory_stock_locations",
24
"related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/inventory_stock_locations"
25
}
26
},
27
"inventory_return_locations": {
28
"links": {
29
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/inventory_return_locations",
30
"related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/inventory_return_locations"
31
}
32
},
33
"attachments": {
34
"links": {
35
"self": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/relationships/attachments",
36
"related": "https://yourdomain.commercelayer.io/api/inventory_models/xYZkjABcde/attachments"
37
}
38
}
39
},
40
"meta": {
41
"mode": "test"
42
}
43
}
44
}
Copied!
Last modified 2mo ago
Copy link