> For the complete documentation index, see [llms.txt](https://docs.getsphere.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getsphere.com/features/integrations/api/stripe-integration-api/add-tax-to-a-stripe-invoice.md).

# Add tax to a Stripe invoice

Calculate and write tax to a draft Stripe invoice.

## Add tax to a Stripe invoice

> Calculates tax for a draft Stripe invoice and writes it onto the invoice's line items, replacing the sequence of Stripe calls you would otherwise make yourself. Hold the draft (auto\_advance: false) before calling, and finalize it once this returns. Safe to retry: an invoice that already carries the same calculation comes back as unchanged. While tax calculation is turned off for the connection, the call returns no\_tax and removes any tax Sphere already wrote to the draft.

```json
{"openapi":"3.1.0","info":{"title":"Sphere API","version":"1.0.0"},"servers":[{"url":"https://api.getsphere.com/v1"},{"url":"https://server.getsphere.com/tax_api/v1"}],"security":[{"apiKeyAuth":[]}],"components":{"securitySchemes":{"apiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-KEY"}},"schemas":{"CalculateStripeInvoiceTaxRequest":{"additionalProperties":false,"description":"Request body for adding Sphere tax to a Stripe invoice.","properties":{"external_id":{"maxLength":255,"minLength":1,"title":"External Id","type":"string"},"stripe_account_id":{"anyOf":[{"maxLength":255,"minLength":1,"type":"string"},{"type":"null"}],"default":null,"title":"Stripe Account Id"}},"required":["external_id"],"title":"CalculateStripeInvoiceTaxRequest","type":"object"},"StripeInvoiceTaxResponse":{"description":"The outcome of a tax write. Amounts are deliberately absent: the tax is\non the Stripe invoice, and finalizing it returns the updated totals.","properties":{"external_id":{"title":"External Id","type":"string"},"stripe_account_id":{"title":"Stripe Account Id","type":"string"},"status":{"allOf":[{"$ref":"#/components/schemas/StripeInvoiceTaxResponseStatusEnum"}],"title":"Status"},"reason":{"title":"Reason","type":"string"},"calculation_id":{"anyOf":[{"type":"string"},{"type":"null"}],"default":null,"title":"Calculation Id"}},"required":["external_id","stripe_account_id","status","reason"],"title":"StripeInvoiceTaxResponse","type":"object"},"StripeInvoiceTaxResponseStatusEnum":{"enum":["applied","unchanged","no_tax"],"type":"string"}}},"paths":{"/stripe/calculate_invoice_tax":{"post":{"operationId":"stripe_calculate_invoice_tax_create","description":"Calculates tax for a draft Stripe invoice and writes it onto the invoice's line items, replacing the sequence of Stripe calls you would otherwise make yourself. Hold the draft (auto_advance: false) before calling, and finalize it once this returns. Safe to retry: an invoice that already carries the same calculation comes back as unchanged. While tax calculation is turned off for the connection, the call returns no_tax and removes any tax Sphere already wrote to the draft.","summary":"Add tax to a Stripe invoice","tags":["Stripe"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalculateStripeInvoiceTaxRequest"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/CalculateStripeInvoiceTaxRequest"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/CalculateStripeInvoiceTaxRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StripeInvoiceTaxResponse"}}},"description":""},"400":{"description":"Validation error, keyed by the failing field."},"403":{"description":"Missing, invalid, or inactive API key; the key is not on a Stripe connection set up for Sphere tax calculation; or stripe_account_id does not match the key's account."},"404":{"description":"No such invoice on the key's Stripe account."},"409":{"description":"The invoice's current state rules out a tax write — it is no longer a draft, it has Stripe automatic tax or tax rates set, or it has no address to calculate from."},"429":{"description":"Rate limit exceeded. Carries Retry-After and RateLimit-* headers."}}}}}}
```
