Shipping to Brazil

Ship to Brazil: the CEP with its hyphen, a CPF or CNPJ on both ends, and the fiscal document some carriers need.

In Brazil the postal code, the CEP, resolves the city, the state and the neighborhood. An address needs the CEP with its hyphen, the house number in its own field, and a CPF or CNPJ on both ends.

At a glance

Postal codeThe CEP, with its hyphen: 01310-200
StateA two-letter code, in state: SP, RJ
CityThe name: São Paulo
House numbernumber, in its own field
Tax IDCPF (11 digits) or CNPJ (14), in identificationNumber, on both origin and destination
Fiscal documentSome carriers need a DC-e or NF-e for a domestic label
CurrencyQuote in BRL. The label is charged in your account's currency
In sandboxBuslog runs the full cycle, with an origin branch

What an address to Brazil needs

What the label call needs. Two rows at the end exist only in the address form (GET /generic-form?country_code=BR&form=address_info):

FieldRequiredWhat goes in it
postalCodeyesThe CEP. Send it with the hyphen — 01310-200
streetyesAvenida Paulista — the street only
numberyes1578, in its own field, not in street
cityyesSão Paulo
stateyesA two-letter code — SP, RJ, MG. 27 of them, no duplicates
identificationNumberyesCPF (11 digits) or CNPJ (14). Required on both origin and destination
districtnoThe bairro. The CEP usually resolves it
referencenoFree text for the carrier — where the apartment goes
interior_numberform onlyThe form's apartment field. The Shipping API has no such field and ignores it: put the apartment in reference
state_registrationform onlyThe inscrição estadual. The Shipping API ignores it too

Send identificationNumber, in camelCase. The address form calls it identification_number; the API ignores that name, and the shipment goes out without the tax ID.

The CEP needs its hyphen

An eight-digit CEP has to be sent formatted:

01310200   →   01310-200

If you store the CEP as eight digits, insert the hyphen after the fifth digit before you send it, as Envia's own integrations do.

Argentina and the United States have their own quirks in the same family — see Addresses by Country.

CPF or CNPJ

DocumentShapeWho
CPF11 digitsA person
CNPJ14 digitsA company

The length tells them apart, and you send only the number. The check digits are validated, so a well-formed but invalid number is rejected later in the flow, not when you save the address.

Brazil and Colombia are the only two countries where this field is required on both ends of the shipment.

The states

API reference → Get states by country

curl https://queries.envia.com/state?country_code=BR

27 states, each with a unique two-letter code: SP, RJ, MG, BA, RS. Send the code, not the name.

Do not use GET /provinces/{state_code}. It searches every country at once, and AM, CE and TO are also Colombian department codes. Use the CEP instead: it resolves the city, the state and the bairro in one call.

All 27 states and their codes
CodeName
ACAcre
ALAlagoas
APAmapa
AMAmazonas
BABahia
CECeara
DFDistrito Federal
ESEspirito Santo
GOGoias
MAMaranhao
MTMato Grosso
MSMato Grosso do Sul
MGMinas Gerais
PAPara
PBParaiba
PRParana
PEPernambuco
PIPiaui
RJRio de Janeiro
RNRio Grande do Norte
RSRio Grande do Sul
RORondonia
RRRoraima
SCSanta Catarina
SPSao Paulo
SESergipe
TOTocantins

The list comes from GET /state?country_code=BR.

A complete address

{
  "name": "João Silva",
  "email": "[email protected]",
  "phone": "+55 11 00000 0000",
  "street": "Avenida Paulista",
  "number": "1578",
  "district": "Bela Vista",
  "city": "São Paulo",
  "state": "SP",
  "postalCode": "01310-200",
  "country": "BR",
  "identificationNumber": "12345678909",
  "reference": "Em frente ao MASP"
}

ICMS, and whether you need items[]

API reference → ICMS rate between two Brazilian states · What a route requires: taxes, items and customs paperwork

Two things that are decided by the route, not by a rule you can hardcode:

ICMS — the interstate tax — comes from its own endpoint, with the two state codes:

curl https://geocodes.envia.com/brazil/icms/SP/RJ
# {"value":"12.00"}

ICMS is not part of the quote. totalPrice is what Envia charges you, its own taxes included: on a Rio → São Paulo Buslog quote, basePrice 24.00 + taxes 3.84 = totalPrice 27.84. The ICMS rate — 12% between São Paulo and Rio — is for the fiscal documents you issue. Do not add it to totalPrice.

Whether the shipment needs items[] and a commercial invoice comes from POST /location-requirements:

{ "origin":      { "country_code": "BR", "state_code": "SP", "postal_code": "01310100" },
  "destination": { "country_code": "BR", "state_code": "RJ", "postal_code": "20040020" } }
{ "applyTaxes": true, "includeBOL": false,
  "isInternalEU": false, "isInternalGB": false, "isInternalUK": false }

applyTaxes: true means the route is domestic for tax purposes: no items[], no customs paperwork. (includeBOL is always its opposite, so read applyTaxes.) Within Brazil it is always true. What a domestic parcel can need instead is a fiscal document, which some carriers ask for: see The fiscal document below.

Ship it, end to end

One shipment from start to finish: Rio de Janeiro → São Paulo, with Buslog. Every request runs as written in sandbox, with the address above as the destination; only the tracking number is a placeholder.

Find the carriers that serve the lane

API reference → Get Carriers With Services

curl https://queries.test.envia.com/available-carrier/BR/0/1 \
  --header "Authorization: Bearer $ENVIA_TOKEN"

BR/0/1 reads: from Brazil, domestic (0), parcel (1). Each carrier comes with the services you can pass when you create the label.

Quote

API reference → Get Shipping Rates

curl --request POST \
  --url https://api-test.envia.com/ship/rate/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "origin": {
      "name": "Loja Rio",
      "company": "Loja Demo",
      "email": "[email protected]",
      "phone": "+55 21 00000 0000",
      "street": "Avenida Rio Branco",
      "number": "156",
      "district": "Centro",
      "city": "Rio de Janeiro",
      "state": "RJ",
      "postalCode": "20040-003",
      "country": "BR",
      "identificationNumber": "12345678909"
    },
    "destination": {
      "name": "João Silva",
      "email": "[email protected]",
      "phone": "+55 11 00000 0000",
      "street": "Avenida Paulista",
      "number": "1578",
      "district": "Bela Vista",
      "city": "São Paulo",
      "state": "SP",
      "postalCode": "01310-200",
      "country": "BR",
      "identificationNumber": "12345678909",
      "reference": "Em frente ao MASP"
    },
    "packages": [
      {
        "content": "Ropa",
        "amount": 1,
        "type": "box",
        "weight": 1,
        "insurance": 0,
        "declaredValue": 0,
        "weightUnit": "KG",
        "lengthUnit": "CM",
        "dimensions": {
          "length": 20,
          "width": 20,
          "height": 10
        }
      }
    ],
    "shipment": {
      "carrier": "buslog",
      "type": 1
    },
    "settings": {
      "currency": "BRL"
    }
  }'

shipment.carrier takes one carrier per request; call it once per carrier to compare. Prices come back in settings.currency.

{
  "meta": "rate",
  "data": [
    {
      "carrier": "buslog",
      "service": "ground",
      "serviceDescription": "Buslog Balcão-Entrega",
      "deliveryEstimate": "1-2 días",
      "totalPrice": 27.84,
      "currency": "BRL"
    }
  ]
}

deliveryEstimate is text for a person, in Spanish as the carrier sends it. Show it as is.

Pick the origin branch, if the service needs one

API reference → Get Branches

Buslog's service is Balcão-Entrega — you drop the parcel at a branch and it is delivered to the door. A branch-to-door service refuses the label without telling it which branch:

The quote tells you. A branch-to-door service comes back with "dropOff": 1 and "dropOffDescription": "Sucursal a puerta"; a door-to-door service has "dropOff": 0. Check it before you offer the service, so you know to ask for a branch.

1127  Origin branch code is required for branch to home service.
curl "https://queries.test.envia.com/branches/buslog/BR?zipcode=20040-003" \
  --header "Authorization: Bearer $ENVIA_TOKEN"

Pick a branch that accepts parcels ("admission": true) and send its branch_code as origin.branchCode. Check the branch's state: the zipcode filter sorts the list but does not filter it, so the first branch can be in another state. More in Drop-off Points.

Create the label

API reference → Generate a Shipping Label

curl --request POST \
  --url https://api-test.envia.com/ship/generate/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "origin": {
      "name": "Loja Rio",
      "company": "Loja Demo",
      "email": "[email protected]",
      "phone": "+55 21 00000 0000",
      "street": "Avenida Rio Branco",
      "number": "156",
      "district": "Centro",
      "city": "Rio de Janeiro",
      "state": "RJ",
      "postalCode": "20040-003",
      "country": "BR",
      "identificationNumber": "12345678909",
      "branchCode": "5"
    },
    "destination": {
      "name": "João Silva",
      "email": "[email protected]",
      "phone": "+55 11 00000 0000",
      "street": "Avenida Paulista",
      "number": "1578",
      "district": "Bela Vista",
      "city": "São Paulo",
      "state": "SP",
      "postalCode": "01310-200",
      "country": "BR",
      "identificationNumber": "12345678909",
      "reference": "Em frente ao MASP"
    },
    "packages": [
      {
        "content": "Roupas",
        "amount": 1,
        "type": "box",
        "weight": 1,
        "insurance": 0,
        "declaredValue": 0,
        "weightUnit": "KG",
        "lengthUnit": "CM",
        "dimensions": {
          "length": 20,
          "width": 20,
          "height": 10
        }
      }
    ],
    "shipment": {
      "carrier": "buslog",
      "service": "ground",
      "type": 1
    },
    "settings": {
      "currency": "BRL",
      "printFormat": "PDF",
      "printSize": "STOCK_4X6"
    }
  }'
{
  "meta": "generate",
  "data": [
    {
      "carrier": "buslog",
      "service": "ground",
      "trackingNumber": "7000000001",
      "trackUrl": "https://test.envia.com/rastreo?label=7000000001&cntry_code=br",
      "label": "https://…/buslog/7000000001.pdf",
      "totalPrice": 94.18,
      "currency": "MXN"
    }
  ]
}

The label is charged in your account's currency. The quote above is BRL 27.84; a Mexican account is charged MXN 94.18.

The fiscal document: DC-e or NF-e

API reference → Generate DC-e · Generate a Shipping Label

Some carriers will not issue a domestic label without one. Gollog, on the same lane:

1129  For shipments in Brazil, it is necessary to provide the DC-e or NF-e information.

It goes on each package, in packages[].xmlData[], with documentType set to nfe when you have a fiscal invoice or dce when you do not:

documentTypeFields
nfenfeKey (44 digits), nfeNumber, nfeSerie, nfeDate, nfeValue
dcedceKey (44 digits), dceNumber, dceSerie, dceDate, dceValue — all from Generate DC-e

Selling without an invoice is what the DC-e is for. Generate it before the label, and cancel it if the parcel does not go out.

Track it

API reference → Track Shipments

curl --request POST \
  --url https://api-test.envia.com/ship/generaltrack/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "trackingNumbers": [
      "7000000001"
    ]
  }'

A label you just created answers "status": "Created". For anything at volume, subscribe to webhooks instead of polling.

Cancel it, if it does not ship

API reference → Cancel a Shipment

curl --request POST \
  --url https://api-test.envia.com/ship/cancel/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "carrier": "buslog",
    "trackingNumber": "7000000001"
  }'

The response includes refundedAmount and balanceReturned: the charge returns to your balance.

International, into and out of Brazil

A shipment that crosses the Brazilian border is an ordinary international shipment: see International Shipping & Customs. To know whether a route needs items[] and customs paperwork, ask What a route requires rather than comparing the two countries.

Envia's own integrations also send items[] on domestic Brazilian shipments. Carriers issue domestic labels without them, so treat them as a safe default rather than a requirement.

The fiscal document applies across the border too: see The fiscal document: DC-e or NF-e above, and DC-e (Brazil).

Into Brazil from Chile, DHL int_express issues the label, with the commercial invoice in additionalFiles. The destination keeps everything above: the CPF in identificationNumber and the CEP with its hyphen. On the package, send items[] with an hsCode, declaredValue in your account's currency and items[].price in Chile's. For a full international request, see Shipping to Hong Kong.

Testing in sandbox

Which Brazilian carriers work in sandbox
  • Buslog runs the full cycle, with an origin branch.
  • UPS issues a label with the placeholder tracking number 1ZXXXXXXXXXXXXXXXX, which cannot be tracked or canceled.
  • Gollog asks for the fiscal document.
  • Correios does not quote.
  • Jadlog returns the same rate for any address, priced in MXN. A rate from it does not mean the address is right: check the CEP with Geocodes.
  • From Chile, FedEx does not quote the lane into Brazil.
  • trackUrl opens a tracking page that does not know sandbox shipments. It works for labels created in production.

In production you use the carriers enabled on your account.

Next steps


Did this page help you?