Skip to main content
Preview tax calculation for a checkout session before creating the order. This endpoint is called from the hosted checkout page when the buyer enters or updates their billing details.
POST /v1/actions/checkout/preview-tax
Authentication: Store Slug

Request Body

FieldTypeRequiredDescription
checkoutSessionIdstringYesCheckout session ID (cs_ + UUID format)
billingDetailobjectYesBilling details for tax calculation

Billing Detail Object

FieldTypeRequiredDescription
countrystringYesISO 3166-1 alpha-2 country code
isBusinessbooleanYesWhether this is a business purchase
statestringConditionalRequired for US and CA

Example Request

curl -X POST https://waffo-pancake-auth-service.vercel.app/v1/actions/checkout/preview-tax \
  -H "Content-Type: application/json" \
  -H "X-Store-Slug: my-store-abc123" \
  -H "X-Environment: test" \
  -d '{
    "checkoutSessionId": "cs_550e8400-e29b-41d4-a716-446655440000",
    "billingDetail": {
      "country": "US",
      "isBusiness": false,
      "state": "CA"
    }
  }'

Success Response

{
  "data": {
    "subtotal": 2900,
    "taxAmount": 261,
    "total": 3161,
    "taxRate": 0.09
  }
}

Response Fields

FieldTypeDescription
subtotalintegerProduct price in smallest currency unit (e.g. 2900 = $29.00)
taxAmountintegerCalculated tax amount in smallest currency unit
totalintegersubtotal + taxAmount
taxRatenumberApplied tax rate as a decimal (e.g. 0.09 = 9%)

Errors

StatusMessageDescription
400Missing required fieldscheckoutSessionId or billingDetail is missing
400Missing state for US/CAstate is required when country is US or CA
404Session not foundNo checkout session matches the given ID
404Session expiredThe checkout session has expired
All amounts are in the smallest currency unit (cents for USD, yen for JPY). For example, 2900 in USD means $29.00.