Skip to main content

Tax calculations

Note

Shopify's Tax Platform is available by invitation only to select tax software companies integrating with Shopify.

This guide covers the HTTP POST requests that Shopify sends to your tax app for tax calculations. These requests are triggered by operations like cart checkouts, order edits that add items or increase quantities, and item exchanges within orders.


Anchor to Tax calculation requestTax calculation request

The tax calculation flow starts when Shopify sends an HTTP POST request to the calculate_taxes_api_endpoint configured in your tax calculation app extension. This request contains cart, customer, and delivery details.

Tax calculation request

Request

POST https://your-tax-app.com/your_calculate_taxes_api_endpoint

Request headers

X-Shopify-Shop-Domain: example.myshopify.com
X-Shopify-Shop-Id: 123456789
X-Shopify-Line-Item-Count: 1
X-Shopify-Request-Id: b1626615b389d34d21602cf8f81a930f
X-Shopify-Hmac-SHA256: base64-encoded-hmac
X-Shopify-API-Version: 2026-04

Request body

{
"idempotent_key": "bbf8e3a2485c1a07c5c964f59e651eb0",
"request": {
"datetime_created_utc": "2022-12-13T05:43:12.000Z",
"tax_included": false,
"currency_code": "CAD",
"session_id": "97e8923d-7fe7-481d-9913-16125bb4641c",
"app": {
"id": "gid://shopify/App/1354745",
"handle": "shopify-draft-orders"
}
},
"shop": {
"billing_address": {
"address1": "62 Royal Mount",
"address2": null,
"city": "Westbury",
"province_code": "MB",
"country_code": "CA",
"zip": "R4K 4A5"
}
},
"cart": {
"buyer_identity": {
"tax_exempt": false,
"customer": {
"id": "593934299",
"exemptions": [],
"metafields": [
{
"namespace": "custom",
"key": "has_prescription",
"type": "boolean",
"value": "true"
}
]

Response body

{
"idempotent_key": "8ec2ef67f35980ea6a7842b122f2549f",
"currency": "CAD",
"delivery_group_taxes": [
{
"id": "05b63f9e002a970b7d05c851aab2d30e",
"tax_lines": [
{
"line_id": "ccebfdf4e2da4ee8c663612ef657ed09",
"tax_id": "fce50938252583cb567a31018db9088e",
"calculated_tax": "21.5774",
"calculated_tax_refundable": "21.5774",
"amount_exempt": "0.0",
"amount_taxable": "165.98",
"amount_non_taxable": "0.0"
},
{
"line_id": "05b63f9e002a970b7d05c851aab2d30e",
"tax_id": "fce50938252583cb567a31018db9088e",
"calculated_tax": "1.3",
"calculated_tax_refundable": "1.3",
"amount_exempt": "0.0",
"amount_taxable": "10.0",
"amount_non_taxable": "0.0"
}
]
}
],
"taxes": [
{
"id": "fce50938252583cb567a31018db9088e",
"title": "HST",
"rate": {
"type": "SALES_TAX",
"structure": "STANDARD",
"amount": "0.13"
},
"source": {
"tax_registration": {
"code": "CA-GST",
"registration_number": "CA4276576354"
},
"tax_authority": {
"code": "CA-GST"
},
"tax_jurisdiction": {
"id": "CA-ON",
"code": "CA-ON",
"type": "PROVINCE",
"name": "ONTARIO"
},
"situs": "DESTINATION"
},
"liability": "Merchant"
}
],
"partner_errors": []
}

HeaderDescription
X-Shopify-Shop-DomainrequiredThe permanent domain of the merchant's shop.
X-Shopify-Shop-IdrequiredThe unique integer ID of the merchant's shop. Can be used to identify which shop is initiating the tax calculation.
X-Shopify-Line-Item-CountrequiredThe total number of line items in the tax calculation request.
X-Shopify-Request-IdrequiredThe unique request ID used to track specific requests for troubleshooting purposes.
X-Shopify-Hmac-SHA256requiredThe token that's generated using the HMAC algorithm with SHA-256. The token is used to hash the request body using the app's secret.
X-Shopify-API-VersionrequiredIndicates the API version of the tax calculation request specified in your tax calculation app extension. If the version is outdated, then it defaults to the oldest supported version (current version - 1 year). If no version is specified, then it defaults to the most current stable version. See API versioning for more information.

AttributeDescriptionType
idempotent_keyrequiredA unique identifier for the tax calculation request. Requests with the same ID are identical to previous requests with that ID.String
requestrequiredMetadata about the tax calculation request. Refer to request hash for more information.Object
shoprequiredInformation about the merchant's shop. Refer to shop hash for more information.Object
cartrequiredContains buyer information, addresses, and delivery groups. Refer to cart hash for more information.Object

AttributeDescriptionType
datetime_created_utcrequiredThe UTC timestamp when the request was created.String (ISO-8601)
tax_includedrequiredIndicates if prices include tax.Boolean
currency_coderequiredThe three-letter ISO 4217 currency code for all monetary values in the request.String
session_idA unique identifier for the session.String
appInformation about the app initiating the request. Refer to app hash for more information.Object

AttributeDescriptionType
idrequiredThe unique identifier for the app.String
handlerequiredThe handle of the app.String

AttributeDescriptionType
billing_addressrequiredThe merchant's billing address. Origin-based states use the merchant's location to determine tax rates instead of the customer's delivery address. For example, if a merchant is located in Austin, Texas (an origin-based state), their Austin address determines the tax rate applied to sales, regardless of where in Texas the customer is located. Refer to address hash for more information.Object

AttributeDescriptionType
buyer_identityInformation about the buyer including customer details and tax exemption status. Refer to buyer identity hash for more information.Object
billing_addressThe billing address for the order. Refer to address hash for more information.Object
delivery_groupsrequiredAn array of delivery groups, each containing items being delivered to the same address with the same delivery method.Array

AttributeDescriptionType
customerCustomer information if the buyer is logged in. Refer to customer hash for more information.Object
purchasing_companyCompany information for B2B transactions. Refer to purchasing company hash for more information.Object
tax_exemptrequiredIndicates if the buyer is tax exempt.Boolean

AttributeDescriptionType
idrequiredThe unique identifier for the customer.String
exemptionsA list of tax exemptions for the customer. Refer to exemption hash for more information.Array
metafieldsCustom metafields associated with the customer, containing merchant-defined attributes that may affect tax calculations (for example, prescription status or tax exemption certificates). Available as of API version 2026-04. Refer to metafield hash and the metafields documentation for more information.Array

AttributeDescriptionType
external_idrequiredThe identifier for the tax exemption type. Refer to the full list of supported tax exemption codes.String

Anchor to [object Object], hashpurchasing_company hash

AttributeDescriptionType
companyrequiredCompany details including ID and VAT number. Refer to company hash for more information.Object
company_locationSpecific company location details if applicable. Refer to company_location hash for more information.Object
exemptionsA list of tax exemptions for the company location. Refer to exemption hash for more information.Array

AttributeDescriptionType
idrequiredThe unique identifier for the company.String
external_idThe external identifier for the company.String
vat_numberThe VAT number of the company.String
metafieldsCustom metafields associated with the company, containing merchant-defined attributes for B2B tax calculations (for example, wholesale status or resale certificates). Available as of API version 2026-04. Refer to metafield hash and the metafields documentation for more information.Array

Anchor to [object Object], hashcompany_location hash

AttributeDescriptionType
idrequiredThe unique identifier for the company location.String
external_idThe external identifier for the company location.String
vat_numberThe VAT number for this company location.String

AttributeDescriptionType
namespacerequiredThe namespace of the metafield (for example, custom or tax_partners).String
keyrequiredThe key of the metafield (for example, has_prescription or tax_code).String
typerequiredThe data type of the metafield value (for example, boolean, single_line_text_field).String
valuerequiredThe value of the metafield, serialized as a string.String

AttributeDescriptionType
address1The first line of the address.String
address2The second line of the address.String
cityThe city name.String
province_codeThe province or state code (2-3 characters).String
country_coderequiredThe country code (2-3 characters).String
zipThe postal or zip code.String

AttributeDescriptionType
idrequiredThe unique identifier for the delivery group.String
selected_delivery_optionrequiredThe delivery option selected for this group. Refer to selected delivery option hash for more information.Object
origin_addressThe origin address for the delivery (e.g., warehouse or store location). Refer to address hash for more information.Object
delivery_addressThe destination address for the delivery. Refer to address hash for more information.Object
cart_linesrequiredAn array of line items in the delivery group.Array

Anchor to [object Object], hashselected_delivery_option hash

AttributeDescriptionType
subtotal_amountrequiredThe subtotal amount for delivery before discounts. Refer to money hash for more information.Object
total_amountrequiredThe total amount for delivery after discounts. Refer to money hash for more information.Object
delivery_method_typerequiredThe type of delivery method. Possible values:
  • LOCAL
  • NONE
  • PICKUP_POINT
  • RETAIL
  • SHIPPING
  • SHIPPING_AND_HANDLING
String

AttributeDescriptionType
idrequiredThe unique identifier for the line item.String
merchandiserequiredThe product or custom item being purchased. Refer to merchandise hash for more information.Object
quantityrequiredThe quantity of the item being purchased.Integer
costrequiredThe cost information for the line item. Refer to cart line cost hash for more information.Object
discount_allocationsAn array of discounts applied to this line item.Array
propertiesCustom name-value pairs on the line item. Tax partner apps configure which property keys they want to receive, up to a maximum of five keys. When a configured key is present on a line item, its value is included in the request. Available as of API version 2026-04.Object

AttributeDescriptionType
amount_per_quantityrequiredThe price per unit of the item. Refer to money hash for more information.Object
amount_per_quantity_setThe price for each unit in both shop and presentment currencies. Available as of API version 2026-01 when the shop has multi-currency enabled. Refer to money bag hash for more information.Object
subtotal_amountrequiredThe subtotal before discounts (quantity × amount_per_quantity). Refer to money hash for more information.Object
subtotal_amount_setThe subtotal before discounts in both shop and presentment currencies. Available as of API version 2026-01 when the shop has multi-currency enabled. Refer to money bag hash for more information.Object
total_amountrequiredThe total after discounts are applied. Refer to money hash for more information.Object
total_amount_setThe total after discounts in both shop and presentment currencies. Available as of API version 2026-01 when the shop has multi-currency enabled. Refer to money bag hash for more information.Object

AttributeDescriptionType
shop_moneyrequiredThe amount in the shop's accounting currency. Refer to money hash for more information.Object
presentment_moneyrequiredThe amount in the customer-facing currency. Refer to money hash for more information.Object

AttributeDescriptionType
amountrequiredThe monetary amount as a decimal string.String
currency_coderequiredThe three-letter ISO 4217 currency code.String

The merchandise hash can be either a product variant or a custom product. Both types share some common attributes but have different structures.

Anchor to Product variant merchandiseProduct variant merchandise
AttributeDescriptionType
__typerequiredThe type of resource. Must be PRODUCT_VARIANT for product variants.String
idrequiredThe unique identifier for the product variant.String
skuThe SKU (stock keeping unit) of the variant.String
productrequiredThe product that this variant belongs to. Refer to product hash for more information.Object
requires_shippingrequiredIndicates whether the item requires shipping.Boolean
weightThe weight of the item.Number
weight_unitThe unit of weight. Possible values: GRAMS, KILOGRAMS, OUNCES, POUNDSString
tax_exemptrequiredIndicates if the product variant is tax exempt.Boolean
metafieldsAn array of metafield data for the variant.Array
Anchor to Custom product merchandiseCustom product merchandise
AttributeDescriptionType
__typerequiredThe type of resource. Must be CUSTOM_PRODUCT for custom products.String
titlerequiredThe title of the custom product.String
is_gift_cardrequiredIndicates whether the item is a gift card.Boolean
requires_shippingIndicates whether the item requires shipping.Boolean
weightThe weight of the item.Number
weight_unitThe unit of weight.String
tax_exemptrequiredIndicates if the custom product is tax exempt.Boolean
AttributeDescriptionType
idrequiredThe unique identifier for the product.String
handlerequiredThe handle (URL slug) of the product.String
is_gift_cardrequiredIndicates whether the product is a gift card.Boolean
metafieldsrequiredAn array of metafield data for the product.Array

AttributeDescriptionType
namespacerequiredA grouping of metafields. Used with the metafield key to find a metafield on a resource and prevent conflicts with other metafields using the same key. Must be 3-255 characters long and contain only alphanumeric characters, hyphens, and underscores.String
keyrequiredThe name of the property. Maximum key size is 30 characters.String
typerequiredThe type of the metafield value. See metafield types for all possible values.String
valuerequiredThe value of the property. Maximum value size is 1000 characters.String

Anchor to [object Object], hashdiscount_allocation hash

AttributeDescriptionType
discounted_amountrequiredThe amount of discount applied to the line item. Refer to money hash for more information.Object

Anchor to Tax calculation responseTax calculation response

AttributeDescriptionType
idempotent_keyrequiredThe unique identifier for the tax calculation request. Must match the idempotent_key from the request.String
currencyrequiredThe three-letter ISO 4217 currency code.String
delivery_group_taxesrequiredAn array of tax calculations for each delivery group.Array
taxesrequiredAn array of unique tax definitions referenced in tax lines.Array
partner_errorsAn array of errors if tax calculation failed.Array

Anchor to [object Object], hashdelivery_group_taxes hash

AttributeDescriptionType
idrequiredThe delivery group ID. Must match the delivery group ID from the request.String
tax_linesrequiredAn array of tax line items for this delivery group.Array

AttributeDescriptionType
line_idrequiredThe cart line ID. Must match the cart line ID from the request.String
tax_idrequiredA reference to a tax definition in the taxes array.String
calculated_taxrequiredThe total tax amount for this line item.String
calculated_tax_refundablerequiredThe refundable portion of the tax (usually same as calculated_tax).String
amount_exemptrequiredThe amount that's exempt from tax.String
amount_taxablerequiredThe amount subject to the tax.String
amount_non_taxablerequiredThe amount not subject to the tax.String

AttributeDescriptionType
idrequiredThe unique identifier for the tax definition.String
titlerequiredThe name for the tax.String
raterequiredThe tax rate information. Refer to tax rate hash for more information.Object
sourcerequiredThe tax source information including jurisdiction. Refer to tax source hash for more information.Object
liabilityIndicates who's responsible for remitting the tax. Possible values are Merchant and Marketplace.String

AttributeDescriptionType
typerequiredThe tax type. Possible values:
  • USE_TAX
  • SALES_TAX
  • EXCISE_TAX
  • FEE
  • VAT
  • UNKNOWN
String
structurerequiredThe way the tax is calculated. Possible values:
  • STANDARD
  • FLAT
  • QUANTITY
String
amountrequiredThe tax rate as decimal (for example, 0.05 for 5%).String

AttributeDescriptionType
tax_jurisdictionrequiredThe jurisdiction information for the tax. Refer to tax jurisdiction hash for more information.Object
tax_registrationThe tax registration details if applicable. Refer to tax_registration hash for more information.Object
tax_authorityThe tax authority information. Refer to tax_authority hash for more information.Object
situsThe tax location basis. Possible values:
  • ORIGIN
  • DESTINATION
  • SHOP
String

Anchor to [object Object], hashtax_registration hash

AttributeDescriptionType
coderequiredA unique code for the tax registration.String
registration_numberrequiredThe tax registration number.String

AttributeDescriptionType
coderequiredThe code for the tax authority to which the taxes would be remitted.String

Anchor to [object Object], hashtax_jurisdiction hash

AttributeDescriptionType
idA unique identifier for the tax jurisdiction.String
codeA unique code to identify the tax jurisdiction. For countries, provinces, and states it would be expected this to be the ISO3166-2 Alpha Code (e.g. CA or US-FL). For counties and cities this should be the alpha code for the state (US-FL) plus a reporting code or FIPS.String
namerequiredThe name of the tax jurisdiction.String
typerequiredType of jurisdiction. Possible values:
  • APO
  • BOROUGH
  • CITY
  • COUNTRY
  • COUNTY
  • DISTRICT
  • FPO
  • LOCAL_IMPROVEMENT_DISTRICT
  • PARISH
  • PROVINCE
  • SPECIAL_PURPOSE_DISTRICT
  • STATE
  • TERRITORY
  • TOWNSHIP
  • TRANSIT_DISTRICT
  • TRADE_BLOCK
String
reporting_codeThe state assigned reporting code for this jurisdiction. This is what will be used by merchants to file taxes for this jurisdiction.String

Shopify must receive an HTTP 2xx response for the tax calculation to be successful. If there are errors with the tax calculation, the app must respond with a partner_errors array in the response that includes a code and message for the error.

This is an example of an expected error response:

{
"idempotent_key": "8ec2ef67f35980ea6a7842b122f2549f",
"currency": "CAD",
"delivery_group_taxes": [],
"taxes": [],
"partner_errors": [
{
"code": "MALFORMED_ADDRESS",
"message": "Address is not valid"
}
]
}

AttributeDescriptionType
coderequiredThe code identifying the class of error. Possible values:
  • MALFORMED_ADDRESS: The address is malformed. For example, it has a non-existent zip code or lacks enough fields to determine the location.
  • BAD_DATA: Field validation failed. Examples include future dates in the creation field or negative money amounts.
  • MALFORMED_PAYLOAD:The request is malformed due to conflicting field relationships. For example, the origin and delivery addresses are in different states, but the delivery method is LOCAL.
String
messagerequiredA description of what happened in this instance. Includes details about the part of the request that was the cause.String

Was this page helpful?