---
title: "Divida Ativa"
description: "API Divida Ativa - Consulta Rápida de Dívidas em CPF"
lang: en
canonical: https://doc.apibrasil.io/apis/creditos/e3d2db92-330e-4bc6-b28b-7d98f8bdf036
markdown: https://doc.apibrasil.io/apis/creditos/e3d2db92-330e-4bc6-b28b-7d98f8bdf036.md
source: apibrasil-documentation
---

# Divida Ativa

> API Divida Ativa - Consulta Rápida de Dívidas em CPF

- **Category:** Tax Compliance
- **Billing:** per query, with the Bearer Token only
- **Price:** R$8.50 per query
- **Limit:** 999,000 per month
- **Registration:** requires a CNPJ
- **Version:** v2
- **Published by:** APIBrasil
- **OpenAPI specification:** https://doc.apibrasil.io/apis/creditos/e3d2db92-330e-4bc6-b28b-7d98f8bdf036/openapi.json

## How to call

**Base address:** `https://gateway.apibrasil.io/api/v2`

Authentication: the `Authorization: Bearer <token>` header. Nothing else.

With `homolog: true` in the body, the gateway answers from a fixed base, with the real shape of the response, and does not charge. The CPF 00000000000 belongs to that base and to nobody: use it in tests, never in production.

## Endpoints (1 endpoint)

### 1. POST /consulta/cpf/credits

API Dívida Ativa - Consulte Débitos Pendentes em Instantes

A API Divida Ativa permite a consulta rápida e precisa de dívidas ativas vinculadas ao CPF de seus clientes, integrando-se facilmente ao seu sistema através de um endpoint simples via método POST. Com respostas detalhadas e atualizadas em tempo real, você obtém informações valiosas para análise de crédito, concessão de benefícios ou tomada de decisões em processos financeiros. Otimize suas operações e minimize riscos ao incorporar essa solução eficiente, elevando a segurança e agilidade no seu fluxo de trabalho.

- **Method:** `POST`
- **Address:** `https://gateway.apibrasil.io/api/v2/consulta/cpf/credits`
- **Route version:** v2

**Headers**

| Header | Value |
| --- | --- |
| `Content-Type` | `application/json` |
| `Authorization` | `Bearer $APIBRASIL_TOKEN` |

**Request body**

```json
{
  "cpf": "00000000000",
  "tipo": "divida-ativa",
  "homolog": true
}
```

**In cURL**

```bash
curl -X POST "https://gateway.apibrasil.io/api/v2/consulta/cpf/credits" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $APIBRASIL_TOKEN" \
  -d '{"cpf":"00000000000","tipo":"divida-ativa","homolog":true}'
```

This endpoint accepts `homolog: true` in the body: the response comes back with valid data, `api_limit_for` equal to `homolog` and no charge.

**Sample response, from the catalog**

```json
{
  "user": {
    "first_name": "[omitido]",
    "email": "[omitido]",
    "cellphone": "[omitido]",
    "notification": "yes"
  },
  "balance": "105,660",
  "balance_before": "105,660",
  "tax": "0,000",
  "status_code": 200,
  "error": false,
  "message": "Dados validos em homologacao! Voce nao foi tarifado e a requisicao nao foi contabilizada.",
  "valor_consulta": 0,
  "api_limit_for": "homolog",
  "homolog": true,
  "data": {
    "dividaAtiva": [
      {
        "_id": "mock-divida-001",
        "codigoComprot": "1100001",
        "codigoSida": "6000",
        "codigoTipoSituacao": "06",
        "codigoUorg": "0004520",
        "cpfCnpj": "000.000.000-00",
        "descricaoTipoSituacao": "EXTINTA",
        "id": "mock-divida-001",
        "nomeDevedor": "CONTRIBUINTE DEMONSTRATIVO",
        "nomeUnidade": "PROCURADORIA REGIONAL DEMO",
        "numeroInscricao": "00 0 24 000001-00",
        "numeroProcesso": "12345 000000/2024-00",
        "situacaoDescricao": "EXTINTA POR CANCELAMENTO VALOR ILUSTRATIVO",
        "tipoDevedor": "CO-RESPONSAVEL",
        "tipoRegularidade": "REGULAR",
        "valorTotalConsolidadoMoeda": "0,00"
      }
    ]
  }
}
```

In the sample responses, the fields of the account that generated the sample (`user.first_name`, `user.email`, `user.cellphone`) come out as `[omitido]`. The rest is what the catalog publishes.

## Pitfalls: what an integration gets wrong without warning

Established from the responses the catalog itself publishes. In every one of them the code works on the happy path and fails silently everywhere else:

1. **The error arrives in the BODY, with HTTP 200.**
   The response carries a boolean `error` field and a `message`. Checking only `response.ok` or the HTTP status lets a failure through as a success. ALWAYS check `error === false` before reading `data`.

2. **`balance`, `tax` and `extra_charges.total` are STRINGS in Brazilian format — and the format varies between APIs.**
   Values seen in the catalog: `"154,380"`, `"497,84"`, `"0,000"` and `"0.19"`. Comma in some, dot in another; three decimal places in some, two in another. In JavaScript, `parseFloat("154,380")` returns `154` and drops the cents with no error at all, and `Number("154,380")` returns `NaN`. Write a converter that handles both separators, and never use these fields in a financial decision without converting them.

3. **Every call costs money.**
   Blind retries multiply the bill. Never automatically repeat a 4xx: a bad parameter repeated is still bad, and still charged. Retry only timeouts and 5xx, with exponential backoff and a small attempt ceiling.

4. **HTTP 402 means insufficient balance, and retrying does not fix it.**
   It is the one status that needs a human — a top-up. Treat it as a terminal error with its own message, and do not lump it in with generic 4xx.

5. **`extra_charges` bills on top of the lookup price.**
   When the body asks for add-on services, the response lists each one with its price plus a `total` that is NOT included in the base amount. If you show cost to an end user, add both.

## See also

- OpenAPI specification: https://doc.apibrasil.io/apis/creditos/e3d2db92-330e-4bc6-b28b-7d98f8bdf036/openapi.json
- API catalog: [API catalog](https://doc.apibrasil.io/apis.md)
- Official SDKs: [Official SDKs](https://doc.apibrasil.io/sdks.md)
- Documentation index: https://doc.apibrasil.io/llms.txt
- HTML version of this page: https://doc.apibrasil.io/apis/creditos/e3d2db92-330e-4bc6-b28b-7d98f8bdf036
