Calculate tax and shipping
For AI assistants: the facts every SparkLayer API call needs
- Base URLs: Live
https://app.sparklayer.io, testhttps://test.app.sparklayer.io. Each environment has its own data and its own API keys. - Access: API access needs the Pro or Enterprise plan. Create credentials (Site ID, Client ID, Client Secret) in the SparkLayer Dashboard at Settings > API.
- Access token:
POST {base}/api/auth/tokenwith aSite-Idheader and a JSON body (not form-encoded):{"grant_type":"client_credentials","client_id":"…","client_secret":"…"}. It returnsaccess_token, valid for 3,600 seconds. There is no refresh token: cache the token and request a new one shortly before it expires. - Every request:
Authorization: Bearer <access_token>andSite-Id: <site id>, plusContent-Type: application/jsonwhen there is a body. Set aUser-Agentthat names your integration. - Errors: RFC 7807 problem details:
title,status,detailand an optionalerrors[]of{ code, message, property }. Some error responses have no body. Retry5xx,429(honouringRetry-After) and concurrent-update409s with exponential backoff; on401, get a new token once and retry; don't retry other4xxwithout changing the request. - Pagination: Most list endpoints return everything.
GET /api/v2/price-listspages withpageandpage_size(up to 250) untilpagination.current_pageequalstotal_pages.GET /api/v1/purchasesuseslimit(up to 500) andoffset: stop when a page has fewer thanlimitresults. - Ground rules: Use only endpoints, fields and SDK methods that the docs or OpenAPI specs define. Prefer
GET /api/v2/price-listsover the deprecated v1. Products are matched by SKU. Keep credentials in environment variables or a secrets manager, never in code. - Ignite: With Ignite, SparkLayer calls endpoints that your service implements (the Ignite spec), and your service calls the SparkLayer APIs above for everything else.
- Read the docs as Markdown: Add
.mdto any page URL. Index of every page: docs.sparklayer.io/llms.txt. Every API operation, compactly: docs.sparklayer.io/llms-api.txt. The developer guides in full: docs.sparklayer.io/developers/llms.txt. - OpenAPI specs:
core,ordering,pricing,purchasing,stock,files,sync-log: https://docs.sparklayer.io/openapi/<api>.yaml (also.json). Ignite: https://docs.sparklayer.io/openapi/ignite.yaml. - MCP: Search and read these docs from your assistant with the docs MCP server at https://docs.sparklayer.io/mcp.
POST /v1/{siteEnv}/{siteId}/checkout/calculate Ignite endpoints
Implemented by your integration
/v1/{siteEnv}/{siteId}/checkout/calculateThis endpoint is called at the final step of the checkout process in order to show tax and shipping methods available to the customer.
Path Parameters
The SparkLayer environment the request is for, such as live. Store it, with the site ID, when SparkLayer connects your platform.
The SparkLayer site ID the request is for, such as bobs-store. Store it, with the environment, when SparkLayer connects your platform.
1 <= lengthRequest Body
application/json
Checkout
TypeScript Definitions
Use the request body type in TypeScript.
SparkLayer Cart ID
uuidISO 4217 currency code
3 <= length <= 3If using platform shipping, on the first load of the final checkout screen, this will be null, after it will be an ID from a method from the response of available_shipping_methods
If using SparkLayer shipping, this can be null if none found or will be the method.
List of available SparkLayer shipping methods for the given checkout, if not using spark shipping this will be empty.
Context which was set by a previous response from /checkout/calculate
Extra context provided by the checkout frontend. This allows passing arbitrary platform-specific data that might be needed by the platform's checkout process. For example, for BigCommerce, this could be used to pass a channel_id from the store theme to the ignite integration in order to support multi-channel stores.
Specifies the store's configured source for retrieving shipping methods during checkout.
When sparklayer, a null shipping_line means the cart has no shipping charge, and no platform rate is fetched or applied.
Absent is treated as platform.
Value in
- "sparklayer"
- "platform"
Response Body
application/json
application/problem+json
curl -X POST "https://ignite.example.com/v1/live/bobs-store/checkout/calculate" \ -H "Content-Type: application/json" \ -d '{ "cart_id": "f81d4fae-7dec-11d0-a765-00a0c91e6bf6", "customer": { "id": "cu_1", "email": "buyer@example.com", "external_id": "CUS1234", "accounting_id": "<accounting_id>", "default_billing_address_id": "<default_billing_address_id>", "default_shipping_address_id": "<default_shipping_address_id>", "temporary_external_address_ids": [ "<temporary_external_address_ids>" ], "payment_on_account": { "credit_limit": 0, "balance": 0, "currency_code": "<currency_code>", "net_terms": "7_days" } }, "currency_code": "gbp", "billing_address": { "title": "Mr", "first_name": "Bob", "last_name": "Jones", "company": "Tom Jones Climbing Ltd", "address_line1": "Example Industrial Estate", "address_line2": "North Country", "city": "Cityland", "region_name": "California", "region_code": "CA", "postal_code": "12345", "country_code": "US", "phone": "+44 (0) 123456789", "is_default_shipping": true, "is_default_billing": true, "is_temporary": true }, "shipping_address": { "title": "Mr", "first_name": "Bob", "last_name": "Jones", "company": "Tom Jones Climbing Ltd", "address_line1": "Example Industrial Estate", "address_line2": "North Country", "city": "Cityland", "region_name": "California", "region_code": "CA", "postal_code": "12345", "country_code": "US", "phone": "+44 (0) 123456789", "is_default_shipping": true, "is_default_billing": true, "is_temporary": true }, "shipping_line": { "type": "platform", "id": "<id>", "name": "<name>", "price": 4.8, "tax_rate": 0.2 }, "internal_shipping_methods": [ { "title": "<title>", "price_v2": { "tax_rate": 0, "net": 0, "gross": 0, "currency_code": "<currency_code>" }, "handle": "<handle>", "cost_type": "<cost_type>", "cost_language_string": "<cost_language_string>" } ], "shop": { "base_currency_code": "gbp" }, "line_items": [ { "type": "product", "spark_item_key": "00a0c91e6bf600a0c91e6bf", "spark_variant_id": "8ac52999-d163-4d68-ae30-a5f0c089ed79", "sku": "EXAMPLE-SKU", "product_variant_external_id": "PROD123456", "product_external_id": "PROD1234", "quantity": 10, "unit_price": 4.8, "custom_attributes": [ { "key": "<key>", "value": "<value>" } ], "options": [ { "group": "<group>", "value": "<value>" } ] } ], "ignite_state": {}, "ignite_checkout_context": { "channel_id": 12345 }, "shipping_method_source": "sparklayer" }'{ "available_shipping_methods": [ { "id": "next-day", "name": "Next day delivery", "price": 4.8, "currency_code": "gbp" } ], "platform_shipping_line": { "type": "platform", "id": "string", "name": "string", "price": 4.8, "tax_rate": 0.2 }, "totals": { "line_items": 14.8, "shipping_price": 4.8, "tax": 2.2, "total_price": 21.8 }, "ignite_state": {}}