Companies

Learn to use the AvaTax API to manage the companies associated with your business.

Avalara caters to the taxation needs of almost any business, whether it’s a sole proprietorship or a large MNCMultinational Corporation. However, before we can start processing tax transactions, we must create a company account for our business in Avalara. We use the {{BASE_URL}}/companies/ endpoint to manage a company account.

Using a company account, we can attribute the correct taxes to a specific business. This is helpful when managing several company accounts for a company with multiple subsidiaries.

Creating a company

We use the {{BASE_URL}}/companies endpoint and the POST method to create a company using the AvaTax API. While creating a company, we can add several nested objects, such as contacts and items, which aid AvaTax in calculating tax more accurately. The complete endpoint URL for creating a company is as follows:

https://sandbox-rest.avatax.com/api/v2/companies

Some of the request parameters for the URL above are as follows:

Request Parameters

Name

Type

Parameter Type

Category

Description

id

integer

Body

Required

This parameter specifies the UUID of the company we're creating.

accountId

integer

Body

Required

This parameter specifies the UUID of our Avalara account, which owns this company.

companyCode

string

Body

Optional

This parameter specifies this company's unique code, allowing us to reference our company in Avalara quickly.

name

string

Body

Required

This parameter specifies the name of this company.

isDefault

boolean

Body

Optional

This boolean parameter specifies whether the company we're creating is the default company of our Avalara account.

isActive

boolean

Body

Optional

This boolean parameter specifies whether Avalara can perform tax transactions on this company. When set to true, Avalara starts processing tax transactions for this company.

defaultCountry

string

Body

Required

This parameter specifies the default country this company is going to be based in. This helps Avalara apply tax rules of the specified country by default when creating tax transactions for it.

We need to pass the two-character ISO-3166 code of the country we're trying to set as default.

contacts

array of contact objects

Body

Optional

This parameter specifies the list of contacts for this company.

items

array of item objects

Body

Optional

This parameter specifies the list of items for this company. These items represent the goods and services provided by the company.

locations

array of location objects

Body

Optional

This parameter specifies the list of locations for this company.

Let’s see how to make an API call to create a company in Avalara. Click the “Run” button to execute the code.

Press + to interact
Please provide values for the following:
ACCOUNT_ID
Not Specified...
LICENSE_KEY
Not Specified...
# Account ID and License Key
account_id = "{{ACCOUNT_ID}}"
license_key = "{{LICENSE_KEY}}"
# Endpoint URL
endpoint_url = "https://sandbox-rest.avatax.com/api/v2/companies"
# Creating a basic auth token using account ID and license key
auth_token = requests.auth.HTTPBasicAuth(account_id, license_key)
# Defining company details
data_obj = {
"accountId": int(account_id),
"name": f"Company {random.randint(0,9999999)}",
"isDefault": False,
"isActive": True,
"hasProfile": True,
"defaultCountry": "US",
"baseCurrencyCode": "USD",
"isTest": True,
}
# Making a POST request to the AvaTax API
response = requests.post(url=endpoint_url, auth=auth_token,
data=json.dumps(data_obj))
# Printing response
print_response(response)

Here's an explanation for the code widget above:

  • Line 6: We define the endpoint URL.

  • Line 9: We define the authorization parameters. You can update these by modifying the auth_token ...