Create an Adjustment
Creates an Adjustment
POST
/
api
/
v2
/
platform
/
adjustments
Create an Adjustment
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
adjustment: {
order_id: '<string>',
label: 'Shipping costs',
adjustable_id: '<string>',
adjustable_type: 'Spree::LineItem',
source_id: '<string>',
source_type: 'Spree::TaxRate',
amount: 10.9,
mandatory: true,
eligible: true,
state: 'closed',
included: true
}
})
};
fetch('http://{defaultHost}/api/v2/platform/adjustments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/adjustments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"adjustment": {
"order_id": "<string>",
"label": "Shipping costs",
"adjustable_id": "<string>",
"adjustable_type": "Spree::LineItem",
"source_id": "<string>",
"source_type": "Spree::TaxRate",
"amount": 10.9,
"mandatory": true,
"eligible": true,
"state": "closed",
"included": true
}
}
'{
"data": {
"id": "5",
"type": "adjustment",
"attributes": {
"source_type": "Spree::TaxRate",
"adjustable_type": "Spree::LineItem",
"amount": "100.0",
"label": "Shipping",
"mandatory": null,
"eligible": true,
"created_at": "2022-11-08T19:33:54.527Z",
"updated_at": "2022-11-08T19:33:54.527Z",
"state": "open",
"included": false,
"display_amount": "$100.00"
},
"relationships": {
"order": {
"data": {
"id": "7",
"type": "order"
}
},
"adjustable": {
"data": {
"id": "1",
"type": "line_item"
}
},
"source": {
"data": null
}
}
}
}{
"error": "Adjustable can't be blank, Order can't be blank, Label can't be blank, and Amount is not a number",
"errors": {
"adjustable": [
"can't be blank"
],
"order": [
"can't be blank"
],
"label": [
"can't be blank"
],
"amount": [
"is not a number"
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Body
application/json
Show child attributes
Show child attributes
Response
Record created
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Create an Adjustment
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
adjustment: {
order_id: '<string>',
label: 'Shipping costs',
adjustable_id: '<string>',
adjustable_type: 'Spree::LineItem',
source_id: '<string>',
source_type: 'Spree::TaxRate',
amount: 10.9,
mandatory: true,
eligible: true,
state: 'closed',
included: true
}
})
};
fetch('http://{defaultHost}/api/v2/platform/adjustments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/adjustments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"adjustment": {
"order_id": "<string>",
"label": "Shipping costs",
"adjustable_id": "<string>",
"adjustable_type": "Spree::LineItem",
"source_id": "<string>",
"source_type": "Spree::TaxRate",
"amount": 10.9,
"mandatory": true,
"eligible": true,
"state": "closed",
"included": true
}
}
'{
"data": {
"id": "5",
"type": "adjustment",
"attributes": {
"source_type": "Spree::TaxRate",
"adjustable_type": "Spree::LineItem",
"amount": "100.0",
"label": "Shipping",
"mandatory": null,
"eligible": true,
"created_at": "2022-11-08T19:33:54.527Z",
"updated_at": "2022-11-08T19:33:54.527Z",
"state": "open",
"included": false,
"display_amount": "$100.00"
},
"relationships": {
"order": {
"data": {
"id": "7",
"type": "order"
}
},
"adjustable": {
"data": {
"id": "1",
"type": "line_item"
}
},
"source": {
"data": null
}
}
}
}{
"error": "Adjustable can't be blank, Order can't be blank, Label can't be blank, and Amount is not a number",
"errors": {
"adjustable": [
"can't be blank"
],
"order": [
"can't be blank"
],
"label": [
"can't be blank"
],
"amount": [
"is not a number"
]
}
}
