calculateTax
Requires permission products:tax:read.
Calculates the tax on a base amount for a tax group, specific tax rates or a location, and saves nothing. Requires permission to read tax.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation CalculateTax($input: TaxCalculationInput!) {
calculateTax(input: $input) {
baseAmount
finalAmount
totalTaxAmount
taxBreakdown {
taxCode
taxName
calculationMethod
rate
taxAmount
taxRateId
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CalculateTax($input: TaxCalculationInput!) {\n calculateTax(input: $input) {\n baseAmount\n finalAmount\n totalTaxAmount\n taxBreakdown {\n taxCode\n taxName\n calculationMethod\n rate\n taxAmount\n taxRateId\n }\n }\n}",
"variables": {
"input": {
"baseAmount": 0
}
}
}
EOF
Variables:
{
"input": {
"baseAmount": 0
}
}
Response:
{
"data": {
"calculateTax": {
"baseAmount": 0,
"finalAmount": 0,
"totalTaxAmount": 0,
"taxBreakdown": [
{
"taxCode": "string",
"taxName": "string",
"calculationMethod": "ADDITIVE",
"rate": 0,
"taxAmount": 0,
"taxRateId": "string"
}
]
}
}
}
calculateTax(
input: TaxCalculationInput!
): TaxCalculation!
Arguments
calculateTax.input ● TaxCalculationInput! non-null input
The base amount and what to tax it by: a tax group, tax rates, or a location, with optional product categories and currency.
Type
TaxCalculation object
The tax worked out on an amount.