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 |
| Required |
attributes.code |
| Required |
attributes.description |
| Optional |
attributes.do_not_ship |
| Optional |
attributes.do_not_track |
| Optional |
attributes.hs_tariff_number |
| Optional |
attributes.image_url |
| Optional |
attributes.metadata |
| Optional |
attributes.name |
| Required |
attributes.pieces_per_pack |
| Optional |
attributes.reference |
| Optional |
attributes.reference_origin |
| Optional |
attributes.unit_of_weight |
| Optional |
attributes.weight |
| Optional |
relationships.shipping_category |
| Required |
relationships.tags |
| Optional |
Example
The following request creates a new SKU:
curl -g -X POST \
'https://yourdomain.commercelayer.io/api/skus' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "skus",
"attributes": {
"code": "TSHIRTMM000000FFFFFFXLXX",
"name": "Men's Black T-shirt with White Logo (XL)"
},
"relationships": {
"shipping_category": {
"data": {
"type": "shipping_categories",
"id": "ABCRtyUpBa"
}
}
}
}
}'
On success, the API responds with a 201 Created
status code, returning the created resource object:
{
"data": {
"id": "xYZkjABcde",
"type": "skus",
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde"
},
"attributes": {
"code": "TSHIRTMM000000FFFFFFXLXX",
"created_at": "2018-01-01T12:00:00.000Z",
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"do_not_ship": false,
"do_not_track": false,
"hs_tariff_number": "4901.91.0020",
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
"inventory": {
"available": true,
"levels": [
{
"delivery_lead_times": [
{
"max": {
"days": 5,
"hours": 120
},
"min": {
"days": 3,
"hours": 72
},
"shipping_method": {
"formatted_free_over_amount": "€99,00",
"formatted_price_amount": "€7,00",
"free_over_amount_cents": 9900,
"name": "Standard Shipping",
"price_amount_cents": 700,
"reference": null
}
},
{
"max": {
"days": 3,
"hours": 72
},
"min": {
"days": 2,
"hours": 48
},
"shipping_method": {
"formatted_free_over_amount": null,
"formatted_price_amount": "€12,00",
"free_over_amount_cents": null,
"name": "Express Delivery",
"price_amount_cents": 1200,
"reference": null
}
}
],
"quantity": 4
},
{
"delivery_lead_times": [
{
"max": {
"days": 6,
"hours": 144
},
"min": {
"days": 4,
"hours": 96
},
"shipping_method": {
"formatted_free_over_amount": "€99,00",
"formatted_price_amount": "€7,00",
"free_over_amount_cents": 9900,
"name": "Standard Shipping",
"price_amount_cents": 700,
"reference": null
}
},
{
"max": {
"days": 4,
"hours": 96
},
"min": {
"days": 3,
"hours": 72
},
"shipping_method": {
"formatted_free_over_amount": null,
"formatted_price_amount": "€12,00",
"free_over_amount_cents": null,
"name": "Express Delivery",
"price_amount_cents": 1200,
"reference": null
}
}
],
"quantity": 6
}
],
"quantity": 10
},
"metadata": {
"foo": "bar"
},
"name": "Men's Black T-shirt with White Logo (XL)",
"pieces_per_pack": 6,
"reference": "ANY-EXTERNAL-REFEFERNCE",
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
"unit_of_weight": "gr",
"updated_at": "2018-01-01T12:00:00.000Z",
"weight": 300.0
},
"relationships": {
"attachments": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/attachments",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/attachments"
}
},
"delivery_lead_times": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/delivery_lead_times",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/delivery_lead_times"
}
},
"events": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/events",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/events"
}
},
"jwt_customer": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/jwt_customer",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/jwt_customer"
}
},
"jwt_markets": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/jwt_markets",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/jwt_markets"
}
},
"jwt_stock_locations": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/jwt_stock_locations",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/jwt_stock_locations"
}
},
"links": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/links",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/links"
}
},
"prices": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/prices",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/prices"
}
},
"shipping_category": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/shipping_category",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/shipping_category"
}
},
"sku_options": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/sku_options",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/sku_options"
}
},
"stock_items": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/stock_items",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/stock_items"
}
},
"stock_reservations": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/stock_reservations",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/stock_reservations"
}
},
"tags": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/tags",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/tags"
}
},
"versions": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/versions",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/versions"
}
}
},
"meta": {
"mode": "test"
}
}
}
Last updated