Search…
API Reference
Updating resources
How to update a resource via API
You can update a resource by sending a PATCH request to the resources endpoint, with a JSON payload.
The Content-Type header must be application/vnd.api+json.
You can get the list of arguments, with type and examples from the documentation of each resource.

Example

Request
Response
The following request updates the description of an existing SKU:
1
curl -g -X PATCH \
2
'https://yourdomain.commercelayer.io/api/skus/xYZkjABcde' \
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
"id": "xYZkjABcde",
10
"attributes": {
11
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
12
}
13
}
14
}'
Copied!
On success, the API responds with a 200 OK status code, returning the updated 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 adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
12
"image_url": null,
13
"tag_names": "",
14
"pieces_per_pack": null,
15
"weight": null,
16
"unit_of_weight": null,
17
"hs_tariff_number": null,
18
"do_not_ship": false,
19
"do_not_track": false,
20
"created_at": "2018-01-01T12:00:00.000Z",
21
"updated_at": "2018-01-01T12:00:00.000Z",
22
"reference": null,
23
"metadata": {}
24
},
25
"relationships": {
26
"shipping_category": {
27
"links": {...}
28
},
29
"prices": {
30
"links": {...}
31
},
32
"stock_items": {
33
"links": {...}
34
},
35
"delivery_lead_times": {
36
"links": {...}
37
},
38
"sku_options": {
39
"links": {...}
40
}
41
},
42
"meta": {
43
"mode": "test"
44
}
45
}
46
}
Copied!
Last modified 1mo ago
Copy link
Contents
Example