Powered By GitBook
Update a line item
How to update an existing line item via API
To update an existing line item, send a PATCH request to the /api/line_items/: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/line_items/:id

Arguments

Body Parameter
Type
Required
type
string
Required
id
string
Required
attributes.sku_code
string
Optional
attributes.bundle_code
string
Optional
attributes.quantity
integer
Optional
attributes.name
string
Optional
attributes.image_url
string
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional

Example

Request
Response
The following request updates the line item identified by the ID "xYZkjABcde":
1
curl -X PATCH \
2
https://yourdomain.commercelayer.io/api/line_items/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": "line_items",
9
"id": "xYZkjABcde",
10
"attributes": {
11
"sku_code": "TSHIRTMM000000FFFFFFXLXX"
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": "line_items",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde"
7
},
8
"attributes": {
9
"sku_code": "TSHIRTMM000000FFFFFFXLXX",
10
"bundle_code": "BUNDLEMM000000FFFFFFXLXX",
11
"quantity": 4,
12
"currency_code": "EUR",
13
"unit_amount_cents": 9900,
14
"unit_amount_float": 99.0,
15
"formatted_unit_amount": "€99,00",
16
"options_amount_cents": 990,
17
"options_amount_float": 9.9,
18
"formatted_options_amount": "€9,90",
19
"discount_cents": -900,
20
"discount_float": 9.0,
21
"formatted_discount": "€9,00",
22
"total_amount_cents": 18800,
23
"total_amount_float": 188.0,
24
"formatted_total_amount": "€188,00",
25
"tax_amount_cents": 1880,
26
"tax_amount_float": 18.8,
27
"formatted_tax_amount": "€18,80",
28
"name": "Black Men T-shirt with White Logo (XL)",
29
"image_url": "https://img.yourdomain.com/skus/xYZkjABcde.png",
30
"discount_breakdown": {
31
"41": {
32
"cents": -900,
33
"weight": 0.416
34
}
35
},
36
"tax_rate": 0.22,
37
"tax_breakdown": {
38
"id": "1234",
39
"city_amount": "0.0",
40
"state_amount": 6.6,
41
"city_tax_rate": 0.0,
42
"county_amount": 2.78,
43
"taxable_amount": 139.0,
44
"county_tax_rate": 0.02,
45
"tax_collectable": 10.08,
46
"special_tax_rate": 0.005,
47
"combined_tax_rate": 0.0725,
48
"city_taxable_amount": 0.0,
49
"state_sales_tax_rate": 0.0475,
50
"state_taxable_amount": 139.0,
51
"county_taxable_amount": 139.0,
52
"special_district_amount": 0.7,
53
"special_district_taxable_amount": 139.0
54
},
55
"item_type": "sku",
56
"created_at": "2018-01-01T12:00:00.000Z",
57
"updated_at": "2018-01-01T12:00:00.000Z",
58
"reference": "ANY-EXTERNAL-REFEFERNCE",
59
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
60
"metadata": {
61
"foo": "bar"
62
}
63
},
64
"relationships": {
65
"order": {
66
"links": {
67
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/order",
68
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/order"
69
}
70
},
71
"item": {
72
"links": {
73
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/item",
74
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/item"
75
}
76
},
77
"line_item_options": {
78
"links": {
79
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/line_item_options",
80
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/line_item_options"
81
}
82
},
83
"shipment_line_items": {
84
"links": {
85
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/shipment_line_items",
86
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/shipment_line_items"
87
}
88
},
89
"stock_line_items": {
90
"links": {
91
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/stock_line_items",
92
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/stock_line_items"
93
}
94
},
95
"stock_transfers": {
96
"links": {
97
"self": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/relationships/stock_transfers",
98
"related": "https://yourdomain.commercelayer.io/api/line_items/xYZkjABcde/stock_transfers"
99
}
100
}
101
},
102
"meta": {
103
"mode": "test"
104
}
105
}
106
}
Copied!
Last modified 25d ago
Copy link