API Reference
Resources
Create a SKU
How to create a SKU via API
To create a new SKU, send a POST request to the /api/skus endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.code
string
Required
attributes.name
string
Required
attributes.description
string
Optional
attributes.image_url
string
Optional
attributes.pieces_per_pack
integer
Optional
attributes.weight
float
Optional
attributes.unit_of_weight
string
Optional
attributes.hs_tariff_number
string
Optional
attributes.do_not_ship
boolean
Optional
attributes.do_not_track
boolean
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.shipping_category
object
Required

Example

Request
Response
The following request creates a new SKU:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/skus' \
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": "skus",
9
"attributes": {
10
"code": "TSHIRTMM000000FFFFFFXLXX",
11
"name": "Black Men T-shirt with White Logo (XL)"
12
},
13
"relationships": {
14
"shipping_category": {
15
"data": {
16
"type": "shipping_categories",
17
"id": "QWERtyUpBa"
18
}
19
}
20
}
21
}
22
}'
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": "skus",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde"
7
},
8
"attributes": {
9
"code": "TSHIRTMM000000FFFFFFXLXX",
10
"name": "Black Men T-shirt with White Logo (XL)",
11
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
12
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
13
"pieces_per_pack": 6,
14
"weight": 300.0,
15
"unit_of_weight": "gr",
16
"hs_tariff_number": "4901.91.0020",
17
"do_not_ship": false,
18
"do_not_track": false,
19
"inventory": {
20
"available": true,
21
"quantity": 10,
22
"levels": [
23
{
24
"quantity": 4,
25
"delivery_lead_times": [
26
{
27
"shipping_method": {
28
"name": "Standard Shipping",
29
"reference": null,
30
"price_amount_cents": 700,
31
"free_over_amount_cents": 9900,
32
"formatted_price_amount": "€7,00",
33
"formatted_free_over_amount": "€99,00"
34
},
35
"min": {
36
"hours": 72,
37
"days": 3
38
},
39
"max": {
40
"hours": 120,
41
"days": 5
42
}
43
},
44
{
45
"shipping_method": {
46
"name": "Express Delivery",
47
"reference": null,
48
"price_amount_cents": 1200,
49
"free_over_amount_cents": null,
50
"formatted_price_amount": "€12,00",
51
"formatted_free_over_amount": null
52
},
53
"min": {
54
"hours": 48,
55
"days": 2
56
},
57
"max": {
58
"hours": 72,
59
"days": 3
60
}
61
}
62
]
63
},
64
{
65
"quantity": 6,
66
"delivery_lead_times": [
67
{
68
"shipping_method": {
69
"name": "Standard Shipping",
70
"reference": null,
71
"price_amount_cents": 700,
72
"free_over_amount_cents": 9900,
73
"formatted_price_amount": "€7,00",
74
"formatted_free_over_amount": "€99,00"
75
},
76
"min": {
77
"hours": 96,
78
"days": 4
79
},
80
"max": {
81
"hours": 144,
82
"days": 6
83
}
84
},
85
{
86
"shipping_method": {
87
"name": "Express Delivery",
88
"reference": null,
89
"price_amount_cents": 1200,
90
"free_over_amount_cents": null,
91
"formatted_price_amount": "€12,00",
92
"formatted_free_over_amount": null
93
},
94
"min": {
95
"hours": 72,
96
"days": 3
97
},
98
"max": {
99
"hours": 96,
100
"days": 4
101
}
102
}
103
]
104
}
105
]
106
},
107
"created_at": "2018-01-01T12:00:00.000Z",
108
"updated_at": "2018-01-01T12:00:00.000Z",
109
"reference": "ANY-EXTERNAL-REFEFERNCE",
110
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
111
"metadata": {
112
"foo": "bar"
113
}
114
},
115
"relationships": {
116
"shipping_category": {
117
"links": {
118
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/shipping_category",
119
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/shipping_category"
120
}
121
},
122
"prices": {
123
"links": {
124
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/prices",
125
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/prices"
126
}
127
},
128
"stock_items": {
129
"links": {
130
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/stock_items",
131
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/stock_items"
132
}
133
},
134
"delivery_lead_times": {
135
"links": {
136
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/delivery_lead_times",
137
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/delivery_lead_times"
138
}
139
},
140
"sku_options": {
141
"links": {
142
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/sku_options",
143
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/sku_options"
144
}
145
},
146
"attachments": {
147
"links": {
148
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/attachments",
149
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/attachments"
150
}
151
}
152
},
153
"meta": {
154
"mode": "test"
155
}
156
}
157
}
Copied!
Last modified 2mo ago
Copy link