Create a Tax Item

Please note there is a soft limit of 5 unique tax items per cart item at any one time.

post
Create a Tax Item

https://api.moltin.com/v2/carts/:cartID/items/:itemID/taxes
Request
Response
Headers
Authorization
required
string
The Bearer token to grant access to the API
Body Parameters
type
required
string
This represents the type of object being returned
name
optional
string
The name of the tax item
jurisdiction
optional
string
The relevant tax jurisdiction
code
optional
string
A unique tax code in this jurisdiction
rate
required
float
The tax rate represented as a decimal (12.5% -> 0.125)
201: Created
{
"data": {
"id": "003e2458-3415-4fd2-a10c-ed422bfac4bb",
"type": "tax_item",
"name": "Tax Name",
"jurisdiction" : "UK",
"code": "MYTAX01",
"rate": 0.2
}
}
422: Unprocessable Entity
In this example, we skip passing name to fail validation.
{
"errors": [
{
"title": "Failed Validation",
"detail": "The data.name field is required."
}
]
}
cURL
Moltin Request
curl -X POST https://api.moltin.com/v2/carts/:cartID/items/:itemID/taxes \
-H "Content-Type: application/json" \
-H "Authorization: Bearer XXXX" \
-d $'{
"data": {
"type": "tax_item",
"name": "Tax Name",
"jurisdiction" : "UK",
"code": "MYTAX01",
"rate": 0.2
}
}'
const { MoltinClient } = require('@moltin/request')
const client = new MoltinClient({
client_id: 'X',
client_secret: 'X'
})
const reference = 'XXXX'
const itemId = 'XXXX'
const taxItemID = 'XXXX'
client
.post(`carts/${reference}/items/${itemId}/taxes/${taxItemID}`, {
type: "tax_item",
name: "Tax Name",
jurisdiction : "UK",
code: "MYTAX01",
rate: 0.2
})
.then(items => {
// Do something...
})
.catch(console.error)