# Avalara Trade Compliance

### Access to the Production API
To interact with this API, you need to acquire a bearer token.
To acquire a bearer token:
1. [Create a License Key](https://knowledge.avalara.com/bundle/bhk1662649440973_bhk1662649440973/page/Get_your_license_key.html).
2. Call Avalara Identity to get an access token:
    ```bash
        curl -X POST https://identity.avalara.com/connect/token
             -H "Content-Type: application/x-www-form-urlencoded"
             -d "grant_type=client_credentials&client_id=&client_secret=&scope=avatax_api"
    ```
    Sample response (json)
    ```json
        {
            "access_token": "",
            "expires_in": 3600,
            "token_type": "Bearer",
            "scope": "avatax_api"
        }
    ```
3. The `access_token` can be used to interact with the API.
4. The `access_token` is valid for 1 hour, after which you will need to request a fresh token.

### Access to the Sandbox API
To interact with the Sandbox API, you can request for a bearer token from your Avalara integration specialist.
You can use the bearer token issued for a fixed number of requests against the sandbox API.

Source: https://developer.avalara.com/products/trade-compliance/api/

**Version:** 1.0
**Base URL:** /

---

## Endpoints

### Product

#### Add a product.

`POST /tradecompliance/product`

Adds a new product to the system. Optionally overwrites an existing product with the same productId.

**Parameters:**

| Name | Type | In | Required | Description |
|---|---|---|---|---|
| `overwriteIfExists` | boolean | query | No | When true, overwrites an existing product with the same productId. When false, does not overwrite an existing product. |
| `avalara-version` |  | header | Yes | API version. Current version is 1.0. |

---

## Models

### ProductRequest

Request payload used to create or update a product. 'productId', 'owner', and 'description' are required; the remaining fields are optional.

| Property | Type | Description |
|---|---|---|
| `productId` | string | Customer-defined unique identifier of the product. Required. |
| `owner` | string | Avalara identifier of the product owner. This is typically the end-customer's AvaTax account ID under the calling profile. Required. |
| `description` | string | General description of the product. Required. |
| `customsDescription` | string | Description used specifically for customs declarations. If omitted, defaults to the value of 'description'. |
| `client` | string | Optional client identifier or label associated with the product. Used for grouping and searching products. Free-form string. |
| `origin` | string | Country of origin in ISO 3166-1 alpha-2 format. |

### ProductProjection

A product as stored in the product service, including its identifier, descriptions, country of origin, and ownership metadata.

| Property | Type | Description |
|---|---|---|
| `productId` | string | Customer-defined unique identifier of the product. |
| `description` | string | General description of the product. |
| `customsDescription` | string | Description used specifically for customs declarations. If omitted on creation, defaults to the value of 'description'. |
| `origin` | string | Country of origin in ISO 3166-1 alpha-2 format. |
| `client` | string | Optional client identifier or label associated with the product. Used for grouping and searching products. Free-form string. |
| `owner` | string | Avalara identifier of the product owner. This is typically the end-customer's AvaTax account ID under the calling profile. |

### AvalaraAPIExceptionDetails

Standard error response payload returned by the API when a request fails. Provides a short error title, the HTTP status code, and a human-readable detail message.

| Property | Type | Description |
|---|---|---|
| `title` | string | Short, human-readable error category. |
| `status` | integer | HTTP status code returned with the error response. |
| `detail` | string | Human-readable explanation of the specific error condition. Suitable for surfacing to end users or logging. |
