# Retry or fallback

Source: https://developer.avalara.com/avatax-dm-combined-erp/sales-tax-badge/calculate-tax-offline/retry-or-fallback/

# Retry or fallback

After your application detects a timeout, it must next make a decision whether to retry the transaction or fallback to a default tax rate. We cannot recommend which specific approach will be right for your program, but we can encourage you to consider a few key risks when retrying a transaction:

-   Some programs attempt to reuse HTTP connections. In the event that you experience a connection disruption, we encourage you to create a completely new connection for the next attempt.
-   If you experienced a timeout, you don't know whether AvaTax received your original API call. The API call may have been received and processed successfully, but the response was not received by your code. If you were creating a permanent document such as a `SalesInvoice`, you should retry your transaction using [CreateOrAdjustTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateOrAdjustTransaction/). This API call will work correctly in either case: if the original API call failed, the document will be created; if the original API call succeeded, the transaction will be adjusted.

If you decide instead to fallback to a default rate, you have a different set of concerns:

-   For transactions shipped around the country, a customer may not be obligated to collect tax in each jurisdiction if they are not set up to collect tax in that jurisdiction. If you collect tax in a jurisdiction, you are legally obligated to remit it.
-   Tax rates vary by product type, sourcing rules, and other considerations. If you use a default tax rate that happens to be higher than the actual final tax rate, you are obligated to remit the "OverCollected" amount.

AvaTax provides two approaches to fallback tax in the event that the application times out: a DownTaxRatesByPostalCode API and a TaxContent API. Whichever approach you select, please be aware that the cardinal rule of tax auditors is that whatever amount of tax you collect, you must remit. If you accidentally over collect tax, you must still remit the amount you collected. If you collect tax in a jurisdiction where you are not registered as a business, you must choose to either register your business and begin filing taxes or refund the tax collected to the customer. For specific advice on tax overcollection policies, please contact [Avalara’s Professional Services](https://www.avalara.com/contact-us/) team for advice suitable to your business as this topic is not a substitute for obtaining professional compliance advice.

## DownloadTaxRatesByPostalCode API

Avalara provides a [DownloadTaxRatesByPostalCode API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/TaxContent/DownloadTaxRatesByZipCode/), which includes a postal code rates table that you can use to determine the sales tax rate for tangible personal property in a jurisdiction. This approach produces a very simple rate value; however it overlooks much of the complexity of tax law. As such, the calculated tax might not accurately reflect the amount of tax required to collect in that jurisdiction.

If you use this approach, keep in mind that sales tax rate changes take effect on the first day of the month. To stay current, we recommend that you set up a reoccurring task to grab the rates on a regular basis. Our rates are generally updated once monthly. Use using a date of your choice in the request. For example:

`https://rest.avatax.com/api/v2/taxratesbyzipcode/download/2-1-21`

## TaxContent API

For another approach, AvaTax provides a [TaxContent API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/TaxContent/) for you to determine sensible default tax rates for your locations. This API will give you more precise tax rates for a variety of locations around the United States and are especially useful for programmers developing a retail point-of-sale (POS) based solution. The API produces a file that contains tax rates and rules for items and locations that can be used to correctly calculate tax in the event a POS device is not able to reach AvaTax.

Here’s how the TaxContent API works:

-   Use the [CreateLocation API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Locations/CreateLocations/) to create one location record for each physical retail presence you have.
-   Determine all the [TaxCodes](https://taxcode.avatax.avalara.com/) appropriate to products sold by your business.
-   On startup, your program should call the [BuildTaxContentFile API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/TaxContent/BuildTaxContentFile/) to download default tax rates for the matrix of locations and tax codes for today.

This data file will help ensure more accuracy in your tax calculation. It is not a perfect substitute for calling [CreateTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/) directly, but it is more precise than using a default rate for a postal code.

[Previous](/avatax-dm-combined-erp/sales-tax-badge/calculate-tax-offline/detect-dropped-connection)

[Next](/avatax-dm-combined-erp/sales-tax-badge/calculate-tax-offline/reconcile-transactions-after-outage)