API reference · Callbacks and Webhooks

Tax Calculation Request

POSTWebhook

Description

This is a complete example of the request that CWS will send to your Tax Calculation endpoint.

CWS sends one request per selling company in the order, with your store's access token in the Authorization header and in the token field of the body.

Your endpoint responds with the calculation. The response body must follow the format documented in Expected response: the same field names, the same types and the same structure as the example.

The calculation is only accepted when the response has status: "ok". With any other value, CWS treats the calculation as an error and records the response's mensagem as the reason.

Parameters

Headers

FieldTypeDescription
Authorizationstring

Your store's access token, in the Bearer <token> format: the same as the token field of the body. CWS gets the token from your store's authentication endpoint.

tenantIdstring

Sent only when set up in your store's tax calculation integration. The header name and value are the ones agreed with your store.

Payload

FieldTypeDescription
clientestring

CPF or CNPJ of the order's customer.

empresastring

Document of the company that sells the items. Each company in the order gets its own request.

finalidadeinteger

Code of the purpose (taxPurpose) with which CWS received the order's tax calculation.

itensarray of object

The company's items in the order.

Fields in itens[]

num_pedidostring

Always "0".

tokenstring

Your store's access token, the same as the Authorization header.

ufstring

State (UF) of the first address given for the calculation.

valor_fretenumber

Freight value of the company's items.

valor_pedidonumber

Sum of sale price × quantity of the company's items, without the freight.

itens[]
FieldTypeDescription
itemstring

Item identifier in the cart.

partner_part_codestring

Internal product code (internalPartCode).

pre_unitstring

Unit sale price, as text with 2 decimal places (e.g.: 451.99).

qtdeinteger

Item quantity.

Tax calculation for an order with 2 items
{
  "cliente": "57.578.030/0001-05",
  "empresa": "30.424.972/0001-74",
  "finalidade": 4,
  "itens": [
    {
      "item": "123456",
      "partner_part_code": "FO0002248281",
      "pre_unit": "451.99",
      "qtde": 45
    },
    {
      "item": "7891011",
      "partner_part_code": "FO0002248279",
      "pre_unit": "654.99",
      "qtde": 5
    }
  ],
  "num_pedido": "0",
  "token": "SEU_TOKEN_GERADO",
  "uf": "ES",
  "valor_frete": 0,
  "valor_pedido": 23614.5
}

Expected response

200 · Tax calculation for an order with 2 items
{
  "empresa": "30.424.972/0001-74",
  "num_pedido": "0",
  "cliente": "57.578.030/0001-05",
  "mensagem": "sucesso",
  "status": "ok",
  "itens": [
    {
      "item": "123456",
      "st": "0.000000",
      "ipi": "11.120000",
      "icms": 0,
      "pis": 0,
      "cofins": 0
    },
    {
      "item": "7891011",
      "st": "0.000000",
      "ipi": "0.000000",
      "icms": 0,
      "pis": 0,
      "cofins": 0
    }
  ]
}