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 code | The CEP, with its hyphen: 01310-200 |
| State | A two-letter code, in state: SP, RJ |
| City | The name: São Paulo |
| House number | number, in its own field |
| Tax ID | CPF (11 digits) or CNPJ (14), in identificationNumber, on both origin and destination |
| Fiscal document | Some carriers need a DC-e or NF-e for a domestic label |
| Currency | Quote in BRL. The label is charged in your account's currency |
| In sandbox | Buslog 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):
| Field | Required | What goes in it |
|---|---|---|
postalCode | yes | The CEP. Send it with the hyphen — 01310-200 |
street | yes | Avenida Paulista — the street only |
number | yes | 1578, in its own field, not in street |
city | yes | São Paulo |
state | yes | A two-letter code — SP, RJ, MG. 27 of them, no duplicates |
identificationNumber | yes | CPF (11 digits) or CNPJ (14). Required on both origin and destination |
district | no | The bairro. The CEP usually resolves it |
reference | no | Free text for the carrier — where the apartment goes |
interior_number | form only | The form's apartment field. The Shipping API has no such field and ignores it: put the apartment in reference |
state_registration | form only | The inscrição estadual. The Shipping API ignores it too |
Send
identificationNumber, in camelCase. The address form calls itidentification_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
| Document | Shape | Who |
|---|---|---|
| CPF | 11 digits | A person |
| CNPJ | 14 digits | A 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=BR27 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, andAM,CEandTOare 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
| Code | Name |
|---|---|
AC | Acre |
AL | Alagoas |
AP | Amapa |
AM | Amazonas |
BA | Bahia |
CE | Ceara |
DF | Distrito Federal |
ES | Espirito Santo |
GO | Goias |
MA | Maranhao |
MT | Mato Grosso |
MS | Mato Grosso do Sul |
MG | Minas Gerais |
PA | Para |
PB | Paraiba |
PR | Parana |
PE | Pernambuco |
PI | Piaui |
RJ | Rio de Janeiro |
RN | Rio Grande do Norte |
RS | Rio Grande do Sul |
RO | Rondonia |
RR | Roraima |
SC | Santa Catarina |
SP | Sao Paulo |
SE | Sergipe |
TO | Tocantins |
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[]
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:
documentType | Fields |
|---|---|
nfe | nfeKey (44 digits), nfeNumber, nfeSerie, nfeDate, nfeValue |
dce | dceKey (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.
trackUrlopens 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
Crossing a border adds three things: a declaration of the contents, a code that classifies them, and who pays the duties.
Offer branch delivery and drop-off at checkout, and make sure the counter accepts the parcel.
What an address needs in each country, where each value comes from, and five rules that apply everywhere.
Updated 18 days ago