> ## Documentation Index
> Fetch the complete documentation index at: https://developers.e-cross.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulate taxes

> Simulate taxes for a set of products at checkout using local-currency amounts

Simulate taxes for the items in a cart together with freight, for a given destination country and state.

<Note>
  All input and output monetary values for this API are in the **local currency** (for example, BRL when `country` is `BR`).
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://product.api.e-cross.tech/ext/taxes' \
    -H 'Authorization: Bearer YOUR_SALES_CHANNEL_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
      "items": [
          {
              "id": "029c31c8-6576-42fb-a846-5144d2efb3a4",
              "skuId": "1",
              "quantity": 1,
              "unitPriceWithDiscount": 180.00
          }
      ],
      "freight": 50,
      "country": "BR",
      "state": "SP"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "fxRate": 5.51,
    "items": [
      {
        "id": "029c31c8-6576-42fb-a846-5144d2efb3a4",
        "skuId": "1",
        "cbsTaxValue": 0,
        "ibsETaxValue": 0,
        "ibsMTaxValue": 0,
        "icmsTaxValue": 31.6,
        "importTaxValue": 0,
        "totalTaxValue": 31.6
      }
    ],
    "totals": {
      "cbsTaxValue": 0,
      "ibsETaxValue": 0,
      "ibsMTaxValue": 0,
      "icmsTaxValue": 31.6,
      "importTaxValue": 0,
      "totalTaxValue": 31.6
    }
  }
  ```
</ResponseExample>

## How authentication works

This endpoint uses the sales channel token authentication model, not the auth token generated with merchant credentials.

The bearer token is provided by e-CROSS to the sales channel during the integration process.

```
Authorization: Bearer YOUR_SALES_CHANNEL_TOKEN
```

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for the sales channel request. Use the format `Bearer YOUR_SALES_CHANNEL_TOKEN`.
</ParamField>

## Request body

<ParamField body="items" type="array" required>
  Line items to simulate taxes for together.

  <Expandable title="Item fields">
    <ParamField body="id" type="string" required>
      Unique ID for this line; the same ID is returned in the response for that line.
    </ParamField>

    <ParamField body="skuId" type="string" required>
      SKU identifier on e-CROSS.
    </ParamField>

    <ParamField body="quantity" type="number" required>
      Quantity of the SKU.
    </ParamField>

    <ParamField body="unitPriceWithDiscount" type="number" required>
      Unit price in local currency after discounts; the amount the customer pays per unit at checkout.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="freight" type="number" required>
  Freight value for the cart in local currency, **without** any shipping discount applied.
</ParamField>

<ParamField body="country" type="string" required>
  ISO 3166-1 alpha-2 destination country code (for example, `BR`).
</ParamField>

<ParamField body="state" type="string" required>
  Destination state or region code. For countries where taxes depend on state (for example, Brazil), use the correct two-letter state code (for example, `SP`).
</ParamField>

## Response fields

<ResponseField name="fxRate" type="number" required>
  USD to BRL FX rate used by this API when calculating the response values.
</ResponseField>

<ResponseField name="items" type="array" required>
  One entry per request line, in the same order as requested.

  <Expandable title="Item properties">
    <ResponseField name="id" type="string" required>
      Line ID from the request.
    </ResponseField>

    <ResponseField name="skuId" type="string" required>
      SKU ID from the request.
    </ResponseField>

    <ResponseField name="cbsTaxValue" type="number" required>
      CBS (Contribuição sobre Bens e Serviços) tax for this line, in local currency.
    </ResponseField>

    <ResponseField name="ibsETaxValue" type="number" required>
      IBS-E (Imposto Estadual sobre Bens e Serviços) tax for this line, in local currency.
    </ResponseField>

    <ResponseField name="ibsMTaxValue" type="number" required>
      IBS-M (Imposto Municipal sobre Bens e Serviços) tax for this line, in local currency.
    </ResponseField>

    <ResponseField name="icmsTaxValue" type="number" required>
      Total ICMS (or equivalent domestic sales tax) for this line, in local currency.
    </ResponseField>

    <ResponseField name="importTaxValue" type="number" required>
      Total import tax for this line, in local currency.
    </ResponseField>

    <ResponseField name="totalTaxValue" type="number" required>
      Total tax for this line: `icmsTaxValue` + `importTaxValue`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="totals" type="object" required>
  Aggregates for the whole request.

  <Expandable title="Totals properties">
    <ResponseField name="cbsTaxValue" type="number" required>
      Sum of CBS (Contribuição sobre Bens e Serviços) tax across all lines.
    </ResponseField>

    <ResponseField name="ibsETaxValue" type="number" required>
      Sum of IBS-E (Imposto Estadual sobre Bens e Serviços) tax across all lines.
    </ResponseField>

    <ResponseField name="ibsMTaxValue" type="number" required>
      Sum of IBS-M (Imposto Municipal sobre Bens e Serviços) tax across all lines.
    </ResponseField>

    <ResponseField name="icmsTaxValue" type="number" required>
      Sum of `icmsTaxValue` across all lines.
    </ResponseField>

    <ResponseField name="importTaxValue" type="number" required>
      Sum of `importTaxValue` across all lines.
    </ResponseField>

    <ResponseField name="totalTaxValue" type="number" required>
      Sum of `totalTaxValue` across all lines (equivalently, `totals.icmsTaxValue` + `totals.importTaxValue`).
    </ResponseField>
  </Expandable>
</ResponseField>

## Errors

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    The request is missing the `Authorization` header, the bearer format is invalid, or the token is invalid.
  </Accordion>
</AccordionGroup>
