Look up CNPJ in Power Automate

This guide shows how to look up a CNPJ (the Brazilian company tax ID) in Power Automate with no code, to automate enrichment inside the Microsoft ecosystem: when a lead, an Excel/SharePoint row or a Dataverse record arrives, the flow looks up the CNPJ with the CNPJAPI API and returns the legal name, registration status and main activity to the next step.

The guide starts from scratch: creating the account and generating your API key.

Before you start: create the account and generate the API key

To use the API you need an API key (a token that identifies your account). It is free to start.

  1. Go to https://app.cnpjapi.com.br and create your account on the free plan (no card required).
  2. Confirm your e-mail and sign in to the portal.
  3. Inside the portal, generate your API key. It starts with cnpj_ (for example, cnpj_a1b2c3...). Copy it and keep it somewhere safe - the key is shown once.
  4. This key goes in the Authorization header, as Bearer cnpj_your_key, on every request.

Details in Authentication. Treat the key like a password: whoever holds it consumes your quota.

How it works in Power Automate

Power Automate has no official CNPJAPI connector. You use the generic HTTP action, which sends the Authorization header the API requires.

Note: the HTTP action is a premium feature of Power Automate (needs a paid plan or a premium trial). It is the way to send the Authorization header; the standard connectors do not send it.

Step by step

  1. In your flow, add the HTTP action (Premium).
  2. Configure:
    • Method: GET.
    • URI: https://api.cnpjapi.com.br/@{variables('cnpj')} - where cnpj is the 14 digits from the trigger. To test, use a fixed one: https://api.cnpjapi.com.br/00776574000156.
    • Headers: key Authorization, value Bearer cnpj_your_key.
  3. Add a Parse JSON action right after:
    • Content: the Body of the HTTP action;
    • Schema: paste the minimal schema below (it covers the fields used; the other response fields are ignored).
{
  "type": "object",
  "properties": {
    "RazaoSocial": { "type": "string" },
    "SituacaoCadastral": {
      "type": "object",
      "properties": { "Descricao": { "type": "string" } }
    },
    "AtividadePrincipal": {
      "type": "object",
      "properties": { "Descricao": { "type": "string" } }
    }
  }
}
  1. In the following steps, use the Parse JSON fields: RazaoSocial, SituacaoCadastral Descricao, AtividadePrincipal Descricao - store them wherever you want (Excel, SharePoint, Dataverse, e-mail...).

Handling "not found" and rate limit

The API responds 404 when the CNPJ does not exist in the base, and 429 when you exceed the per-minute limit or the monthly quota (with the Retry-After header, in seconds).

By default a 4xx/5xx makes the HTTP action fail and stops the flow. To handle it without stopping: on the next action, use Configure run after (run even if HTTP failed) and a Condition on statusCode (for example, outputs('HTTP')?['statusCode']) to branch 200 / 404 / 429.

Rate limit (and when to upgrade)

A flow applied to many rows fires many calls. On the CNPJAPI free plan the API accepts a limited number of lookups per minute; when you exceed it, it returns 429. For larger volumes:

  • Slow down (concurrency limit on the Apply to each, or a Delay); or
  • Upgrade to a plan with a higher limit and a comfortable monthly quota.

See the plan limits. If you automate enrichment often, a paid plan pays off quickly.

Notes

  • There is no official CNPJAPI connector/app in Power Automate - it is the generic HTTP action (premium).
  • Keep the API key safe: prefer a Power Platform environment variable over hardcoding it in the flow.

Next steps

Create your free account at https://app.cnpjapi.com.br and build your first flow in minutes.