Update a SKU
How to update an existing SKU via API
To update an existing SKU, send a PATCH
request to the /api/skus/:id
endpoint, where id
is the ID of the resource that you want to update.
Here below the list of all the possible arguments that you can pass with the request body.
Request
PATCH https://yourdomain.commercelayer.io/api/skus/:id
Arguments
Body Parameter | Type | Required |
---|---|---|
type |
| Required |
id |
| Required |
attributes.code |
| Optional |
attributes.name |
| Optional |
attributes.description |
| Optional |
attributes.image_url |
| Optional |
attributes.pieces_per_pack |
| Optional |
attributes.weight |
| Optional |
attributes.unit_of_weight |
| Optional |
attributes.hs_tariff_number |
| Optional |
attributes.do_not_ship |
| Optional |
attributes.do_not_track |
| Optional |
attributes.reference |
| Optional |
attributes.reference_origin |
| Optional |
attributes.metadata |
| Optional |
relationships.shipping_category |
| Optional |
relationships.tags |
| Optional |
Example
The following request updates the SKU identified by the ID "xYZkjABcde":
curl -g -X PATCH \
'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "skus",
"id": "xYZkjABcde",
"attributes": {
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
},
"relationships": {
"shipping_category": {
"data": {
"type": "shipping_categories",
"id": "ABCRtyUpBa"
}
}
}
}
}'
On success, the API responds with a 200 OK
status code, returning the updated resource object:
{
"data": {
"id": "xYZkjABcde",
"type": "skus",
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde"
},
"attributes": {
"code": "TSHIRTMM000000FFFFFFXLXX",
"name": "Men's Black T-shirt with White Logo (XL)",
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
"pieces_per_pack": 6,
"weight": 300.0,
"unit_of_weight": "gr",
"hs_tariff_number": "4901.91.0020",
"do_not_ship": false,
"do_not_track": false,
"inventory": {
"available": true,
"quantity": 10,
"levels": [
{
"quantity": 4,
"delivery_lead_times": [
{
"shipping_method": {
"name": "Standard Shipping",
"reference": null,
"price_amount_cents": 700,
"free_over_amount_cents": 9900,
"formatted_price_amount": "€7,00",
"formatted_free_over_amount": "€99,00"
},
"min": {
"hours": 72,
"days": 3
},
"max": {
"hours": 120,
"days": 5
}
},
{
"shipping_method": {
"name": "Express Delivery",
"reference": null,
"price_amount_cents": 1200,
"free_over_amount_cents": null,
"formatted_price_amount": "€12,00",
"formatted_free_over_amount": null
},
"min": {
"hours": 48,
"days": 2
},
"max": {
"hours": 72,
"days": 3
}
}
]
},
{
"quantity": 6,
"delivery_lead_times": [
{
"shipping_method": {
"name": "Standard Shipping",
"reference": null,
"price_amount_cents": 700,
"free_over_amount_cents": 9900,
"formatted_price_amount": "€7,00",
"formatted_free_over_amount": "€99,00"
},
"min": {
"hours": 96,
"days": 4
},
"max": {
"hours": 144,
"days": 6
}
},
{
"shipping_method": {
"name": "Express Delivery",
"reference": null,
"price_amount_cents": 1200,
"free_over_amount_cents": null,
"formatted_price_amount": "€12,00",
"formatted_free_over_amount": null
},
"min": {
"hours": 72,
"days": 3
},
"max": {
"hours": 96,
"days": 4
}
}
]
}
]
},
"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",
"jwt_custom_claim": {
},
"metadata": {
"foo": "bar"
}
},
"relationships": {
"shipping_category": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/shipping_category",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/shipping_category"
}
},
"prices": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/prices",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/prices"
}
},
"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"
}
},
"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"
}
},
"sku_options": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/sku_options",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/sku_options"
}
},
"sku_list_items": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/sku_list_items",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/sku_list_items"
}
},
"sku_lists": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/sku_lists",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/sku_lists"
}
},
"attachments": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/attachments",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/attachments"
}
},
"links": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/links",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/links"
}
},
"events": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/relationships/events",
"related": "https://yourdomain.commercelayer.io/api/skus/xYZkjABcde/events"
}
},
"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"
}
},
"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"
}
}
},
"meta": {
"mode": "test",
"organization_id": "xRRkjDFafe",
"trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
}
}
}
Last updated