Creates a Line Item
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
line_item: {
order_id: '1',
variant_id: '1',
quantity: 2,
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/line_items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "27",
"type": "line_item",
"attributes": {
"quantity": 1,
"price": "10.0",
"created_at": "2022-11-08T19:34:20.312Z",
"updated_at": "2022-11-08T19:34:20.352Z",
"currency": "USD",
"cost_price": "17.0",
"adjustment_total": "0.0",
"additional_tax_total": "0.0",
"promo_total": "0.0",
"included_tax_total": "0.0",
"pre_tax_amount": "10.0",
"taxable_adjustment_total": "0.0",
"non_taxable_adjustment_total": "0.0",
"public_metadata": {},
"private_metadata": {},
"display_discounted_amount": "$10.00",
"display_amount": "$10.00",
"display_final_amount": "$10.00",
"display_subtotal": "$10.00",
"display_pre_tax_amount": "$10.00",
"display_price": "$10.00",
"display_adjustment_total": "$0.00",
"display_additional_tax_total": "$0.00",
"display_promo_total": "$0.00",
"display_total": "$10.00",
"display_included_tax_total": "$0.00"
},
"relationships": {
"order": {
"data": {
"id": "31",
"type": "order"
}
},
"tax_category": {
"data": {
"id": "72",
"type": "tax_category"
}
},
"variant": {
"data": {
"id": "187",
"type": "variant"
}
},
"adjustments": {
"data": []
},
"inventory_units": {
"data": []
},
"digital_links": {
"data": []
}
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Show child attributes
Record created
Show child attributes
Was this page helpful?
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
line_item: {
order_id: '1',
variant_id: '1',
quantity: 2,
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/line_items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "27",
"type": "line_item",
"attributes": {
"quantity": 1,
"price": "10.0",
"created_at": "2022-11-08T19:34:20.312Z",
"updated_at": "2022-11-08T19:34:20.352Z",
"currency": "USD",
"cost_price": "17.0",
"adjustment_total": "0.0",
"additional_tax_total": "0.0",
"promo_total": "0.0",
"included_tax_total": "0.0",
"pre_tax_amount": "10.0",
"taxable_adjustment_total": "0.0",
"non_taxable_adjustment_total": "0.0",
"public_metadata": {},
"private_metadata": {},
"display_discounted_amount": "$10.00",
"display_amount": "$10.00",
"display_final_amount": "$10.00",
"display_subtotal": "$10.00",
"display_pre_tax_amount": "$10.00",
"display_price": "$10.00",
"display_adjustment_total": "$0.00",
"display_additional_tax_total": "$0.00",
"display_promo_total": "$0.00",
"display_total": "$10.00",
"display_included_tax_total": "$0.00"
},
"relationships": {
"order": {
"data": {
"id": "31",
"type": "order"
}
},
"tax_category": {
"data": {
"id": "72",
"type": "tax_category"
}
},
"variant": {
"data": {
"id": "187",
"type": "variant"
}
},
"adjustments": {
"data": []
},
"inventory_units": {
"data": []
},
"digital_links": {
"data": []
}
}
}
}