Endpoint
Authentication
| Header | Required | Value |
|---|---|---|
X-API-Key | Yes | Your API key (bun_...) |
Overview
Validate Brazilian tax IDs, CPF (individuals) and CNPJ (companies), in one endpoint. Bunny runs the official check-digit algorithm and returns whether the document is mathematically valid, the document type, and the formatted number.Use cases
- Validate CPF and CNPJ fields on registration and checkout forms
- Prevent typos and transposed digits from entering your database
- KYC and identity verification flows
- Enforce correct formatting before sending to payment processors
Details
Accepts formatted (529.982.247-25) or raw (52998224725) input. Both work. The validation is algorithmic (check-digit), not a lookup against a government database.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document | string | Yes | CPF (e.g. 529.982.247-25) or CNPJ (e.g. 11.222.333/0001-81). Formatted or digits only. |
Response
200 OK
| Field | Type | Description |
|---|---|---|
document | string | The document digits with non-numeric characters stripped |
type | string | cpf or cnpj |
valid | boolean | true if the document passes checksum validation |
formatted | string | The document formatted with standard punctuation |

