# CEPs, streets and IBGE codes

> How CEPs and IBGE codes work on CNPJá: CEP types, deactivated CEPs, DNE editions and why the Correios CEP may differ from the one in the Receita registry.

The [CEP](https://cnpja.com/en-us/docs/glossary#cep) is the Brazilian postal code and identifies a Correios delivery area, and the [IBGE code](https://cnpja.com/en-us/docs/glossary#código-ibge--ibge-code) identifies a municipality. CNPJá shows each CEP as Correios registers it and uses both codes to find companies by area.

## How a CEP works

A CEP has 8 digits, which go from the most general to the most specific: the first one indicates a region of the country, and the following ones narrow the area down to a [street](https://cnpja.com/en-us/docs/glossary#logradouro--street) or a single recipient. As a result, CEPs that start the same way lie in the same area, and a CEP range, such as `01452000` to `01452999`, covers one area.

CEPs are assigned by Correios and published in the National Address Directory ([DNE](https://cnpja.com/en-us/docs/glossary#dne)), the official source of CEPs. For each CEP, CNPJá shows the address, type and status registered in the DNE.

A CEP is a code, not a number: write and store its 8 digits as text, with the leading zeros (`01452922`, never `1452922`). On screen, it shows with a hyphen, as in `01452-922`. The rules for every identifier are in [Identifiers as text](https://cnpja.com/en-us/docs/data/format#identifiers).

CEPs have no coordinates on CNPJá. Coordinates exist only for an establishment's address, as explained in [Address coordinates and imagery](https://cnpja.com/en-us/docs/data/location).

## CEP types and status

The DNE classifies each CEP by type, and the type sets what the CEP's address holds:

| Type | What the CEP covers | What the address holds |
| --- | --- | --- |
| **Locality** | A whole locality. When active, it is the general CEP of a municipality or district without street-level CEPs | Only the municipality and the state |
| **Street** | A street, avenue or square, or a stretch of it, such as one side of the street or a range of numbers | The street and, when available, the district and the details that delimit the stretch |
| **Large recipient** | A single recipient with a high volume of mail, such as a building or a company | The recipient's name, the street and, when available, the number and the district |
| **Operational unit** | A Correios unit | The same as a large recipient |
| **Community PO box** | A PO box for community use | The name, the street and, when available, the number and the district |

Every CEP holds the name of the municipality, the state and the municipality's IBGE code. A district's CEP holds the municipality the district belongs to.

The status tells whether the CEP is in use:

- **Active:** the CEP is in use in the DNE.
- **Deactivated:** the CEP no longer takes mail. It is the CEP ending in `000` of a locality with street-level CEPs, when it matches no street or recipient. It is therefore always of type **Locality** and holds only the municipality and the state.

A deactivated CEP can still appear in older records, including a CNPJ's address at the Receita Federal. For a full address, use the CEP of the street or the recipient.

## DNE updates

Correios publishes the DNE in periodic editions, and CNPJá updates its CEP data with each new edition. Any change made by Correios, such as a new CEP or a renamed street, only appears on CNPJá after the edition that includes it.

CEP data always comes from the [cache](https://cnpja.com/en-us/docs/data/freshness#cached): there is no live query to Correios, and the max age does not apply to it. Each CEP carries the date it was last updated from the DNE.

## Municipality IBGE code

The IBGE code identifies each Brazilian municipality with 7 digits, such as `3550308` for São Paulo. It is assigned by the Brazilian Institute of Geography and Statistics (IBGE), which publishes the [official code table](https://www.ibge.gov.br/explica/codigos-dos-municipios.php).

Unlike the name, the code is stable and does not depend on spelling, accents or abbreviations. That makes it the recommended way to identify a municipality in spreadsheets and integrations, and it is the code required in electronic tax documents, such as the NF-e.

On CNPJá, the IBGE code goes with the municipality's name in the CEP's address, where it is never missing, and in the addresses of the establishment and of state and SUFRAMA registrations, where it can be missing. Municipality filters take the code, not the name.

To find a municipality's code from its name, look the municipality up in the **City** filter, which shows the code beside each name, or search for the name in **Search postal codes** and read the **IBGE code** column.

## Correios CEP and Receita CEP

The CEP of an establishment's address comes from the CNPJ registry at the Receita Federal, as stated by the company itself, not from the DNE. They are separate registries and can differ in the street's spelling, in the district or in the CEP itself: an older record, for example, can keep a CEP that Correios has since deactivated.

The search for companies by CEP compares the CEP in the Receita registry. An establishment located on a street, but registered with another CEP, does not appear under that street's CEP. To cover a whole area, regardless of each record's CEP, use a CEP range or the municipality.

A divergence can only be corrected at the source: the CNPJ's address at the Receita Federal and the CEP at Correios. The correction appears on CNPJá after the next update, as explained in [How to correct data at the source](https://cnpja.com/en-us/docs/data/sources#correct-at-source).

## Find companies by area

The company search filters by the address in the Receita registry, from the narrowest area to the widest:

| Filter | What it finds |
| --- | --- |
| **Postal code** | Establishments registered with exactly that CEP |
| **Postal code range** | Establishments with a CEP between two values, both included, such as the CEPs starting with `01452` (`01452000` to `01452999`) |
| **City** | Establishments in the municipality, by IBGE code |
| **State** | Establishments in the state |

A range on the first 5 digits covers a CEP's area and also catches records made with neighboring or deactivated CEPs of the same area. Each result is an establishment, not a company: the head office and the branches show on separate rows, as explained in [How company search matching works](https://cnpja.com/en-us/docs/data/search-matching).

## Where it appears in the app

- In the **CEP** app, **Search postal codes** finds CEPs by CEP, street, district or municipality, with the **Status**, **Type**, **City** and **State** filters, as explained in [Search CEPs by address](https://cnpja.com/en-us/docs/postal-codes/search).
- Each CEP's record shows the address, type, status and **IBGE code**, shortcuts to search the CEPs and companies of the same area and the **Establishments at this postal code**, by the CEP in the Receita registry. See [CEP record and companies](https://cnpja.com/en-us/docs/postal-codes/record).
- On a CNPJ's record, the address carries the CEP and the **IBGE code**, which leads to the company search for the same municipality, as explained in [The company record](https://cnpja.com/en-us/docs/companies/record).
- In the CNPJ search, the **Postal code**, **Postal code range**, **City** and **State** filters are described in [Search filters](https://cnpja.com/en-us/docs/search/filters#reference).

## In the API

Lookup CEP and Search CEP return the DNE data, and Lookup CEP also accepts public access, with no API key. The IBGE code comes in `municipality` in CEP records and in `address.municipality` in establishment addresses. In Search CNPJ, the address filters cover CEP, CEP range, municipality and state. Parameters, fields and codes are in [CEPs and addresses in the API](https://cnpja.com/en-us/docs/api/postal-codes).
