Skip to main content

Endpoint

POST https://api.bunny.build/api/v1/cpf-cnpj-generator

Authentication

HeaderRequiredValue
X-API-KeyYesYour API key (bun_...)
Content-TypeYesapplication/json

Overview

Generate batches of mathematically valid CPF (individual taxpayer) or CNPJ (company taxpayer) numbers for use in test environments. All generated documents pass the official checksum algorithm and can optionally be returned with standard formatting masks. These are synthetic numbers for testing only and do not correspond to real individuals or entities.

Use cases

  • Seed test databases and QA environments with realistic Brazilian document numbers
  • Validate form input components in CI pipelines without using real data
  • Demonstrate form validation behavior in live demos and prototypes
  • Generate fixtures for unit and integration tests

Request body

FieldTypeRequiredDescription
typestringNoDocument type: "cpf" or "cnpj". Default: "cpf"
countintegerNoNumber of documents to generate (1–100). Default: 1
formattedbooleanNoReturn formatted strings (e.g. "123.456.789-09"). Default: true

Example

{
  "type": "cpf",
  "count": 3,
  "formatted": true
}

Response

200 OK

FieldTypeDescription
typestringDocument type returned ("cpf" or "cnpj")
countintegerNumber of documents generated
documentsarray of objectsEach entry has raw (digits only) and formatted (masked string, omitted if formatted: false)
documentobjectFirst document in the batch — same shape as a documents entry. Shortcut for count: 1 use cases
Example
{
  "type": "cpf",
  "count": 3,
  "documents": [
    { "raw": "12345678909", "formatted": "123.456.789-09" },
    { "raw": "98765432100", "formatted": "987.654.321-00" },
    { "raw": "11122233396", "formatted": "111.222.333-96" }
  ],
  "document": { "raw": "12345678909", "formatted": "123.456.789-09" }
}

401 Unauthorized

{
  "detail": "Missing API key. Include X-API-Key header."
}

402 Payment Required

{
  "detail": "Monthly quota exceeded. Upgrade your plan."
}

422 Unprocessable Entity

{
  "detail": "'count' must be between 1 and 100."
}

429 Too Many Requests

{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}

cURL example

curl -X POST https://api.bunny.build/api/v1/cpf-cnpj-generator \
  -H "X-API-Key: bun_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "cpf", "count": 3, "formatted": true}'