Update a Tax Rate
Updates a Tax Rate
PATCH
/
api
/
v2
/
platform
/
tax_rates
/
{id}
Update a Tax Rate
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tax_rate: {
amount: 0.05,
tax_category_id: '1',
calculator_attributes: {type: 'Spree::Calculator::FlatRate', preferences: {amount: 0, currency: 'USD'}},
zone_id: '2',
included_in_price: true,
name: 'California',
show_rate_in_label: false
}
})
};
fetch('http://{defaultHost}/api/v2/platform/tax_rates/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request PATCH \
--url http://{defaultHost}/api/v2/platform/tax_rates/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tax_rate": {
"amount": 0.05,
"tax_category_id": "1",
"calculator_attributes": {
"type": "Spree::Calculator::FlatRate",
"preferences": {
"amount": 0,
"currency": "USD"
}
},
"zone_id": "2",
"included_in_price": true,
"name": "California",
"show_rate_in_label": false
}
}
'{
"data": {
"id": "19",
"type": "tax_rate",
"attributes": {
"amount": "25.9",
"included_in_price": true,
"created_at": "2022-11-08T19:35:45.406Z",
"updated_at": "2022-11-08T19:35:45.637Z",
"name": "TaxRate - 33807",
"show_rate_in_label": true,
"deleted_at": null,
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"zone": {
"data": {
"id": "106",
"type": "zone"
}
},
"tax_category": {
"data": {
"id": "170",
"type": "tax_category"
}
}
}
}
}{
"error": "The access token is invalid"
}{
"error": "The resource you were looking for could not be found."
}{
"error": "Rate can't be blank",
"errors": {
"amount": [
"can't be blank"
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
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 updated
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Update a Tax Rate
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tax_rate: {
amount: 0.05,
tax_category_id: '1',
calculator_attributes: {type: 'Spree::Calculator::FlatRate', preferences: {amount: 0, currency: 'USD'}},
zone_id: '2',
included_in_price: true,
name: 'California',
show_rate_in_label: false
}
})
};
fetch('http://{defaultHost}/api/v2/platform/tax_rates/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request PATCH \
--url http://{defaultHost}/api/v2/platform/tax_rates/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tax_rate": {
"amount": 0.05,
"tax_category_id": "1",
"calculator_attributes": {
"type": "Spree::Calculator::FlatRate",
"preferences": {
"amount": 0,
"currency": "USD"
}
},
"zone_id": "2",
"included_in_price": true,
"name": "California",
"show_rate_in_label": false
}
}
'{
"data": {
"id": "19",
"type": "tax_rate",
"attributes": {
"amount": "25.9",
"included_in_price": true,
"created_at": "2022-11-08T19:35:45.406Z",
"updated_at": "2022-11-08T19:35:45.637Z",
"name": "TaxRate - 33807",
"show_rate_in_label": true,
"deleted_at": null,
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"zone": {
"data": {
"id": "106",
"type": "zone"
}
},
"tax_category": {
"data": {
"id": "170",
"type": "tax_category"
}
}
}
}
}{
"error": "The access token is invalid"
}{
"error": "The resource you were looking for could not be found."
}{
"error": "Rate can't be blank",
"errors": {
"amount": [
"can't be blank"
]
}
}
