curl --request POST \
--url https://api.dualentry.com/public/v3-alpha/taxes/calculate/ \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"company_id": 1,
"customer_id": 1,
"vendor_id": null,
"record_type": "invoice",
"credit_source": {
"record_id": 1,
"record_type": "invoice"
},
"transaction_buyer_address": {
"city": "San Francisco",
"country": "US",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"region": "CA"
},
"transaction_ship_from_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_ship_to_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_date": "2025-08-29",
"supply_date": "2025-08-29",
"items": [
{
"discount_type": "PERCENTAGE",
"discount_value": "10.00",
"item_id": -1,
"quantity": "1.000000",
"unit_price": "100.000000"
},
{
"item_id": -2,
"quantity": "2.000000",
"record_level_discount_amount": "5.00",
"selected_vat_rate_id": 1,
"unit_price": "50.000000"
}
],
"currency_code": "USD"
}
'import requests
url = "https://api.dualentry.com/public/v3-alpha/taxes/calculate/"
payload = {
"company_id": 1,
"customer_id": 1,
"vendor_id": None,
"record_type": "invoice",
"credit_source": {
"record_id": 1,
"record_type": "invoice"
},
"transaction_buyer_address": {
"city": "San Francisco",
"country": "US",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"region": "CA"
},
"transaction_ship_from_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_ship_to_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_date": "2025-08-29",
"supply_date": "2025-08-29",
"items": [
{
"discount_type": "PERCENTAGE",
"discount_value": "10.00",
"item_id": -1,
"quantity": "1.000000",
"unit_price": "100.000000"
},
{
"item_id": -2,
"quantity": "2.000000",
"record_level_discount_amount": "5.00",
"selected_vat_rate_id": 1,
"unit_price": "50.000000"
}
],
"currency_code": "USD"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
company_id: 1,
customer_id: 1,
vendor_id: null,
record_type: 'invoice',
credit_source: {record_id: 1, record_type: 'invoice'},
transaction_buyer_address: {
city: 'San Francisco',
country: 'US',
line1: '123 Main St',
line2: 'Suite 100',
postal_code: '94105',
region: 'CA'
},
transaction_ship_from_address: {
country: 'US',
postal_code: '94105',
region: 'CA',
city: 'San Francisco',
line1: '123 Main St',
line2: 'Suite 100'
},
transaction_ship_to_address: {
country: 'US',
postal_code: '94105',
region: 'CA',
city: 'San Francisco',
line1: '123 Main St',
line2: 'Suite 100'
},
transaction_date: '2025-08-29',
supply_date: '2025-08-29',
items: [
{
discount_type: 'PERCENTAGE',
discount_value: '10.00',
item_id: -1,
quantity: '1.000000',
unit_price: '100.000000'
},
{
item_id: -2,
quantity: '2.000000',
record_level_discount_amount: '5.00',
selected_vat_rate_id: 1,
unit_price: '50.000000'
}
],
currency_code: 'USD'
})
};
fetch('https://api.dualentry.com/public/v3-alpha/taxes/calculate/', 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.dualentry.com/public/v3-alpha/taxes/calculate/",
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([
'company_id' => 1,
'customer_id' => 1,
'vendor_id' => null,
'record_type' => 'invoice',
'credit_source' => [
'record_id' => 1,
'record_type' => 'invoice'
],
'transaction_buyer_address' => [
'city' => 'San Francisco',
'country' => 'US',
'line1' => '123 Main St',
'line2' => 'Suite 100',
'postal_code' => '94105',
'region' => 'CA'
],
'transaction_ship_from_address' => [
'country' => 'US',
'postal_code' => '94105',
'region' => 'CA',
'city' => 'San Francisco',
'line1' => '123 Main St',
'line2' => 'Suite 100'
],
'transaction_ship_to_address' => [
'country' => 'US',
'postal_code' => '94105',
'region' => 'CA',
'city' => 'San Francisco',
'line1' => '123 Main St',
'line2' => 'Suite 100'
],
'transaction_date' => '2025-08-29',
'supply_date' => '2025-08-29',
'items' => [
[
'discount_type' => 'PERCENTAGE',
'discount_value' => '10.00',
'item_id' => -1,
'quantity' => '1.000000',
'unit_price' => '100.000000'
],
[
'item_id' => -2,
'quantity' => '2.000000',
'record_level_discount_amount' => '5.00',
'selected_vat_rate_id' => 1,
'unit_price' => '50.000000'
]
],
'currency_code' => 'USD'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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.dualentry.com/public/v3-alpha/taxes/calculate/"
payload := strings.NewReader("{\n \"company_id\": 1,\n \"customer_id\": 1,\n \"vendor_id\": null,\n \"record_type\": \"invoice\",\n \"credit_source\": {\n \"record_id\": 1,\n \"record_type\": \"invoice\"\n },\n \"transaction_buyer_address\": {\n \"city\": \"San Francisco\",\n \"country\": \"US\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\"\n },\n \"transaction_ship_from_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_ship_to_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_date\": \"2025-08-29\",\n \"supply_date\": \"2025-08-29\",\n \"items\": [\n {\n \"discount_type\": \"PERCENTAGE\",\n \"discount_value\": \"10.00\",\n \"item_id\": -1,\n \"quantity\": \"1.000000\",\n \"unit_price\": \"100.000000\"\n },\n {\n \"item_id\": -2,\n \"quantity\": \"2.000000\",\n \"record_level_discount_amount\": \"5.00\",\n \"selected_vat_rate_id\": 1,\n \"unit_price\": \"50.000000\"\n }\n ],\n \"currency_code\": \"USD\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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.dualentry.com/public/v3-alpha/taxes/calculate/")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"company_id\": 1,\n \"customer_id\": 1,\n \"vendor_id\": null,\n \"record_type\": \"invoice\",\n \"credit_source\": {\n \"record_id\": 1,\n \"record_type\": \"invoice\"\n },\n \"transaction_buyer_address\": {\n \"city\": \"San Francisco\",\n \"country\": \"US\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\"\n },\n \"transaction_ship_from_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_ship_to_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_date\": \"2025-08-29\",\n \"supply_date\": \"2025-08-29\",\n \"items\": [\n {\n \"discount_type\": \"PERCENTAGE\",\n \"discount_value\": \"10.00\",\n \"item_id\": -1,\n \"quantity\": \"1.000000\",\n \"unit_price\": \"100.000000\"\n },\n {\n \"item_id\": -2,\n \"quantity\": \"2.000000\",\n \"record_level_discount_amount\": \"5.00\",\n \"selected_vat_rate_id\": 1,\n \"unit_price\": \"50.000000\"\n }\n ],\n \"currency_code\": \"USD\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dualentry.com/public/v3-alpha/taxes/calculate/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"company_id\": 1,\n \"customer_id\": 1,\n \"vendor_id\": null,\n \"record_type\": \"invoice\",\n \"credit_source\": {\n \"record_id\": 1,\n \"record_type\": \"invoice\"\n },\n \"transaction_buyer_address\": {\n \"city\": \"San Francisco\",\n \"country\": \"US\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\"\n },\n \"transaction_ship_from_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_ship_to_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_date\": \"2025-08-29\",\n \"supply_date\": \"2025-08-29\",\n \"items\": [\n {\n \"discount_type\": \"PERCENTAGE\",\n \"discount_value\": \"10.00\",\n \"item_id\": -1,\n \"quantity\": \"1.000000\",\n \"unit_price\": \"100.000000\"\n },\n {\n \"item_id\": -2,\n \"quantity\": \"2.000000\",\n \"record_level_discount_amount\": \"5.00\",\n \"selected_vat_rate_id\": 1,\n \"unit_price\": \"50.000000\"\n }\n ],\n \"currency_code\": \"USD\"\n}"
response = http.request(request)
puts response.read_body{
"type": "SALES_TAX",
"data": {
"items": [
{
"product_tax_code": "<string>",
"tax_code": "<string>",
"tax_rate": "0.2000",
"tax_amount": "20",
"amount_with_tax": "120",
"item_id": 123,
"provider_tax_code": "<string>",
"is_taxable": true,
"tax_exempt_amount": "0",
"tax_metadata": {},
"post_to_gl": [
{
"account_id": 123,
"name": "<string>",
"number": 123,
"role": "asset"
}
]
}
],
"total_tax_amount": "20",
"total_with_tax": "120",
"tax_applicable": true,
"nexus_detected": true,
"destination": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"tax_rate_for_destination": "0.2000",
"calculation_source": "<string>",
"tax_metadata": {}
}
}{
"errors": {},
"success": false
}{
"errors": {},
"success": false
}{
"errors": {},
"success": false
}Calculate tax
Calculate tax for a transaction before you create it.
This is the same calculator the DualEntry UI uses. Public invoice create does not
calculate tax. Call this endpoint first, copy the result onto each line tax
object, then POST the invoice (or bill).
Required:
company_idcustomer_id(money-in) orvendor_id(money-out), not both
Usually also send:
itemswithitem_id,quantity, andunit_pricetransaction_buyer_addressfor US sales tax (destination / shipping address)transaction_dateandcurrency_codefor US sales taxsupply_dateto filter VAT/GST rates by validity
The response type is SALES_TAX, VAT, GST, or NONE. NONE is HTTP 200
with a reason (for example a missing buyer address). It is not an error.
Map each result line onto invoice items[].tax:
tax_code→tax.codetax_rate→tax.ratetax_amount→tax.amountis_taxable→tax.is_taxabletax_exempt_amount→tax.tax_exempt_amounttax_metadata→tax.tax_metadataselected_vat_rate_id→tax.vat_rate_idselected_gst_tax_rate_id→tax.gst_tax_rate_id
For Canada GST and VAT, the first call returns available_rates. Pick a rate,
send selected_gst_tax_rate_id or selected_vat_rate_id on the line, calculate
again, then create the invoice.
A shipping address on the invoice payload does not trigger tax. Pass that
address as transaction_buyer_address on this calculate call.
V2 API only.
curl --request POST \
--url https://api.dualentry.com/public/v3-alpha/taxes/calculate/ \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"company_id": 1,
"customer_id": 1,
"vendor_id": null,
"record_type": "invoice",
"credit_source": {
"record_id": 1,
"record_type": "invoice"
},
"transaction_buyer_address": {
"city": "San Francisco",
"country": "US",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"region": "CA"
},
"transaction_ship_from_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_ship_to_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_date": "2025-08-29",
"supply_date": "2025-08-29",
"items": [
{
"discount_type": "PERCENTAGE",
"discount_value": "10.00",
"item_id": -1,
"quantity": "1.000000",
"unit_price": "100.000000"
},
{
"item_id": -2,
"quantity": "2.000000",
"record_level_discount_amount": "5.00",
"selected_vat_rate_id": 1,
"unit_price": "50.000000"
}
],
"currency_code": "USD"
}
'import requests
url = "https://api.dualentry.com/public/v3-alpha/taxes/calculate/"
payload = {
"company_id": 1,
"customer_id": 1,
"vendor_id": None,
"record_type": "invoice",
"credit_source": {
"record_id": 1,
"record_type": "invoice"
},
"transaction_buyer_address": {
"city": "San Francisco",
"country": "US",
"line1": "123 Main St",
"line2": "Suite 100",
"postal_code": "94105",
"region": "CA"
},
"transaction_ship_from_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_ship_to_address": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"transaction_date": "2025-08-29",
"supply_date": "2025-08-29",
"items": [
{
"discount_type": "PERCENTAGE",
"discount_value": "10.00",
"item_id": -1,
"quantity": "1.000000",
"unit_price": "100.000000"
},
{
"item_id": -2,
"quantity": "2.000000",
"record_level_discount_amount": "5.00",
"selected_vat_rate_id": 1,
"unit_price": "50.000000"
}
],
"currency_code": "USD"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
company_id: 1,
customer_id: 1,
vendor_id: null,
record_type: 'invoice',
credit_source: {record_id: 1, record_type: 'invoice'},
transaction_buyer_address: {
city: 'San Francisco',
country: 'US',
line1: '123 Main St',
line2: 'Suite 100',
postal_code: '94105',
region: 'CA'
},
transaction_ship_from_address: {
country: 'US',
postal_code: '94105',
region: 'CA',
city: 'San Francisco',
line1: '123 Main St',
line2: 'Suite 100'
},
transaction_ship_to_address: {
country: 'US',
postal_code: '94105',
region: 'CA',
city: 'San Francisco',
line1: '123 Main St',
line2: 'Suite 100'
},
transaction_date: '2025-08-29',
supply_date: '2025-08-29',
items: [
{
discount_type: 'PERCENTAGE',
discount_value: '10.00',
item_id: -1,
quantity: '1.000000',
unit_price: '100.000000'
},
{
item_id: -2,
quantity: '2.000000',
record_level_discount_amount: '5.00',
selected_vat_rate_id: 1,
unit_price: '50.000000'
}
],
currency_code: 'USD'
})
};
fetch('https://api.dualentry.com/public/v3-alpha/taxes/calculate/', 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.dualentry.com/public/v3-alpha/taxes/calculate/",
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([
'company_id' => 1,
'customer_id' => 1,
'vendor_id' => null,
'record_type' => 'invoice',
'credit_source' => [
'record_id' => 1,
'record_type' => 'invoice'
],
'transaction_buyer_address' => [
'city' => 'San Francisco',
'country' => 'US',
'line1' => '123 Main St',
'line2' => 'Suite 100',
'postal_code' => '94105',
'region' => 'CA'
],
'transaction_ship_from_address' => [
'country' => 'US',
'postal_code' => '94105',
'region' => 'CA',
'city' => 'San Francisco',
'line1' => '123 Main St',
'line2' => 'Suite 100'
],
'transaction_ship_to_address' => [
'country' => 'US',
'postal_code' => '94105',
'region' => 'CA',
'city' => 'San Francisco',
'line1' => '123 Main St',
'line2' => 'Suite 100'
],
'transaction_date' => '2025-08-29',
'supply_date' => '2025-08-29',
'items' => [
[
'discount_type' => 'PERCENTAGE',
'discount_value' => '10.00',
'item_id' => -1,
'quantity' => '1.000000',
'unit_price' => '100.000000'
],
[
'item_id' => -2,
'quantity' => '2.000000',
'record_level_discount_amount' => '5.00',
'selected_vat_rate_id' => 1,
'unit_price' => '50.000000'
]
],
'currency_code' => 'USD'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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.dualentry.com/public/v3-alpha/taxes/calculate/"
payload := strings.NewReader("{\n \"company_id\": 1,\n \"customer_id\": 1,\n \"vendor_id\": null,\n \"record_type\": \"invoice\",\n \"credit_source\": {\n \"record_id\": 1,\n \"record_type\": \"invoice\"\n },\n \"transaction_buyer_address\": {\n \"city\": \"San Francisco\",\n \"country\": \"US\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\"\n },\n \"transaction_ship_from_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_ship_to_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_date\": \"2025-08-29\",\n \"supply_date\": \"2025-08-29\",\n \"items\": [\n {\n \"discount_type\": \"PERCENTAGE\",\n \"discount_value\": \"10.00\",\n \"item_id\": -1,\n \"quantity\": \"1.000000\",\n \"unit_price\": \"100.000000\"\n },\n {\n \"item_id\": -2,\n \"quantity\": \"2.000000\",\n \"record_level_discount_amount\": \"5.00\",\n \"selected_vat_rate_id\": 1,\n \"unit_price\": \"50.000000\"\n }\n ],\n \"currency_code\": \"USD\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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.dualentry.com/public/v3-alpha/taxes/calculate/")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"company_id\": 1,\n \"customer_id\": 1,\n \"vendor_id\": null,\n \"record_type\": \"invoice\",\n \"credit_source\": {\n \"record_id\": 1,\n \"record_type\": \"invoice\"\n },\n \"transaction_buyer_address\": {\n \"city\": \"San Francisco\",\n \"country\": \"US\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\"\n },\n \"transaction_ship_from_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_ship_to_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_date\": \"2025-08-29\",\n \"supply_date\": \"2025-08-29\",\n \"items\": [\n {\n \"discount_type\": \"PERCENTAGE\",\n \"discount_value\": \"10.00\",\n \"item_id\": -1,\n \"quantity\": \"1.000000\",\n \"unit_price\": \"100.000000\"\n },\n {\n \"item_id\": -2,\n \"quantity\": \"2.000000\",\n \"record_level_discount_amount\": \"5.00\",\n \"selected_vat_rate_id\": 1,\n \"unit_price\": \"50.000000\"\n }\n ],\n \"currency_code\": \"USD\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dualentry.com/public/v3-alpha/taxes/calculate/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"company_id\": 1,\n \"customer_id\": 1,\n \"vendor_id\": null,\n \"record_type\": \"invoice\",\n \"credit_source\": {\n \"record_id\": 1,\n \"record_type\": \"invoice\"\n },\n \"transaction_buyer_address\": {\n \"city\": \"San Francisco\",\n \"country\": \"US\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\"\n },\n \"transaction_ship_from_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_ship_to_address\": {\n \"country\": \"US\",\n \"postal_code\": \"94105\",\n \"region\": \"CA\",\n \"city\": \"San Francisco\",\n \"line1\": \"123 Main St\",\n \"line2\": \"Suite 100\"\n },\n \"transaction_date\": \"2025-08-29\",\n \"supply_date\": \"2025-08-29\",\n \"items\": [\n {\n \"discount_type\": \"PERCENTAGE\",\n \"discount_value\": \"10.00\",\n \"item_id\": -1,\n \"quantity\": \"1.000000\",\n \"unit_price\": \"100.000000\"\n },\n {\n \"item_id\": -2,\n \"quantity\": \"2.000000\",\n \"record_level_discount_amount\": \"5.00\",\n \"selected_vat_rate_id\": 1,\n \"unit_price\": \"50.000000\"\n }\n ],\n \"currency_code\": \"USD\"\n}"
response = http.request(request)
puts response.read_body{
"type": "SALES_TAX",
"data": {
"items": [
{
"product_tax_code": "<string>",
"tax_code": "<string>",
"tax_rate": "0.2000",
"tax_amount": "20",
"amount_with_tax": "120",
"item_id": 123,
"provider_tax_code": "<string>",
"is_taxable": true,
"tax_exempt_amount": "0",
"tax_metadata": {},
"post_to_gl": [
{
"account_id": 123,
"name": "<string>",
"number": 123,
"role": "asset"
}
]
}
],
"total_tax_amount": "20",
"total_with_tax": "120",
"tax_applicable": true,
"nexus_detected": true,
"destination": {
"country": "US",
"postal_code": "94105",
"region": "CA",
"city": "San Francisco",
"line1": "123 Main St",
"line2": "Suite 100"
},
"tax_rate_for_destination": "0.2000",
"calculation_source": "<string>",
"tax_metadata": {}
}
}{
"errors": {},
"success": false
}{
"errors": {},
"success": false
}{
"errors": {},
"success": false
}Authorizations
Headers
Optional. A unique value (a UUID works well) identifying this operation. If the request is repeated with the same key, the original response is replayed instead of the operation running again, so a retry cannot create a duplicate record. Results are replayable for 48 hours. Reusing a key with a different request body returns 422.
255Body
Company ID
1
Customer ID (money-in records)
1
Vendor ID (money-out records)
null
Optional taxable record type. Customer/vendor credits use ReturnOrder estimates.
invoice, cash_sale, customer_credit, sales_order, bill, direct_expense, vendor_credit, purchase_order "invoice"
Optional linked source for customer/vendor credits. Used to pin AvaTax taxOverride.taxDate to the original sale/purchase.
Show child attributes
Show child attributes
{ "record_id": 1, "record_type": "invoice" }
Buyer address on the transaction — required for sales tax, ignored for VAT
Show child attributes
Show child attributes
{ "city": "San Francisco", "country": "US", "line1": "123 Main St", "line2": "Suite 100", "postal_code": "94105", "region": "CA" }
Vendor shipment origin for money-out records. Overrides the vendor default address in tax preview.
Show child attributes
Show child attributes
Company delivery location for money-out records. Overrides the company default address in tax preview.
Show child attributes
Show child attributes
Transaction date — required for sales tax
"2025-08-29"
Tax point / date of supply — filters VAT and GST rates by valid_from / valid_to
"2025-08-29"
List of items to calculate tax for
Show child attributes
Show child attributes
[ { "discount_type": "PERCENTAGE", "discount_value": "10.00", "item_id": -1, "quantity": "1.000000", "unit_price": "100.000000" }, { "item_id": -2, "quantity": "2.000000", "record_level_discount_amount": "5.00", "selected_vat_rate_id": 1, "unit_price": "50.000000" } ]
Currency code (ISO 4217) — required for sales tax
AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VES, VND, VUV, WST, XAF, XAG, XAU, XCD, XDR, XOF, XPD, XPF, XPT, YER, ZAR, ZMW, ZWL "USD"
Was this page helpful?