Getting Started with the AvaTax API

Get an overview of the AvaTax API and obtain Avalara credentials.

Avalara offers cloud-based automated tax compliance solutions for businesses of all sizes. One of the services available in Avalara is AvaTax, which provides real-time tax rates from multiple jurisdictions across international borders.

The AvaTax API

We can use Avalara's AvaTax API to calculate sales tax for every business transaction based on jurisdiction laws and rules. AvaTax has two types of accounts: Production and Sandbox. Both of them have different credentials. You'll be using the Sandbox account throughout this course.

Creating an AvaTax sandbox account

To create an AvaTax sandbox account, follow these steps:

  1. Go to the Avalara signup page and enter the required information (first name, last name, and email). After filling in the required information, click the "Continue" button.

  2. Fill in your company information. You must provide a valid address for AvaTax to determine which tax jurisdiction to place your company in. After filling in the company information, press the “Next” button.

  3. Select the “API & CUSTOM INTEGRATION” option. A message will pop up on the right side of the screen.

  4. Click the “Select API” button to proceed.

  5. After you’ve selected the API, you’ll receive an email to confirm the successful creation of your developer account.

To activate your Avalara account to use the AvaTax API, follow these steps:

  1. Open the activation email and click the button given in the email to set up the account password. You’ll then be redirected to the password setup page. Enter your password and click “Save.”

  2. Enter your registered email address (this is also the username), and click “Next.”

  3. Enter the password you just created and click the “Sign in” button.

  4. After setting up the password and signing in, accept Avalara’s terms and conditions by clicking the “I accept” button.

  5. Click the “Get started” button to start the account activation process.

  6. Enter your company’s name and phone number, and choose the “No” option for the question, “Is this an online marketplace?” Ignore the rest of the fields and click the “Next” button.

  7. Add a valid address for your company. The address should be valid because Avalara uses this location to set up the default tax calculations in AvaTax.

  8. Click the “Validate address” button in case your company address is in the US. A pop-up will appear, asking you whether to choose the validated or the original address. We recommend you choose the validated address by clicking the “Use validated address” button. You can also choose the original address if you want by clicking the “Keep original address” button. After choosing the address, you want to use, click the “Next” button.

  9. Click the “No, this is complete” button to activate your Avalara account quickly.

  10. Avalara will ask if your company is eligible to pay taxes in other countries. Click “No, where I collect tax is complete” to proceed ahead quickly.

  11. Avalara will now show the place(s) where tax will be collected from your company. Click the “Done with tax jurisdiction” button to proceed.

  12. Activate your Avalara account by clicking the “Activate company” button.

  13. Your Avalara account will now be successfully activated, and you can now proceed to the AvaTax sandbox environment dashboard by clicking the “Continue to AvaTax” button.

  14. Navigate to the top-right corner of your screen and open your “Account” menu. Now, select the “Sign out” option to sign out of your account.

Note: If you cannot sign in to your Avalara account, make sure you’re on the sandbox environment’s login page. It’s a common mistake to try to sign in to the production environment instead of Sandbox. Here’s the correct link for the Sandbox environment: https://sandbox.admin.avalara.com/

To create the authentication credentials for your AvaTax sandbox account, follow these steps:

  1. Navigate to the navigation bar, then select and open the “Settings” menu.

  2. Now, select the “License and API keys” option.

  3. Click the “Generate license key” button to generate the license key.

  4. Confirm the previous action by clicking the “Yes, generate a license key” button.

  5. Copy the Account ID next to “Avalara account” and the license key from the “License Key” field. You need to save these keys in the code executable in the section below. In case you lose these, you’ll have to repeat these steps to generate new ones.

Credentials authentication

There are two options that the AvaTax API supports for HTTP Basic authentication. These are as follows:

  • The AvaTax account number and license key authentication.

  • The AvaTax username and password authentication.

For this course, we’ll use the account ID and license key that we previously generated for authentication.

Credentials

Click the "Edit" button and enter the ACCOUNT_ID and LICENSE_KEY that you generated to save them for use throughout the course without entering them again.

Note: It may take a few minutes for Avalara to update your account, and you won’t be able to authenticate your account credentials till then.

# Account ID and License Key
account_id = "{{ACCOUNT_ID}}"
license_key = "{{LICENSE_KEY}}"
# Creating a basic auth token using account ID and license key
auth_token = auth.HTTPBasicAuth(account_id,license_key)
# Authenticating auth token
authenticate(auth_token)