Avalara - Technical documentation
This documentation page explains at a C4 level how the Avalara connector works.
Use this documentation if you need to review / assess at a very low level if the data that are transmitted to Avalara and what APIs calls are used.
C4 diagrams
Context
OIS
Web
Authentication
All requests to the Avalara APIs are inputted with the following header.
Authorization: Basic base64('<API login>:<API password>')
The credentials used are configured in your sales channel configuration where "<API login>" is from avalara.credentials.username and "<API password>" fromavalara.credentials.password.
Specific header
There is a X-Avalara-Client header sent with every request to Avalara to identifiy that the request comes from OneStock
X-Avalara-Client: xxxxxConfiguration
The configuration can be done in your Sales Channel.
0. Before starting
For the majority of calls we use the same endpoint CreateOrAdjustTransaction.
STAGING_URL : https://sandbox-rest.avatax.com/api/v2
PROD_URL : https://rest.avatax.com/api/v2
1. CreateOrAdjustTransaction
Route: POST <PROD|STAGING_URL>/transactions/createoradjust?$include=Lines
1.1 CreateTransaction Structure - Avalara Tax API
Parameter | Type | Description | Value |
|---|---|---|---|
code | string | Unique transaction code | Dynamic: |
commit | bool | Indicates if the transaction should be committed | Dynamic: Based on |
companyCode | string | Avalara company code | Configuration: Sales channel : |
currencyCode | string | Currency code (ex: "EUR") | Dynamic: |
customerCode | string | Unique customer code | Dynamic: |
date | string | Transaction date | Dynamic: Current date in YYYY-MM-DD format |
entityUseCode | string | Tax exemption code | Dynamic: Tax exemption code if applicable for the customer |
lines | []*LineItem | List of transaction items | Dynamic: Array of |
type | TransactionType | Transaction type | Dynamic: |
userDefinedFields | []UserDefinedField | Custom fields | Dynamic: User-defined fields to store additional information |
addresses | *Addresses | Shipping and billing addresses | Dynamic: |
taxOverride | *TaxOverride | Tax override | Dynamic: Used for refunds with |
1.2 Sub-structure Details
LineItem
Parameter | Type | Description | Value |
|---|---|---|---|
number | string | Unique line number | Dynamic: |
amount | float64 | Line amount | Dynamic: Item price or shipping fees |
description | string | Item description | Dynamic: |
itemCode | string | Item code | Dynamic: |
taxCode | string | Tax code | Dynamic: |
hsCode | string | Harmonized code | Dynamic: |
taxIncluded | bool | Tax included in price | Dynamic: |
quantity | int64 | Quantity | Dynamic: |
addresses | *Addresses | Line-specific addresses | Dynamic: |
userDefinedFields | []UserDefinedField | Line custom fields | Dynamic: |
Addresses
Parameter | Type | Description | Value |
|---|---|---|---|
shipFrom | *AddressLocation | Shipping address | Dynamic: Origin address of the delivery |
shipTo | *AddressLocation | Delivery address | Dynamic: Destination address of the delivery |
singleLocation | *AddressLocation | Single address | Dynamic: Used for direct deliveries (StraightFulfilled) |
AddressLocation
Parameter | Type | Description | Value |
|---|---|---|---|
city | string | City | Dynamic: |
country | string | Country code | Dynamic: |
line1 | string | Address line 1 | Dynamic: |
line2 | string | Address line 2 | Dynamic: |
line3 | string | Address line 3 | Dynamic: |
locationCode | string | Avalara location code | Configuration: Endpoint - Location code configured in Avalara |
postalCode | string | Postal code | Dynamic: |
region | string | Region/state code | Dynamic: |
2. Estimation
Using CreateOrAdjustTransaction plus some specific parameters:
2.1 Estimation - Creation
Parameter | Type | Description | Value |
|---|---|---|---|
commit | bool | Transaction commit status | Hard-coded: |
type | TransactionType | Transaction type | Hard-coded: |
adjustmentDescription | string | Adjustment description | Hard-coded: |
2.2 Estimation - Refund
Parameter | Type | Description | Value |
|---|---|---|---|
commit | bool | Transaction commit status | Hard-coded: |
type | TransactionType | Transaction type | Hard-coded: |
adjustmentDescription | string | Adjustment description | Hard-coded: |
taxOverride | *TaxOverride | Tax override | Dynamic: Override some properties from original transaction creation |
TaxOverride
Parameter | Type | Description | Value |
|---|---|---|---|
taxDate | string | Tax date | Dynamic: Original transaction creation date in YYYY-MM-DD format |
3. Create
Using CreateOrAdjustTransaction plus some specific parameters:
Parameter | Type | Description | Value |
|---|---|---|---|
commit | bool | Transaction commit status | Dynamic: Based on the |
type | TransactionType | Transaction type | Dynamic: |
adjustmentDescription | string | Adjustment description | Hard-coded: |
4. Refresh
Using CreateOrAdjustTransaction plus some specific parameters:
Parameter | Type | Description | Value |
|---|---|---|---|
commit | bool | Transaction commit status | Dynamic: Based on the |
type | TransactionType | Transaction type | Hard-coded: |
adjustmentDescription | string | Adjustment description | Hard-coded: |
5. Refund
Using CreateOrAdjustTransaction plus some specific parameters:
Parameter | Type | Description | Value |
|---|---|---|---|
commit | bool | Transaction commit status | Hard-coded: |
type | TransactionType | Transaction type | Dynamic: |
adjustmentDescription | string | Adjustment description |