The Webmania CEP API 2.0 looks up a CEP, the 8-digit Brazilian postal code, and returns the full address. It also has an address autocomplete endpoint. Integrate it in your back end with secure token authentication, and pay only for the credits you use. To start, read the Quick guide.
X-Token). Since August 31, 2026, 23:59:59 (America/Sao_Paulo), the API 1.0 endpoints return HTTP 410 Gone. New canonical endpoint: /2/cep/{cep}. See Migrating from API 1.0.What is the CEP API? It turns a CEP into a full address, with the IBGE code of the city. The IBGE code is the official 7-digit city code of the Brazilian Institute of Geography and Statistics, which invoices and other tax documents use. It also suggests addresses while the user types the street name:
Street, neighborhood, city, state and IBGE code from an 8-digit CEP, with GET /2/cep/{cep}.
Search by street name, with filters by state, city and neighborhood, with GET /2/cep/autocomplete.
Each new lookup uses credits. Repeats recognized within the 24-hour window do not use more credits.
Authentication uses the X-Token header. Protect the token and never expose it in the front end.
Send every API request over encrypted HTTPS to the URL https://api.webmania.com.br. The /2/ prefix means you are using version 2.0 of the API.
| URL | HTTP Verb | Function |
|---|---|---|
/2/cep/{cep} | GET | CEP lookup |
/2/cep/autocomplete | GET | Address search |
Every response is a JSON object. Send the X-Token header with your token in every call, always from your back end. See Authentication.
How to integrate the CEP API:
X-Token header. /2/cep/{cep} with the 8-digit CEP. The response has the street, neighborhood, city, state and the IBGE city code. /2/cep/autocomplete with the text in q. The user then picks the address by street name. 401 for the token, 402 for credits, 429 for the per-second limit, and others. The two endpoints work together: autocomplete finds the CEP from the street name, and the CEP lookup returns the IBGE code. Choose by what the user already entered:
An HTTP 2xx status means the request succeeded. When a request fails, the response body is still JSON and always has the error field. For example, if authentication fails, the API returns HTTP 401 with this body ("Acesso restrito." means "Access restricted."):
{
"error": "Unauthorized",
"message": "Acesso restrito."
} The full list of statuses, with what to do for each one, is in Errors.
If you still use the CEP API 1.0, you must change the URL, the endpoint and the authentication. The timeline and the steps are below.
410 Gone. Use the API 2.0.| Date | Change |
|---|---|
2026-04-01 | Credentials in the query string (app_key, app_secret) blocked |
2026-04-30 | X-Token required in every request |
2026-08-31 | Full sunset of the API 1.0: all endpoints turned off |
api.webmania.com.br/2/cep/{cep} instead of the legacy endpoint /api/1/cep/{cep}X-Token header (remove app_key and app_secret from the query string)New feature: The autocomplete endpoint searches by street name. It was not available in the API 1.0.
Take this reference to your AI assistant, integrate the API with an official SDK, or start from the ready-made modules and examples.
Send an AI the section index of this reference: it reads the index and fetches only the sections it needs, in Markdown. The Markdown is in Portuguese; the assistant can answer in English.
Official open-source SDKs on GitHub to integrate the Webmania APIs in the language of your project. Each repository includes installation, examples and the operations it covers.
Node.js / TypeScript Available
git clone https://github.com/
Python Available
git clone https://github.com/
PHP Available
git clone https://github.com/
Perl Available
git clone https://github.com/
Go Available
git clone https://github.com/
C Available
git clone https://github.com/
C++ Available
git clone https://github.com/
Lua Available
git clone https://github.com/
Dart Available
git clone https://github.com/
R Available
git clone https://github.com/
Java Available
git clone https://github.com/
Kotlin Available
git clone https://github.com/
Scala Available
git clone https://github.com/
Clojure Available
git clone https://github.com/
Ruby Available
git clone https://github.com/
.NET (C#) Available
git clone https://github.com/
PowerShell Available
git clone https://github.com/
Elixir Available
git clone https://github.com/
Rust Available
git clone https://github.com/
Haskell Available
git clone https://github.com/
Swift Available
git clone https://github.com/
Test the CEP API 2.0 endpoints directly in Postman, or integrate with the CEP-SDK. It includes the API wrapper class, a proxy endpoint for a secure front-end integration and complete usage examples.
Your application must call the CEP API 2.0 only from its back end. Never expose the X-Token in front-end JavaScript code that runs in the user's browser.
Clone the SDK repository for the language of your back end:
git clone https://github.com/webmaniabr/CEP-SDK.git
cd CEP-SDK
# Open the folder of your language:
# php/ | nodejs/ | python/ | csharp/ | java/ | ruby/ Set the environment variable WEBMANIA_CEP_TOKEN to your X-Token (a 36-character UUID). You get it in the Webmania® Panel:
# Linux/macOS
export WEBMANIA_CEP_TOKEN="your-token-uuid-here"
# Windows (PowerShell)
$env:WEBMANIA_CEP_TOKEN = "your-token-uuid-here" Example in PHP, with the script saved in the php folder of the SDK:
// Load the SDK and create an instance
require_once __DIR__ . '/WebmaniaCep.php';
$cep = new WebmaniaCep(getenv('WEBMANIA_CEP_TOKEN'));
// Look up a CEP
$endereco = $cep->consultarCep('01310100');
echo $endereco['endereco']; // Avenida Paulista
echo $endereco['cidade']; // Sao Paulo
echo $endereco['uf']; // SP Example in Node.js, with the script saved in the nodejs folder of the SDK:
const { WebmaniaCep } = require('./webmania-cep');
const cep = new WebmaniaCep(process.env.WEBMANIA_CEP_TOKEN);
async function main() {
const endereco = await cep.consultarCep('01310100');
console.log(endereco.endereco); // Avenida Paulista
}
main(); Autocomplete searches addresses by street name. It is ideal for forms that fill in the address automatically:
// PHP — Search addresses with filters
$resultados = $cep->autocomplete('Rua das Flores', [
'uf' => 'SP',
'cidade' => 'São Paulo',
'limit' => 5
]);
foreach ($resultados['resultados'] as $item) {
echo $item['endereco'] . ' — ' . $item['cep'];
} Each SDK includes a ready-to-use proxy server. The proxy receives requests from the front end and forwards them to the Webmania API with the token kept safe:
# PHP — Start the proxy
php -S localhost:8080 proxy.php
# Node.js — Start the proxy (it also serves the front end)
npm install && node server.js
# Python — Start the proxy
pip install -r requirements.txt && python server.py After you start the proxy, the front end can send requests to:
| Method | Local endpoint | Description |
|---|---|---|
| GET | http://localhost:8080/api/cep/{cep} | CEP lookup through the proxy |
| GET | http://localhost:8080/api/cep/autocomplete?q=... | Autocomplete through the proxy |
The HTML example in the SDK (frontend/cep-autocomplete.html) shows a complete form with autocomplete and CEP lookup. Start any of the proxies and open the HTML file in the browser.
X-Token. This prevents misuse of the API and protects your credits. The API 2.0 authenticates with the X-Token header. The token is a UUID you receive when you buy credits for the CEP API. New lookups need enough credits. Repeats that were already charged and are recognized within the deduplication window are not charged again.
Send the token in the HTTP header of every request:
curl -X GET \
-H "X-Token: a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
https://api.webmania.com.br/2/cep/01310100 Keep the X-Token safe. Use it only in server-side (back-end) applications. Never expose the token in front-end JavaScript code.
The lookup returns the full address of a CEP: street, neighborhood, city, state (UF) and the IBGE code of the city. Use it when the user already entered the CEP.
To look up a CEP, send a GET request to /2/cep/{cep}, with the 8-digit CEP in the URL path.
curl -X GET \
-H "X-Token: YOUR_TOKEN" \
https://api.webmania.com.br/2/cep/01310100 | Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
cep | Path | String | Yes | CEP with 8 digits (with or without a hyphen) |
X-Token | Header | String (UUID) | Yes | Authentication token |
Example of an HTTP 200 response:
{
"cep": "01310100",
"endereco": "Avenida Paulista",
"bairro": "Bela Vista",
"cidade": "Sao Paulo",
"uf": "SP",
"ibge": "3550308"
} | Field | Type | Description |
|---|---|---|
cep | String | CEP formatted with 8 digits (no hyphen) |
endereco | String | Street address (street, avenue, etc.) |
bairro | String | Neighborhood |
cidade | String | City |
uf | String | State abbreviation (2 characters) |
ibge | String or null | IBGE code of the city (can be null for some CEPs) |
Autocomplete suggests addresses from the street name, for forms that fill in the address automatically. Each result has the CEP of the address.
To search addresses by street name, send a GET request to /2/cep/autocomplete, with the search parameters in the query string.
curl -X GET \
-H "X-Token: YOUR_TOKEN" \
"https://api.webmania.com.br/2/cep/autocomplete?q=Rua%20das%20Flores&uf=SP&limit=5" | Parameter | Type | Required | Description |
|---|---|---|---|
q | String | Yes | Search text (min. 4 characters, max. 120) |
uf | String | No | Abbreviation of a valid Brazilian state (UF), with 2 uppercase letters (e.g. SP) |
cidade | String | No | Filter by city (max. 80 characters) |
bairro | String | No | Filter by neighborhood (max. 80 characters) |
limit | Integer | No | Maximum number of results (1-20, default: 10) |
The API automatically expands common Brazilian street-type abbreviations in the search:
| Abbreviation | Expansion |
|---|---|
R. | Rua (street) |
Av. | Avenida (avenue) |
Trav. | Travessa (side street) |
Al. | Alameda (tree-lined street) |
Pça. | Praça (square) |
Example of an HTTP 200 response:
{
"resultados": [
{
"cep": "09726310",
"endereco": "Rua das Flores",
"bairro": "Jardim do Mar",
"cidade": "Sao Bernardo do Campo",
"uf": "SP"
}
],
"total": 1,
"creditos_consumidos": 0.005
} ibge field. If you need the IBGE code, take the CEP of the result and look up the CEP with the /2/cep/{cep} endpoint.The CEP API 2.0 limits requests per second to keep the service stable. Requests over the limit receive the status 429 Too Many Requests.
403), depending on how serious they are.| Type | Sustained limit | Burst (10s) |
|---|---|---|
| Per token | 2 req/s | 12 requests |
| Per IP | 8 req/s | 40 requests |
| Type | Sustained limit | Burst (10s) |
|---|---|---|
| Per token | 5 req/s | 30 requests |
| Per IP | 10 req/s | 60 requests |
New lookups on the CEP API 2.0 need enough credits. When the API recognizes a request as a repeat of a lookup already charged within the deduplication window, it does not charge again.
| Endpoint | Credits per lookup | Deduplication |
|---|---|---|
/2/cep/{cep} | 0.10 | 24 hours |
/2/cep/autocomplete | 0.005 | 24 hours |
Deduplication works per customer and per endpoint, for 24 hours after the recognized charge. For the CEP lookup, it matches the same normalized CEP. For autocomplete, it matches the normalized search text and the uf and cidade filters; bairro and limit do not change this match. On a recognized repeat, creditos_consumidos in the autocomplete response is 0. If the API fails to recognize a repeat, it may charge again.
When a request fails, the JSON response has the error field and may also have message. The main statuses and examples are below. The error text can change with the validation or the lookup, and some texts are in Portuguese. Handle the HTTP status and do not depend on one specific message.
| HTTP status | Error | What it means | What to do |
|---|---|---|---|
401 | Unauthorized | Token not found or invalid. | Check the X-Token header. |
402 | insufficient_credits | Not enough credits to process the request. | Buy more credits in the Webmania® Panel. |
403 | access_temporarily_blocked | Autocomplete blocked because of suspicious activity (anti-scraping). | Wait for the 5- or 30-minute block to end. See Usage limits. |
404 | CEP não encontrado | The CEP does not exist in the database ("CEP não encontrado" means "CEP not found"). | Check the CEP you sent. |
422 | CEP inválido. | Invalid request parameters (invalid CEP, search text too short, etc.). "CEP inválido." means "Invalid CEP." | Fix the parameters as described in Look up a CEP and Autocomplete. |
429 | Too Many Requests | Limit of requests per second exceeded. | Wait a few seconds and try again, with the retry strategy below. |
500 | internal_error | Internal server error. | Try again. If it continues, contact support. |
503 | Não foi possível localizar o CEP. | The lookup service is temporarily unavailable ("Não foi possível localizar o CEP." means "The CEP could not be found."). | Try again in a moment, with the retry strategy below. |
For 429 and 503 errors, retry with exponential backoff: wait 1 second after the first failure, 2 seconds after the second, and so on, up to a maximum of 3 attempts.
The Webmania® API runs on Amazon AWS, the global leader in cloud computing, in the us-east-1 region (US East), with a point of presence in sa-east-1 (São Paulo). The entry point is anycast and highly available: from anywhere in the world, your request goes to the server closest to you.
The same entry IPs serve the whole world. Your request goes to the server closest to you, with no setup on your side.
us-east-1 (US East) and sa-east-1 (São Paulo). Keep your infrastructure close to one of them for a shorter response time.
Fixed IPs for inbound and outbound traffic: allow them in your firewall and check the source of the notifications you receive.
13.248.145.9076.223.17.24034.196.69.3844.219.142.86Webmania® limits the number of requests per second and the total number of requests per month based on the chosen plan. The count adds up the requests from the client side and from the server side. If the application goes over the initial limit, its requests will fail.
https://webmania.com.br/api/ returns 403 Forbidden, contact us and we will allow the IP of your server. The documentation is now LLM-ready: copy the page or each section as Markdown, a section index and llms.txt.