---
title: Calculate the sales tax with TaxJar service.
slug: amberflo-api/calculate-the-sales-tax-with-taxjar-service
docTags: 
createdAt: 2024-11-07T15:10:16.979Z
---

{
  "id": "ksHCaMBfj_AxzDJdBMl-_",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/integration/tax/sales-tax/taxjar",
    "servers": [
      {
        "url": "https://app.amberflo.io/integration/tax/sales-tax/taxjar"
      }
    ],
    "name": "Calculate the sales tax with TaxJar service.",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "com.amberflo.integration.tax.SalesTaxRequest.in",
          "schema": [
            {
              "name": "accountAddress",
              "kind": "required",
              "type": "object",
              "description": "The address of the account that is providing the product",
              "modelRef": "#/components/schemas/com.amberflo.integration.tax.Address.in",
              "customType": "com.amberflo.integration.tax.Address.in",
              "schema": [
                {
                  "name": "country",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "postalCode",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "state",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "city",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "line1",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                }
              ]
            },
            {
              "name": "customerAddress",
              "kind": "required",
              "type": "object",
              "description": "The address of the customer whose invoice the tax is being calculated on",
              "modelRef": "#/components/schemas/com.amberflo.integration.tax.Address.in",
              "customType": "com.amberflo.integration.tax.Address.in",
              "schema": [
                {
                  "name": "country",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "postalCode",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "state",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "city",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "line1",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                }
              ]
            },
            {
              "name": "salesTaxOrder",
              "kind": "required",
              "type": "object",
              "description": "The order for the sales tax calculation request",
              "modelRef": "#/components/schemas/com.amberflo.integration.tax.SalesTaxOrder.in",
              "customType": "com.amberflo.integration.tax.SalesTaxOrder.in",
              "schema": [
                {
                  "name": "id",
                  "kind": "required",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "amount",
                  "kind": "required",
                  "type": "number",
                  "example": ""
                }
              ]
            },
            {
              "name": "productCategory",
              "kind": "required",
              "type": "string",
              "description": "The category of product that the account is charging the customer for",
              "modelRef": "#/components/schemas/com.amberflo.integration.tax.SalesTaxProductCategory.in",
              "customType": "com.amberflo.integration.tax.SalesTaxProductCategory.in",
              "schema": []
            },
            {
              "name": "accountIntegrationDetail",
              "kind": "required",
              "type": "object",
              "description": "The extra account integration detail required for the sales tax integration.",
              "modelRef": "#/components/schemas/com.amberflo.integration.tax.AccountIntegrationDetail.in",
              "customType": "com.amberflo.integration.tax.AccountIntegrationDetail.in",
              "schema": [
                {
                  "name": "username",
                  "kind": "optional",
                  "type": "string",
                  "description": "User name or account id etc.",
                  "example": ""
                },
                {
                  "name": "password",
                  "kind": "optional",
                  "type": "string",
                  "description": "API key, password, license key (such as Avalara), etc.",
                  "example": ""
                },
                {
                  "name": "companyCode",
                  "kind": "optional",
                  "type": "string",
                  "description": "Company code for the integration if applicable, such as Avalara.",
                  "example": ""
                },
                {
                  "name": "environment",
                  "kind": "optional",
                  "type": "string",
                  "description": "Environment that the account integration detail is used for if applicable. Such as sandbox or production",
                  "example": ""
                }
              ]
            },
            {
              "name": "customerIntegrationDetail",
              "kind": "required",
              "type": "object",
              "description": "The extra customer integration detail required for the sales tax integration.",
              "modelRef": "#/components/schemas/com.amberflo.integration.tax.CustomerIntegrationDetail.in",
              "customType": "com.amberflo.integration.tax.CustomerIntegrationDetail.in",
              "schema": [
                {
                  "name": "customerCode",
                  "kind": "required",
                  "type": "string",
                  "description": "The identifier for a customer.",
                  "example": ""
                }
              ]
            },
            {
              "name": "timeInSeconds",
              "kind": "required",
              "type": "integer<int64>",
              "description": "Time of transaction, which could be invoice start/end time, tax calculation time, etc.",
              "example": 0
            }
          ],
          "modelRef": "#/components/schemas/com.amberflo.integration.tax.SalesTaxRequest.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "com.amberflo.integration.tax.SalesTaxResponse.out",
            "schema": [
              {
                "name": "salesTaxAmount",
                "kind": "optional",
                "type": "number",
                "description": "The amount of sales tax the customer needs to pay",
                "example": ""
              },
              {
                "name": "invoiceSalesTax",
                "kind": "optional",
                "type": "object",
                "description": "The sales tax related details",
                "modelRef": "#/components/schemas/com.amberflo.integration.tax.InvoiceSalesTax.out",
                "customType": "com.amberflo.integration.tax.InvoiceSalesTax.out",
                "schema": [
                  {
                    "name": "totalTaxAmount",
                    "kind": "optional",
                    "type": "number",
                    "description": "The total tax for all lines in this transaction",
                    "example": ""
                  },
                  {
                    "name": "totalTaxableAmount",
                    "kind": "optional",
                    "type": "number",
                    "description": "The portion of the total amount of this transaction that was taxable",
                    "example": ""
                  },
                  {
                    "name": "totalExemptAmount",
                    "kind": "optional",
                    "type": "number",
                    "description": "The amount of this transaction that was exempt",
                    "example": ""
                  },
                  {
                    "name": "combinedTaxRate",
                    "kind": "optional",
                    "type": "number",
                    "description": "The rate of taxation, as a fraction of the amount",
                    "example": ""
                  },
                  {
                    "name": "hasNexus",
                    "kind": "optional",
                    "type": "boolean",
                    "description": "Has nexus",
                    "example": ""
                  },
                  {
                    "name": "taxCode",
                    "kind": "optional",
                    "type": "string",
                    "description": "The tax code",
                    "example": ""
                  }
                ]
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "object",
                "description": "The message that contains information regarding sales tax calculation",
                "modelRef": "#/components/schemas/com.amberflo.service.common.log_message.LogMessage.out",
                "customType": "com.amberflo.service.common.log_message.LogMessage.out",
                "schema": [
                  {
                    "name": "level",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "modelRef": "#/components/schemas/com.amberflo.service.common.log_message.MessageLevel.out",
                    "customType": "com.amberflo.service.common.log_message.MessageLevel.out",
                    "schema": []
                  },
                  {
                    "name": "code",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "modelRef": "#/components/schemas/com.amberflo.service.common.log_message.MessageCode.out",
                    "customType": "com.amberflo.service.common.log_message.MessageCode.out",
                    "schema": []
                  },
                  {
                    "name": "message",
                    "kind": "optional",
                    "type": "string",
                    "example": ""
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/com.amberflo.integration.tax.SalesTaxResponse.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "8QBMdBrPfr5j9qc6LLFTa",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/integration/tax/sales-tax/taxjar \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"accountAddress\": {\n     \"country\": \"\",\n     \"city\": \"\",\n     \"line1\": \"\"\n     },\n     \"customerAddress\": {\n     \"country\": \"\",\n     \"city\": \"\",\n     \"line1\": \"\"\n     },\n     \"salesTaxOrder\": {\n     \"id\": \"\",\n     \"amount\": \"\"\n     },\n     \"productCategory\": \"\",\n     \"accountIntegrationDetail\": {},\n     \"customerIntegrationDetail\": {\n     \"customerCode\": \"\"\n     },\n     \"timeInSeconds\": 0\n     }'"
        },
        {
          "id": "XGiP8aY4TeDvfKhhloD58",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"accountAddress\": {\n      \"country\": \"\",\n      \"city\": \"\",\n      \"line1\": \"\"\n   },\n   \"customerAddress\": {\n      \"country\": \"\",\n      \"city\": \"\",\n      \"line1\": \"\"\n   },\n   \"salesTaxOrder\": {\n      \"id\": \"\",\n      \"amount\": \"\"\n   },\n   \"productCategory\": \"\",\n   \"accountIntegrationDetail\": {},\n   \"customerIntegrationDetail\": {\n      \"customerCode\": \"\"\n   },\n   \"timeInSeconds\": 0\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/integration/tax/sales-tax/taxjar\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "_3STENU4KyA7rV2YNWnHO",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/integration/tax/sales-tax/taxjar\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"accountAddress\": {\n      \"country\": \"\",\n      \"city\": \"\",\n      \"line1\": \"\"\n   },\n   \"customerAddress\": {\n      \"country\": \"\",\n      \"city\": \"\",\n      \"line1\": \"\"\n   },\n   \"salesTaxOrder\": {\n      \"id\": \"\",\n      \"amount\": \"\"\n   },\n   \"productCategory\": \"\",\n   \"accountIntegrationDetail\": {},\n   \"customerIntegrationDetail\": {\n      \"customerCode\": \"\"\n   },\n   \"timeInSeconds\": 0\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "u-uEOewgeI1-GS77F2Lg4",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/integration/tax/sales-tax/taxjar\"\n\npayload = json.dumps({\n   \"accountAddress\": {\n      \"country\": \"\",\n      \"city\": \"\",\n      \"line1\": \"\"\n   },\n   \"customerAddress\": {\n      \"country\": \"\",\n      \"city\": \"\",\n      \"line1\": \"\"\n   },\n   \"salesTaxOrder\": {\n      \"id\": \"\",\n      \"amount\": \"\"\n   },\n   \"productCategory\": \"\",\n   \"accountIntegrationDetail\": {},\n   \"customerIntegrationDetail\": {\n      \"customerCode\": \"\"\n   },\n   \"timeInSeconds\": 0\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "8QBMdBrPfr5j9qc6LLFTa"
    },
    "results": {
      "languages": [
        {
          "id": "f5_d8qhExNOf34oc6FiY-",
          "language": "200",
          "code": "// Successful request\n{\n  \"salesTaxAmount\": 0,\n  \"invoiceSalesTax\": {\n    \"totalTaxAmount\": 0,\n    \"totalTaxableAmount\": 0,\n    \"totalExemptAmount\": 0,\n    \"combinedTaxRate\": 0,\n    \"hasNexus\": false,\n    \"taxCode\": \"\"\n  },\n  \"message\": {\n    \"level\": \"\",\n    \"code\": \"\",\n    \"message\": \"\"\n  }\n}"
        }
      ],
      "selectedLanguageId": "f5_d8qhExNOf34oc6FiY-"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}