CEP lookup and search in the API
Look up a CEP's address via the API, even without a key, search CEPs by address, prefix, state or IBGE code and find companies by CEP or CEP range.
Tip: Concepts on this page: CEPs, streets and IBGE codes.
The API returns the address, type and status of each CEP as registered in the Correios National Address Directory (DNE), in Lookup CEP, when the CEP is known, and in Search CEP, when only part of the address is known. Lookup CEP also accepts public access, without an API key. What a CEP is, its types and its status are in CEPs, streets and IBGE codes.
Request
| Operation | Use | API key |
|---|---|---|
| Lookup CEP | Address, type and status of a known CEP | Optional |
| Search CEP | CEPs found by address, prefix, type, status, state or municipality, in pages | Required |
Lookup CEP
Send the CEP’s 8 digits in the path, with no hyphen and with leading zeros:
GET /v2/postal-codes/01452922 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY | Parameter | Location | Format |
|---|---|---|
code | Path | CEP with exactly 8 characters, such as 01452922 |
- The operation has no query parameters. With a key, unrecognized names in the URL are ignored; without a key, any parameter makes the request return
401API_, as explained in Public access.KEY_ MISSING - The CEP must be exactly 8 digits. Any other value, such as a CEP with a hyphen, without its leading zeros, with punctuation or with letters, is rejected with
400and not charged: strip the punctuation and restore the leading zeros before sending.
Search CEP
Send the filters as query parameters. All of them are optional, and each filter added narrows the results:
GET /v2/postal-codes?search=faria%20lima&state.in=SP&status.code.in=ACTIVE&limit=20 HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY | Parameter | Function | Format |
|---|---|---|
search | Free text looked up in the CEP, name, street, number, district, city and state | At least 1 character |
type. | CEP types to include | LOCALITY, STREET, LARGE_, OPERATIONAL_, COMMUNITY_ |
status. | Statuses to include | ACTIVE, DEACTIVATED |
state. | States to include | Abbreviations, such as SP,RJ |
municipality. | Municipalities to include | 7-digit IBGE codes, such as 3550308 |
sort | Field used to sort records | relevance (default), code, state, city, municipality |
order | Sort direction | ASC, DESC. When omitted, DESC for relevance and ASC for the others |
limit | Records per page | From 1 to 1000, default 10 |
cursor | Reading the next page | The nextCursor of the previous response, with no other parameter |
- Multi-value filters accept comma-separated values or the repeated parameter. Different filters are combined with AND.
searchonly returns records containing all the given words, in any order, and follows the text matching rules of the CNPJ search. It also matches the abbreviated forms of names registered in the DNE.searchfinds CEPs by their first digits, from 3 digits on:search=01452returns the CEPs starting with01452.- The extra details (
details) are not part of the text search. - With the default
sort=relevance, records come in ascending CEP order, and with a multi-wordsearch, records containing the words as an exact phrase come first, each group following CEP order. The other values sort by the response field of the same name, and ties follow ascending CEP. sort=citycompares names by character code, without ignoring case or accents: uppercase letters come before lowercase ones, and accented letters come after both, soÁguas de Lindóiacomes afterZortéa.
The full rules for filters, text, sorting and paging are in CNPJ search and in Search filters, Sorting and Pagination, in the Reference.
Response fields
Lookup CEP returns one record, trimmed below:
{
"updatedAt": "2026-01-27T03:00:00.000Z",
"code": "01452922",
"type": { "code": "LARGE_RECIPIENT", "label": "Grande Usuário" },
"status": { "code": "ACTIVE", "label": "Ativo" },
"name": "Edifício Barão de Iguatemi",
"street": "Avenida Brigadeiro Faria Lima",
"number": "2369",
"details": null,
"district": "Jardim Paulistano",
"city": "São Paulo",
"state": "SP",
"municipality": "3550308"
} | Field | Content |
|---|---|
updatedAt | Last update of the record from Correios data |
code | CEP, with 8 digits |
type | CEP type, with code and label, described in Codes and values |
status | Status of the CEP in the DNE, with code and label |
name | Name of the large recipient, operational unit or community PO box, or null for the other types |
street | Name of the street, or null for LOCALITY |
number | Number on the street, when available, or null |
details | Extra details of the street, which can delimit a stretch, as in até 610 - lado par, or null |
district | Name of the neighborhood or district, or null |
city | Name of the municipality. For a district’s CEP, the name of the municipality the district belongs to |
state | State abbreviation |
municipality | Municipality IBGE code, with 7 digits |
municipality holds the same code as address. in the addresses of establishments and of state and SUFRAMA registrations, and municipality filters take this code, not the name: municipality. in Search CEP, and address. or address. in Search CNPJ. To get the code from the name, search for the municipality’s name in Search CEP with state., check city in the record returned and read municipality.
Search CEP returns a page, with each item of records in the same format as Lookup CEP. Illustrative excerpt:
{
"total": 250,
"limit": 20,
"nextCursor": "9ed11ce29dc14f9c78304c1a403e9f85",
"records": [
{
"code": "01452922",
"type": { "code": "LARGE_RECIPIENT", "label": "Grande Usuário" },
"status": { "code": "ACTIVE", "label": "Ativo" },
"name": "Edifício Barão de Iguatemi",
"street": "Avenida Brigadeiro Faria Lima",
"city": "São Paulo",
"state": "SP",
"municipality": "3550308"
}
]
} The page carries the records in records, the number of records found in total, the page size in limit and the cursor of the next page in nextCursor, which is null on the last page. The page format and the cursor rules are in Response format.
Finding companies by CEP
In Search CNPJ, the CEP and the municipality of the address work as filters:
| Filter | Function |
|---|---|
address. | One or more CEPs |
address. and address. | A range of CEPs, such as 01000000 to 05999999, with both bounds included |
address. and address. | Municipalities to include or exclude, by IBGE code |
address. | States to include |
GET /v2/establishments?address.postalCode.in=01452922&status.code.in=ACTIVE HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY - The search compares the CEP registered in the CNPJ registry at the Receita Federal, not the DNE. To cover a whole area, use a CEP range or the municipality, as explained in Correios CEP and Receita CEP.
- The reverse also works: the
address.of an establishment, or of a CPF’s registrations, can be sent to Lookup CEP.postalCode - The other filters, the result count and paging are in CNPJ search.
- Coordinates, map and street view of an establishment’s address are in Location and maps.
Codes and values
Base your logic on code. The label is for display only and changes with the language, as explained in Response format.
CEP types
type. | label in pt-BR and en-US | What it covers | Filled fields |
|---|---|---|---|
LOCALITY | Localidade, Locality | A whole locality. When active, it is the general CEP of a locality without street-level CEPs | Only city, state and municipality; the other address fields are null |
STREET | Logradouro, Street | A street or a stretch of it, which details can delimit | street and, when available, district and details; name and number are null |
LARGE_ | Grande Usuário, Large Recipient | A single recipient, such as a building or a company | name, street and, when available, number and district; details describes the street stretch, not the recipient |
OPERATIONAL_ | Unidade Operacional, Operational Unit | A Correios unit | Same as LARGE_ |
COMMUNITY_ | Caixa Postal Comunitária, Community PO Box | A PO box for community use | name, street and, when available, number and district; details is null |
Statuses
status. | label in pt-BR and en-US | Meaning |
|---|---|---|
ACTIVE | Ativo, Active | CEP in use in the DNE |
DEACTIVATED | Desativado, Deactivated | CEP ending in 000 with the same 5-digit prefix as street-level CEPs, which matches no street or recipient |
Deactivated CEPs are always of type LOCALITY and carry only city, state and municipality. Lookup CEP also returns deactivated CEPs. In Search CEP, send status. to get only the CEPs in use.
Sources and updates
- Lookup CEP and Search CEP serve cached data only: they make no live queries and do not accept
maxAge. updatedAtgives when the record was last updated from the Correios DNE.- A new CEP can only be found after the DNE edition that includes it, as explained in DNE updates.
Billing
Lookup CEP and Search CEP consume cached queries only, including on 404 responses and on searches with no results, and public access is not charged. The consumption of each operation is in the Metering Rules, under Consumption in the API.
Frequent errors
| Status | Code | Cause | Action |
|---|---|---|---|
400 | REQUEST_ | CEP without exactly 8 digits, filter, sort or order with an invalid value, unknown parameter name in Search CEP or cursor sent with other parameters | Fix what errors points to and send the CEP with 8 digits |
400 | PAGE_ | The cursor has expired or is unknown | Restart the search from the first page |
401 | API_ | Search CEP without a key, or Lookup CEP without a key and with query parameters | Send an API key or remove the parameters from the public request |
402 | CACHED_, LIVE_ or OVERAGE_ | The organization’s quota or overage budget is used up. What each code means is in Error codes | Follow one of the ways out in Quota used up |
404 | POSTAL_ | No record has the CEP | Check the digits and do not retry right away, since with a key the 404 is charged. To find CEPs with the same prefix, send the first digits as search to Search CEP |
429 | RATE_ or CONCURRENCY_ | Requests above the usage limits, the plan’s with a key and the IP address’s under public access | Reduce the pace or the parallelism, or use an API key |
A search with no matches returns 200 with empty records, never 404. The other errors are in Limits and errors.
Use cases
- Address autofill: in a sign-up form, look up the CEP typed in and fill in street, district, city and state. At low volume, the lookup can use public access.
- CEP finder: offer a search box backed by Search CEP,
searchand a smalllimitfor users who do not know their CEP. A smalllimitkeeps consumption low, as set out in the Metering Rules. - Support for record checks: check that the CEP provided exists and is active (
ACTIVE) and compare the address provided with the DNE address. - Municipality normalization: store
municipalitywith the address to identify the municipality by its IBGE code in reports and tax documents. - CEPs by municipality: go through the CEPs of a state grouped by municipality, ordered by IBGE code and then by CEP, with
state.andin sort=municipality. - Companies by area: search for companies by CEP, CEP range or municipality in Search CNPJ.
- Recipients with their own CEP: find the buildings and companies with an exclusive CEP in an area with
type.andcode. in=LARGE_ RECIPIENT municipality..in
In the app
In the CEP app, Search postal codes uses the same filters as Search CEP, and each CEP’s record shows the Lookup CEP data with the establishments registered at the CEP. See Search CEPs by address and CEP record and companies.
Notes
- Store the CEP as text, never as a number, to keep the leading zeros, as explained in Identifiers as text.
- Lookup CEP does not return coordinates. Coordinates exist only for an establishment’s address, as described in Location and maps.
- Search CEP filters accept only the
inoperator. Street, district and city are found throughsearch. - All parameters are in Lookup CEP and Search CEP, in the Reference.