Calculate tax
Computes tax for inline line items against your legal entity’s configured tax engine and stores the result, returning an id (with an expiry) you pass when issuing a receipt to pin these exact line items and amounts. Each call creates a new calculation; send an Idempotency-Key header to make a retry return the original calculation instead of a new one. Provide a buyer address (and optional tax ids for reverse-charge / exemption) and per-line canonical tax codes; an omitted code defaults to general business SaaS.
curl --request POST \
--url https://api.alguna.io/tax/calculations \
--header 'Alguna-Version: <alguna-version>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"currency": "USD",
"customer": {
"address": {
"country": "USA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"state": "CA"
},
"first_name": "Jane",
"last_name": "Doe",
"email": "buyer@example.com",
"reference": "<string>",
"tax_ids": [
{
"type": "eu_vat",
"value": "DE123456789"
}
]
},
"line_items": [
{
"amount": "100.00",
"quantity": "1",
"description": "Pro plan",
"reference": "line_1",
"tax_code": "txcd_business_saas"
}
],
"legal_entity_id": "<string>",
"tax_behavior": "exclusive"
}
'import requests
url = "https://api.alguna.io/tax/calculations"
payload = {
"currency": "USD",
"customer": {
"address": {
"country": "USA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"state": "CA"
},
"first_name": "Jane",
"last_name": "Doe",
"email": "buyer@example.com",
"reference": "<string>",
"tax_ids": [
{
"type": "eu_vat",
"value": "DE123456789"
}
]
},
"line_items": [
{
"amount": "100.00",
"quantity": "1",
"description": "Pro plan",
"reference": "line_1",
"tax_code": "txcd_business_saas"
}
],
"legal_entity_id": "<string>",
"tax_behavior": "exclusive"
}
headers = {
"Alguna-Version": "<alguna-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Alguna-Version': '<alguna-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
currency: 'USD',
customer: {
address: {
country: 'USA',
city: 'San Francisco',
line1: '123 Main St',
line2: 'Suite 100',
postal_code: '94105',
state: 'CA'
},
first_name: 'Jane',
last_name: 'Doe',
email: 'buyer@example.com',
reference: '<string>',
tax_ids: [{type: 'eu_vat', value: 'DE123456789'}]
},
line_items: [
{
amount: '100.00',
quantity: '1',
description: 'Pro plan',
reference: 'line_1',
tax_code: 'txcd_business_saas'
}
],
legal_entity_id: '<string>',
tax_behavior: 'exclusive'
})
};
fetch('https://api.alguna.io/tax/calculations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.alguna.io/tax/calculations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'currency' => 'USD',
'customer' => [
'address' => [
'country' => 'USA',
'city' => 'San Francisco',
'line1' => '123 Main St',
'line2' => 'Suite 100',
'postal_code' => '94105',
'state' => 'CA'
],
'first_name' => 'Jane',
'last_name' => 'Doe',
'email' => 'buyer@example.com',
'reference' => '<string>',
'tax_ids' => [
[
'type' => 'eu_vat',
'value' => 'DE123456789'
]
]
],
'line_items' => [
[
'amount' => '100.00',
'quantity' => '1',
'description' => 'Pro plan',
'reference' => 'line_1',
'tax_code' => 'txcd_business_saas'
]
],
'legal_entity_id' => '<string>',
'tax_behavior' => 'exclusive'
]),
CURLOPT_HTTPHEADER => [
"Alguna-Version: <alguna-version>",
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.alguna.io/tax/calculations"
payload := strings.NewReader("{\n \"currency\": \"USD\",\n \"customer\": {\n \"address\": {\n \"country\": \"USA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"state\": \"CA\"\n },\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"email\": \"buyer@example.com\",\n \"reference\": \"<string>\",\n \"tax_ids\": [\n {\n \"type\": \"eu_vat\",\n \"value\": \"DE123456789\"\n }\n ]\n },\n \"line_items\": [\n {\n \"amount\": \"100.00\",\n \"quantity\": \"1\",\n \"description\": \"Pro plan\",\n \"reference\": \"line_1\",\n \"tax_code\": \"txcd_business_saas\"\n }\n ],\n \"legal_entity_id\": \"<string>\",\n \"tax_behavior\": \"exclusive\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Alguna-Version", "<alguna-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.alguna.io/tax/calculations")
.header("Alguna-Version", "<alguna-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"currency\": \"USD\",\n \"customer\": {\n \"address\": {\n \"country\": \"USA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"state\": \"CA\"\n },\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"email\": \"buyer@example.com\",\n \"reference\": \"<string>\",\n \"tax_ids\": [\n {\n \"type\": \"eu_vat\",\n \"value\": \"DE123456789\"\n }\n ]\n },\n \"line_items\": [\n {\n \"amount\": \"100.00\",\n \"quantity\": \"1\",\n \"description\": \"Pro plan\",\n \"reference\": \"line_1\",\n \"tax_code\": \"txcd_business_saas\"\n }\n ],\n \"legal_entity_id\": \"<string>\",\n \"tax_behavior\": \"exclusive\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.alguna.io/tax/calculations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Alguna-Version"] = '<alguna-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"currency\": \"USD\",\n \"customer\": {\n \"address\": {\n \"country\": \"USA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"state\": \"CA\"\n },\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"email\": \"buyer@example.com\",\n \"reference\": \"<string>\",\n \"tax_ids\": [\n {\n \"type\": \"eu_vat\",\n \"value\": \"DE123456789\"\n }\n ]\n },\n \"line_items\": [\n {\n \"amount\": \"100.00\",\n \"quantity\": \"1\",\n \"description\": \"Pro plan\",\n \"reference\": \"line_1\",\n \"tax_code\": \"txcd_business_saas\"\n }\n ],\n \"legal_entity_id\": \"<string>\",\n \"tax_behavior\": \"exclusive\"\n}"
response = http.request(request)
puts response.read_body{
"currency": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"line_items": [
{
"tax_amount": "<string>",
"tax_rate": "<string>",
"reference": "<string>",
"tax_reason": "<string>",
"tax_type": "<string>"
}
],
"total_tax": "<string>"
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}Authorizations
API key authentication. Pass your API key as a Bearer token.
Headers
2026-04-01 A unique string used to ensure the request is processed exactly once. If you retry a request with the same idempotency key within 24 hours, the original response is returned without re-executing the operation.
255"ik_a1b2c3d4e5f6"
Body
ISO 4217 currency code
"USD"
Who is being taxed
Show child attributes
Show child attributes
Line items to tax
Show child attributes
Show child attributes
Selling legal entity; defaults to the org's default when omitted
Whether line amounts exclude (default) or already include tax
exclusive, inclusive "exclusive"
Response
Success
Currency of the amounts
When the calculation stops being issuable
Id of the persisted calculation; pass it when issuing a receipt to pin these results
Per-line tax breakdown
Show child attributes
Show child attributes
Sum of per-line tax amounts
curl --request POST \
--url https://api.alguna.io/tax/calculations \
--header 'Alguna-Version: <alguna-version>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"currency": "USD",
"customer": {
"address": {
"country": "USA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"state": "CA"
},
"first_name": "Jane",
"last_name": "Doe",
"email": "buyer@example.com",
"reference": "<string>",
"tax_ids": [
{
"type": "eu_vat",
"value": "DE123456789"
}
]
},
"line_items": [
{
"amount": "100.00",
"quantity": "1",
"description": "Pro plan",
"reference": "line_1",
"tax_code": "txcd_business_saas"
}
],
"legal_entity_id": "<string>",
"tax_behavior": "exclusive"
}
'import requests
url = "https://api.alguna.io/tax/calculations"
payload = {
"currency": "USD",
"customer": {
"address": {
"country": "USA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"state": "CA"
},
"first_name": "Jane",
"last_name": "Doe",
"email": "buyer@example.com",
"reference": "<string>",
"tax_ids": [
{
"type": "eu_vat",
"value": "DE123456789"
}
]
},
"line_items": [
{
"amount": "100.00",
"quantity": "1",
"description": "Pro plan",
"reference": "line_1",
"tax_code": "txcd_business_saas"
}
],
"legal_entity_id": "<string>",
"tax_behavior": "exclusive"
}
headers = {
"Alguna-Version": "<alguna-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Alguna-Version': '<alguna-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
currency: 'USD',
customer: {
address: {
country: 'USA',
city: 'San Francisco',
line1: '123 Main St',
line2: 'Suite 100',
postal_code: '94105',
state: 'CA'
},
first_name: 'Jane',
last_name: 'Doe',
email: 'buyer@example.com',
reference: '<string>',
tax_ids: [{type: 'eu_vat', value: 'DE123456789'}]
},
line_items: [
{
amount: '100.00',
quantity: '1',
description: 'Pro plan',
reference: 'line_1',
tax_code: 'txcd_business_saas'
}
],
legal_entity_id: '<string>',
tax_behavior: 'exclusive'
})
};
fetch('https://api.alguna.io/tax/calculations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.alguna.io/tax/calculations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'currency' => 'USD',
'customer' => [
'address' => [
'country' => 'USA',
'city' => 'San Francisco',
'line1' => '123 Main St',
'line2' => 'Suite 100',
'postal_code' => '94105',
'state' => 'CA'
],
'first_name' => 'Jane',
'last_name' => 'Doe',
'email' => 'buyer@example.com',
'reference' => '<string>',
'tax_ids' => [
[
'type' => 'eu_vat',
'value' => 'DE123456789'
]
]
],
'line_items' => [
[
'amount' => '100.00',
'quantity' => '1',
'description' => 'Pro plan',
'reference' => 'line_1',
'tax_code' => 'txcd_business_saas'
]
],
'legal_entity_id' => '<string>',
'tax_behavior' => 'exclusive'
]),
CURLOPT_HTTPHEADER => [
"Alguna-Version: <alguna-version>",
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.alguna.io/tax/calculations"
payload := strings.NewReader("{\n \"currency\": \"USD\",\n \"customer\": {\n \"address\": {\n \"country\": \"USA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"state\": \"CA\"\n },\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"email\": \"buyer@example.com\",\n \"reference\": \"<string>\",\n \"tax_ids\": [\n {\n \"type\": \"eu_vat\",\n \"value\": \"DE123456789\"\n }\n ]\n },\n \"line_items\": [\n {\n \"amount\": \"100.00\",\n \"quantity\": \"1\",\n \"description\": \"Pro plan\",\n \"reference\": \"line_1\",\n \"tax_code\": \"txcd_business_saas\"\n }\n ],\n \"legal_entity_id\": \"<string>\",\n \"tax_behavior\": \"exclusive\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Alguna-Version", "<alguna-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.alguna.io/tax/calculations")
.header("Alguna-Version", "<alguna-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"currency\": \"USD\",\n \"customer\": {\n \"address\": {\n \"country\": \"USA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"state\": \"CA\"\n },\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"email\": \"buyer@example.com\",\n \"reference\": \"<string>\",\n \"tax_ids\": [\n {\n \"type\": \"eu_vat\",\n \"value\": \"DE123456789\"\n }\n ]\n },\n \"line_items\": [\n {\n \"amount\": \"100.00\",\n \"quantity\": \"1\",\n \"description\": \"Pro plan\",\n \"reference\": \"line_1\",\n \"tax_code\": \"txcd_business_saas\"\n }\n ],\n \"legal_entity_id\": \"<string>\",\n \"tax_behavior\": \"exclusive\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.alguna.io/tax/calculations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Alguna-Version"] = '<alguna-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"currency\": \"USD\",\n \"customer\": {\n \"address\": {\n \"country\": \"USA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"state\": \"CA\"\n },\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"email\": \"buyer@example.com\",\n \"reference\": \"<string>\",\n \"tax_ids\": [\n {\n \"type\": \"eu_vat\",\n \"value\": \"DE123456789\"\n }\n ]\n },\n \"line_items\": [\n {\n \"amount\": \"100.00\",\n \"quantity\": \"1\",\n \"description\": \"Pro plan\",\n \"reference\": \"line_1\",\n \"tax_code\": \"txcd_business_saas\"\n }\n ],\n \"legal_entity_id\": \"<string>\",\n \"tax_behavior\": \"exclusive\"\n}"
response = http.request(request)
puts response.read_body{
"currency": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"line_items": [
{
"tax_amount": "<string>",
"tax_rate": "<string>",
"reference": "<string>",
"tax_reason": "<string>",
"tax_type": "<string>"
}
],
"total_tax": "<string>"
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}{
"detail": "<string>",
"status": 123
}