# Order Tracking (API)

### Starter Guide

{% hint style="warning" %}
**ATTENTION:** The asterisk (<mark style="color:red;">`*`</mark>) symbol, when placed next to a field or item in forms or documentation, typically denotes that the information is mandatory or required.
{% endhint %}

{% hint style="warning" %}
**ATTENTION:** Sending the country value is only mandatory if you want to segregate the data by country. If there is no need to segregate by country, you can proceed without providing this information.
{% endhint %}

### 1. Adding products to the cart

An important step in the process is when the user adds a product to the shopping cart. This a very important moment and indicates that the user has actually engaged with the product (or with the offer).

## Cart

<mark style="color:green;">`POST`</mark> `https://vfr-v3-production.sizebay.technology/plugin/new/cart?sid=*`

Endpoint for adding the product in the cart.

#### Headers Parameters

| Name                                              | Type   | Description                                                                                                |
| ------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------- |
| x-szb-country                                     | string | Country running plugin (ex: BR, US, MX, DE)                                                                |
| x-szb-device<mark style="color:red;">\*</mark>    | string | <p>User device</p><p>Possible values: <em>DESKTOP</em>, <em>MOBILE</em>, <em>TABLET</em>, <em>APP</em></p> |
| x-szb-tenant-id<mark style="color:red;">\*</mark> | string | Store ID                                                                                                   |
| x-szb-referer<mark style="color:red;">\*</mark>   | string | The referer must be the (domain) of the store, for example: “store.sizebay.com”, without https\://.        |

#### Query Parameters

| Name | Type   | Description         |
| ---- | ------ | ------------------- |
| sid  | string | User identification |

#### Request Body

| Name    | Type   | Description                             |
| ------- | ------ | --------------------------------------- |
| payload | object | Payload with all products added to cart |

{% hint style="warning" %}
The **SID** must me retrieved from the cookies, identified as **`SIZEBAY_SESSION_ID_V4`**
{% endhint %}

#### Payload Example:

```javascript
{
  "products": [
    {
      "permalink": "https://www.sizebay.com.br/product/product-example"
    }
  ],
  "tenantId": 000
}
```

| `Field`     | Type   | Description                            |
| ----------- | ------ | -------------------------------------- |
| `tenantId`  | string | Sizebay Store ID                       |
| `products`  | array  | Array containing the product permalink |
| `permalink` | string | Product URL                            |

{% hint style="warning" %}
**Important**: The tenantId should be provided by our Support Team (<support@sizebay.com>)
{% endhint %}

### 2. **Finalizing the order**

The checkout page is the most important page in the process, as it represents the sale itself. It is through the sales indicators that the exchanges/returns rate of the products sold are analyzed.

{% hint style="warning" %}
**ATTENTION:** Sending the country value is only mandatory if you want to segregate the data by country. If there is no need to segregate by country, you can proceed without providing this information.
{% endhint %}

## Ordered

<mark style="color:green;">`POST`</mark> `https://vfr-v3-production.sizebay.technology/plugin/new/ordered?sid=*`

Endpoint to register a new order.

#### Headers Parameters&#x20;

| Name                                              | Type   | Description                                                                                                |
| ------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------- |
| x-szb-country                                     | string | Country running plugin (ex: BR, US, MX, DE)                                                                |
| x-szb-device<mark style="color:red;">\*</mark>    | string | <p>User device</p><p>Possible values: <em>DESKTOP</em>, <em>MOBILE</em>, <em>TABLET</em>, <em>APP</em></p> |
| x-szb-tenant-id<mark style="color:red;">\*</mark> | string | Store ID                                                                                                   |
| x-szb-referer<mark style="color:red;">\*</mark>   | string | The referer must be the (domain) of the store, for example: “store.sizebay.com”, without https\://.        |

#### Query Parameters

| Name | Type   | Description         |
| ---- | ------ | ------------------- |
| sid  | string | User identification |

#### Request Body

| Name    | Type   | Description                        |
| ------- | ------ | ---------------------------------- |
| payload | object | Payload with the order information |

{% hint style="warning" %}
The **SID** must me retrieved from the cookies, identified as **`SIZEBAY_SESSION_ID_V4`**
{% endhint %}

```javascript
{
  "orderId": "000000",
  "items": [
    {
      "permalink": "https://www.sizebay.com.br/product/product-example",
      "price": 75,
      "quantity": 1,
      "size": "M",
      "feedProductId": "00000",
      "sku": "A1P"
    }
  ],
  "tenantId": 000,
  "currency": "EUR"
}
```

| `Field`         | Type   | Description                                                                                                                                                                                                        |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `tenantId`      | string | Sizebay Store ID                                                                                                                                                                                                   |
| `orderId`       | string | Must be filled in with the order code generated as soon as the purchase is made. It is with this information that we will be able to track this shopping experience in case of a future exchanged/returned product |
| `items`         | array  | Array with the various items that were sold in this purchased order. There are no product limits to be included. Each product has the attributes described **below**:                                              |
| `permalink`     | string | Product URL. It must be the same used in the shopping cart                                                                                                                                                         |
| `price`         | float  | The price of the product sold                                                                                                                                                                                      |
| `quantity`      | int    | Number of itens                                                                                                                                                                                                    |
| `size`          | string | Clothing size ordered                                                                                                                                                                                              |
| `feedProductId` | string | global product id (id for all variations)                                                                                                                                                                          |
| `sku`           | string | Id of product variation                                                                                                                                                                                            |
| `currency`      | string | Currency applied to the ordered item                                                                                                                                                                               |

{% hint style="warning" %}
**Important:** For the complete list of supported countries and currencies, please head over to the session [Sizebay Tracker - Supported Countries and Currencies](https://docs.sizebay.com/shopping-tracker/sizebay-tracker-supported-countries-and-currencies)
{% endhint %}

{% hint style="warning" %}
**Important**: The tenantId should be provided by our Support Team (<support@sizebay.com>)
{% endhint %}
