# RefreshECommerceToken

Refresh an eCommerce token.

`PUT /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/RefreshECommerceToken/

## Description

Refresh an eCommerce token.
            
CertCapture eCommerce tokens expire after one hour. This API is used to refresh an eCommerce token that is about to expire. This API can only be used with active tokens. If your token has expired, you must generate a new one.

### 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 the refreshed certificate belongs to. |
| `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:** `RefreshECommerceTokenInputModel`

A model used to request the refresh of a CertCapture eCommerce token.

| Property | Type | Required | Description |
|---|---|---|---|
| `token` | string | **Yes** | The token that requires its expiration to be extended. Example: `jwt token for gencert utility`. |

## Responses

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

### 200 Response: `ECommerceTokenOutputModelFetchResult`

| Property | Type | Required | Description |
|---|---|---|---|
| `@recordsetCount` | integer | No |  |
| `value` | ECommerceTokenOutputModel[] | No |  |
| `@nextLink` | string | No |  |
| `pageKey` | string | No |  |

## Example Request

```bash
curl -X PUT "https://sandbox-rest.avatax.com/api/v2/companies/{companyId}/ecommercetokens" \
  -H "Authorization: Basic <credentials>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
  "token": "jwt token for gencert utility"
}'
```