Calling Avalara API from Postman
This article can help you understand the Avalara developer portal, how to use the portal, and how to identify Avalara’s APIs. We’ll also share an example endpoint to create a REST API call using Postman.
Before we begin
To get started, you’ll need an Avalara AvaTax account. Avalara provides a free trial account you can use to begin developing against AvaTax. This trial account will allow you to use advanced AvaTax functionality for locations in the U.S. and Canada.
You can begin by signing up for a free AvaTax account online, or you can contact sales to purchase an account. Once your free trial is up, you can continue using our Free TaxRates API or contact sales to upgrade to a full account. To explore the various APIs provided by Avalara, visit the Avalara developer portal at http://developer.avalara.com/ . By clicking APIs on the top navigation bar, you’ll see links to our Overview, Developer Guide, API References, and much more as shown in the screenshot below.
Authentication is required to use Avalara APIs. If you don’t have a username, password, or authentication token, register for a free account at https://developer.avalara.com/avatax. Visit https://developer.avalara.com for more information. You can download the Postman tool from the official Postman website at https://www.postman.com/downloads/.
Identify the API in the developer portal you want to call in Postman. For a list of all AvaTax endpoints available, see https://developer.avalara.com/api-reference/avatax/rest/v2/. Let’s look at an example of the CreateTransaction endpoint from AvaTax API and see the process of creating a Postman request.
Example – CreateTransaction endpoint
URL - https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/
This endpoint is used to record a new transaction in AvaTax. When you go to the endpoint page in the developer portal, you can see all the details for endpoint, as shown in the screenshot below. Avalara provides two different environments for AvaTax: Sandbox and Production. Each environment is completely separate, and each has its own credentials. If you have a Sandbox account, you cannot use that account to sign in to Production and vice versa. The screenshot below shows all the endpoint details.
Each endpoint has its own set of input parameters: header, querystring, and request body. See all the required or optional input parameters in screenshot below.
More information about request body is available in the parameters section. For our example, see the screenshot below for CreateTransactionModel. This includes the Field Name, Attributes, and Summary of each field of request body for the endpoint. You can get request payload and expected response from every endpoint listed on the developer portal.
Create Transaction in Postman
In this example, we use the Sandbox URL and Sandbox credential to test an endpoint. For the Production environment, you can use the Production URL mentioned in the developer portal. Open the Postman application from your system. Click on the New button to create a new request.
Set the querystring parameters in Postman under the parameters tab, if required. In this example, you can see that $include is an optional string querystring parameter. This parameter specifies objects to include in the response after the transaction is created.
Set headers in Postman under the Headers tab, if required. In this example, you can see that Header as X-Avalara-Client, which is an optional string parameter. This parameter identifies the software you’re using to call this API. For more information on the client header, see Client Headers ( https://developer.avalara.com/avatax/client-headers/ ).
Set Authorization for request in Postman under the Authorization tab. If you have a username and password then select Type as Basic Auth in the dropdown of the left panel. Now you can add username and password for authentication. If you have an authentication token then select Bearer token instead of Basic Auth in Type dropdown then add token in token textbox in Postman.
Creating a request in Postman
- Get the request URL for the endpoint from the developer portal and enter in Postman. In the CreateTransaction example, we added the URL https://sandbox-rest.avatax.com/api/v2/transactions/create in Postman URL address bar.
- Select the required HTTP verb, which can be GET, POST, PUT, etc. from the dropdown in Postman.
- Get request JSON from the developer portal endpoint and paste in Postman. Change the values of payload to actual values as needed. As seen in the screenshot below, under the Body tab in Postman, we’ve selected the raw option where we can add JSON payload for request.
Getting a response
a. Click on send button to send request to server. Within a few seconds you’ll get a response in Postman as shown below.
Verifying the response
- Verify the response by checking the response status code. Successful response status code starts with 2xx.
- Check the response JSON. If you see an error, make sure you entered the right information.
- If you see any errors in the response, make sure you added the right information.
- There can be various reasons for errors. These are some basic verification checks you can do:
- Verify the environment URL you are planning to use. It can be Sandbox or Production.
- Verify your credentials or authentication token. Credentials or authentication token are specific to environment.
- Verify HTTP verb in Postman request.
- Verify endpoint URL in Postman.
- Verify request payload, check for required parameters, its datatype, and the input values you provided.