# CreateECommerceToken

Create a new ecommerce token.

`POST /api/v2/companies/{companyId}/ecommercetokens`

**API:** AvaTax API
**Tag:** ECommerceToken
**API Version:** v2
**Base URL:** https://sandbox-rest.avatax.com/
**Content-Type:** `application/json`
**Accepts:** `application/json`
**Authentication:** API Key (`Authorization` in header) or OAuth 2.0 or Basic (username + license key)

Source: https://developer.avalara.com/products/crossborder/api/methods/ECommerceToken/CreateECommerceToken/

## Description

Creates a new ecommerce token.
            
This API is used to create a new ecommerce token. An ecommerce token is required in order to launch the ECM/CertCapture ecommerce plugin. Create a separate token for each of your ECM/CertCapture customers.

Use the SDK to embed ECM’s document submission form into your ecommerce platform or online store. Once the token is created, place the returned token value for that customer record in the token field in your ecommerce SDK code. This allows customers to manage their exemption certificates before or after making the purchase. More information is available in the [ECM/CertCapture integration guide](https://developer.avalara.com/document-management/set-up-ecm-for-ecommerce/ecm-in-ecom-environments/).

You can also use the [ecommerce Plugin Demo](https://developer.avalara.com/certcapture/cert-demo/) on developer.avalara.com to test generating a token. Using your AvaTax username and password, try generating the token and combining it with various parameters.

### Security Policies

* This API requires one of the following user roles: AccountAdmin, AccountOperator, AccountUser, AvaTaxOnlyAccountAdmin, AvaTaxOnlyAccountUser, AvaTaxOnlyCompanyAdmin, AvaTaxOnlyCompanyUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, Compliance Root User, ComplianceAdmin, ComplianceUser, CSPAdmin, CSPTester, ECMAccountUser, ECMCompanyUser, FirmAdmin, FirmUser, ProStoresOperator, Registrar, ReturnsOnlyAccountAdmin, ReturnsOnlyAccountUser, ReturnsOnlyCompanyAdmin, ReturnsOnlyCompanyUser, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser, TreasuryAdmin, TreasuryUser.

## Parameters

| Name | Type | In | Required | Description |
|---|---|---|---|---|
| `companyId` | integer | path | Yes | The company ID that will be issued this certificate. |
| `X-Avalara-Client` | string | header | No | Identifies the software you are using to call this API.  For more information on the client header, see [Client Headers](https://developer.avalara.com/avatax/client-headers/) . |

## Request Body

**Schema:** `CreateECommerceTokenInputModel`

A model used to initialize a new CertCapture eCommerce token.

| Property | Type | Required | Description |
|---|---|---|---|
| `customerNumber` | string | **Yes** | The customer's number that the token will be issued for. Example: `1`. |

## Responses

| Status | Description | Schema |
|---|---|---|
| 200 | Success | `ECommerceTokenOutputModel` |
| 400 | Bad Request |  |
| 401 | Unauthorized |  |
| 500 | Server Error |  |

### 200 Response: `ECommerceTokenOutputModel`

The resource model returned by the ECommerceTokenController's endpoints.

| Property | Type | Required | Description |
|---|---|---|---|
| `token` | string | **Yes** | The JWT token that authorizes the gencert tool to operate. Example: `jwt token for gencert utility`. |
| `clientIds` | integer[] | No | The list of clients that the token is valid for. |
| `createdDate` | string | **Yes** | The date the token was created. Example: `2000-01-01T00:00:00`. |
| `expirationDate` | string | **Yes** | The date that the token will expire. Example: `2000-01-01T00:00:00`. |

## Example Request

```bash
curl -X POST "https://sandbox-rest.avatax.com/api/v2/companies/{companyId}/ecommercetokens" \
  -H "Authorization: Basic <credentials>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
  "customerNumber": "1"
}'
```