Skip to content
CEP lookup and search in the API
API · Features

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

OperationUseAPI key
Lookup CEPAddress, type and status of a known CEPOptional
Search CEPCEPs found by address, prefix, type, status, state or municipality, in pagesRequired

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
ParameterLocationFormat
codePathCEP 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 401 API_KEY_MISSING, as explained in Public access.
  • 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 400 and 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
ParameterFunctionFormat
searchFree text looked up in the CEP, name, street, number, district, city and stateAt least 1 character
type.code.inCEP types to includeLOCALITY, STREET, LARGE_RECIPIENT, OPERATIONAL_UNIT, COMMUNITY_PO_BOX
status.code.inStatuses to includeACTIVE, DEACTIVATED
state.inStates to includeAbbreviations, such as SP,RJ
municipality.inMunicipalities to include7-digit IBGE codes, such as 3550308
sortField used to sort recordsrelevance (default), code, state, city, municipality
orderSort directionASC, DESC. When omitted, DESC for relevance and ASC for the others
limitRecords per pageFrom 1 to 1000, default 10
cursorReading the next pageThe 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.
  • search only 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.
  • search finds CEPs by their first digits, from 3 digits on: search=01452 returns the CEPs starting with 01452.
  • 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-word search, 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=city compares 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óia comes after Zorté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"
}
FieldContent
updatedAtLast update of the record from Correios data
codeCEP, with 8 digits
typeCEP type, with code and label, described in Codes and values
statusStatus of the CEP in the DNE, with code and label
nameName of the large recipient, operational unit or community PO box, or null for the other types
streetName of the street, or null for LOCALITY
numberNumber on the street, when available, or null
detailsExtra details of the street, which can delimit a stretch, as in até 610 - lado par, or null
districtName of the neighborhood or district, or null
cityName of the municipality. For a district’s CEP, the name of the municipality the district belongs to
stateState abbreviation
municipalityMunicipality IBGE code, with 7 digits

municipality holds the same code as address.municipality in the addresses of establishments and of state and SUFRAMA registrations, and municipality filters take this code, not the name: municipality.in in Search CEP, and address.municipality.in or address.municipality.nin in Search CNPJ. To get the code from the name, search for the municipality’s name in Search CEP with state.in, 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:

FilterFunction
address.postalCode.inOne or more CEPs
address.postalCode.gte and address.postalCode.lteA range of CEPs, such as 01000000 to 05999999, with both bounds included
address.municipality.in and address.municipality.ninMunicipalities to include or exclude, by IBGE code
address.state.inStates 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.postalCode of an establishment, or of a CPF’s registrations, can be sent to Lookup CEP.
  • 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.codelabel in pt-BR and en-USWhat it coversFilled fields
LOCALITYLocalidade, LocalityA whole locality. When active, it is the general CEP of a locality without street-level CEPsOnly city, state and municipality; the other address fields are null
STREETLogradouro, StreetA street or a stretch of it, which details can delimitstreet and, when available, district and details; name and number are null
LARGE_RECIPIENTGrande Usuário, Large RecipientA single recipient, such as a building or a companyname, street and, when available, number and district; details describes the street stretch, not the recipient
OPERATIONAL_UNITUnidade Operacional, Operational UnitA Correios unitSame as LARGE_RECIPIENT
COMMUNITY_PO_BOXCaixa Postal Comunitária, Community PO BoxA PO box for community usename, street and, when available, number and district; details is null

Statuses

status.codelabel in pt-BR and en-USMeaning
ACTIVEAtivo, ActiveCEP in use in the DNE
DEACTIVATEDDesativado, DeactivatedCEP 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.code.in=ACTIVE 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.
  • updatedAt gives 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

StatusCodeCauseAction
400REQUEST_VALIDATION_FAILEDCEP without exactly 8 digits, filter, sort or order with an invalid value, unknown parameter name in Search CEP or cursor sent with other parametersFix what errors points to and send the CEP with 8 digits
400PAGE_CURSOR_INVALIDThe cursor has expired or is unknownRestart the search from the first page
401API_KEY_MISSINGSearch CEP without a key, or Lookup CEP without a key and with query parametersSend an API key or remove the parameters from the public request
402CACHED_QUERY_QUOTA_EXCEEDED, LIVE_QUERY_QUOTA_EXCEEDED or OVERAGE_BUDGET_EXCEEDEDThe organization’s quota or overage budget is used up. What each code means is in Error codesFollow one of the ways out in Quota used up
404POSTAL_CODE_NOT_FOUNDNo record has the CEPCheck 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
429RATE_LIMIT_EXCEEDED or CONCURRENCY_LIMIT_EXCEEDEDRequests above the usage limits, the plan’s with a key and the IP address’s under public accessReduce 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, search and a small limit for users who do not know their CEP. A small limit keeps 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 municipality with 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.in and 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.code.in=LARGE_RECIPIENT and 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 in operator. Street, district and city are found through search.
  • All parameters are in Lookup CEP and Search CEP, in the Reference.

Informational content that may change without notice. It is not tax, accounting or legal advice, and CNPJá's terms and policies prevail over this page.