CPFHub.io
Start for free

Authentication

Every request to the CPFHub.io API must be authenticated with an API key sent in the x-api-key header.

Getting your API key

When you create your account, an API key is generated automatically. Go to app.cpfhub.io/api-keys to view and copy it at any time.

If you need to, you can generate a new key on that same page. Each account has a single active key. When you generate a new one, the previous one stops working within 5 minutes and starts returning 401 with "API Key inativa" (inactive API key).

ℹ

Rotating the key in production

There is no period with two valid keys. Generate the new key only when you can update the secret in your system right afterward, so your lookups are not interrupted.

The key is an opaque string. Do not validate its prefix, length or format in your code.

⚠

Store your key securely

Never expose your API key in client-side code, public repositories or logs. Use environment variables.

Sending the API key

Include the x-api-key header in every request:

bash
curl "https://api.cpfhub.io/cpf/12345678909" \
  -H "x-api-key: $CPFHUB_API_KEY"

Store the key in an environment variable (CPFHUB_API_KEY in the example) and read it from there in your code.

Base URL

All requests must use HTTPS:

https://api.cpfhub.io

Requests over http:// get a 301 redirect to HTTPS. Many HTTP clients turn a POST into a GET when they follow that redirect, which breaks the Real-Time Lookup and the batch lookup. Always use https://.

Authentication errors

The API only responds in Portuguese, so the error messages below are shown as returned, with the translation in parentheses.

CodeMessage (error)When
401API Key não fornecida (API key not provided)The x-api-key header was not sent
401API Key inválida (invalid API key)The key does not exist
401API Key inativa (inactive API key)The key was replaced by a new one in the dashboard
403Usuário inativo. Entre em contato com o suporte. (inactive user, contact support)Account deactivated
403Conta bloqueada. Entre em contato com o suporte. (account blocked, contact support)Account blocked

In these cases the error field is a string:

JSON
{
  "success": false,
  "error": "API Key não fornecida"
}

The same API key works for all endpoints: Simple Lookup, Real-Time Lookup, Batch Lookup and credit balance.

For full details on every error, see Error Codes.


Updated on October 3, 2026