Companies
Register company automatically
Just CNPJ, A1 certificate and password: the platform creates the company, links the certificate and lists anything missing.
/openapi/v2/empresas/cadastro-automaticotoken, timestamp and sign signature headers, see Authentication.One call replaces Register company + Link digital certificate. The certificate proves ownership; legal name, address and CNAE come from the public CNPJ registry data; state registration comes from the SEFAZ taxpayer registry, queried with the certificate itself; the tax regime crosses that registry with the Simples Nacional and MEI options in the public data.
With a complete profile the company goes straight to review. If something is missing, it is created as a draft with the certificate linked, the fields are listed in camposPendentes and nothing is filled in by guesswork: issuance stays blocked until you complete it with Register company (body with id). Track the company with Query company.
Headers
Content-Type* | string | Body type |
* Required field
Request body
cnpj* | string | Company CNPJ |
senha* | string | Certificate password |
arquivoBase64* | string | Certificate in Base64 |
* Required field
status and camposPendentes to see whether it is already under review.empresaId | string | Company identifier |
cnpj | string | Company CNPJ |
status | string | Company status |
camposPendentes | array | Pending fields |
razaoSocial | string | Legal name |
nomeFantasia | string | Trade name |
inscricaoEstadual | string | State registration |
optanteSimplesNacional | bool | Simples member |
mei | bool | MEI |
email | string | Registered e-mail |
telefoneComercial | string | Registered phone |
| object | Address used for the profile |
| Field | Source | If not obtained |
|---|---|---|
| CNPJ | Request, checked against the certificate | Rejected 10003010 |
| Legal name | Public CNPJ data; else SEFAZ registry; else certificate name | Always obtained |
| Trade name, e-mail, phone | Public CNPJ data (trade name also from SEFAZ) | Left empty, not blocking |
| Main CNAE | Public CNPJ data; else SEFAZ | Left empty, not blocking |
| State and city | SEFAZ IBGE code; else state and city name from public data | Rejected 10003053 |
| Address (street, number, complement, district, postal code) | Whole block from the active SEFAZ state registration when complete; else whole block from public data, never mixing both sources | Draft, listed in camposPendentes; a value over the NF-e limit (60 characters, number 16) is left empty, not cut |
| State registration | SEFAZ, only the active registration of the same CNPJ | Draft, listed in camposPendentes |
| Tax regime | Apuração regime of the active state registration (SEFAZ) crossed with the Simples and MEI options in the public data | Draft with regime pending; optanteSimplesNacional and mei in camposPendentes |
| NF-e numbering | Not created, same as Register company without emissaoNFeProduto | Create it with Register company carrying id and emissaoNFeProduto |
| Environment | Homologation, same as Register company | — |
The platform takes one result from each source and only accepts unambiguous results.
State registry (apuração regime of the active SEFAZ state registration):
| State registry | Result |
|---|---|
| Contains SIMEI | MEI |
| Starts with NORMAL | Normal regime |
| Contains SIMPLES, empty, other value, only inactive registration, several active ones, or SEFAZ did not answer | No result |
Public CNPJ data (the same opcaoSimples and opcaoMei as CNPJ lookup):
| Simples option | MEI option | Result |
|---|---|---|
| Any | Yes | MEI |
| No | Any | Normal regime |
| Yes | No | Simples Nacional |
| Yes | Not informed | No result |
Combination: if only one source has a result, it applies; if both agree, that result applies; if they differ, the regime is undetermined. Over the sublimit (CRT 2) cannot be determined from official public data: in the official layout of the state registry query the apuração regime is free text with no value table; the SEFAZ registry only tells Simples from Regime Normal; and whether revenue passed the sublimit is not public. So "Simples member and not MEI" is always deduced as Simples Nacional (CRT 1), and CRT 2 is never deduced. The typical mismatch, a NORMAL state registry with the Simples option, is usually exactly a company over the sublimit.
Undetermined does not block registration: the company stays a draft with the regime pending confirmation (optanteSimplesNacional and mei are null) and cannot go to review or issue new documents (10003052) until you send optanteSimplesNacional and mei through Register company with id. Cancellation, correction letters and other events on documents already issued are not blocked. A company over the sublimit, whether deduced as Simples Nacional or pending because of a mismatch, is switched to CRT 2 in the console under "Tax settings", which also clears the pending confirmation: the update with id only stores CRT 1, 3 or 4, and only while the regime is pending. See "Tax regime" in Companies.
- Complete: call Register company with
id=empresaId. If the company has no state registration yet,inscricaoEstadualis stored; with the regime pending,optanteSimplesNacionalandmeiset the regime (CRT 2 only through the console); address and contacts follow the normal update rules. Once the data is complete, a draft company goes to review automatically; a rejected one only goes back to (manual) review when the update completes a field that was pending. The state registration is only stored for draft or rejected companies. - Track: Query company returns
status,motivoStatusand, for draft or rejected companies,camposPendentes. - Certificate: already linked; to replace it use Link digital certificate.
- NF-e numbering: not created here. Before issuing NF-e, call Register company with
idandemissaoNFeProduto(series and next number); see "Set the NF-e numbering". - Some states SEFAZ does not offer the registry query, or does not answer in time; then the state registration comes in
camposPendentes.
Send Content-Type: multipart/form-data with the three fields below. In the signature the body is the empty string: sign = MD5(token + path + timestamp).
APP_SECRET="sk_live_9f8e7d6c5b4a"P="/openapi/v2/empresas/cadastro-automatico"TS=$(date +%s)SIGN=$(printf '%s' "${APP_SECRET}${P}${TS}" | md5sum | cut -d' ' -f1)curl -X POST "https://api.v2.tffiscal.com${P}" \-H "token: ${APP_SECRET}" -H "timestamp: ${TS}" -H "sign: ${SIGN}" \-F "cnpj=14422279000106" -F "senha=certpass123" -F "arquivo=@empresa.pfx"
Form fields
cnpj* | text | Company CNPJ |
senha* | text | Certificate password |
arquivo* | file | Certificate file |
* Required field
statusCompany status
Right after registration only Rascunho (fields missing, or sending to review failed with an empty camposPendentes: call Register company with id to resend), AguardandoAprovacao and Ativa appear.
| Values | Meaning |
|---|---|
| Rascunho | Saved and not yet sent for review; camposPendentes lists what is missing |
| AguardandoAprovacao | Under platform review; cannot issue yet |
| Ativa | Approved; can issue once a valid certificate is linked |
| Rejeitada | Refused at review; motivoStatus carries the reason. Fix and resubmit in the console; if it had fields in camposPendentes, completing them with Register company (body with id) sends it back to manual review |
| Inativa | Disabled; does not issue until re-enabled in the console |
camposPendentesPending fields
Only present when status is Rascunho or Rejeitada. Names appear in this order.
| Values | Meaning |
|---|---|
| inscricaoEstadual | State registration missing. Not required from a company that only issues NFS-e (NFS-e profile and no NF-e series) |
| optanteSimplesNacional | Tax regime pending confirmation; always comes together with mei. Send both to set the regime |
| mei | Tax regime pending confirmation; always comes together with optanteSimplesNacional |
| endereco.logradouro | Address street missing |
| endereco.numero | Address number missing |
| endereco.bairro | Address district missing |
| endereco.cep | Address postal code missing |
| Code | HTTP | |
|---|---|---|
| 10001001 | 400 | Invalid field; mensagem names it. |
| 10003001 | 400 | Invalid CNPJ. |
| 10003002 | 400 | This application already has a company with this CNPJ. Use the existing empresaId. |
| 10003008 | 400 | Certificate password mismatch. |
| 10003009 | 400 | The file is not a valid A1 certificate with a private key. |
| 10003010 | 400 | Certificate CNPJ differs from the cnpj sent. |
| 10003011 | 400 | Certificate expired. |
| 10003035 | 400 | Invalid Base64 or file above 1MB. JSON shape only. |
| 10003038 | 400 | Direct-customer account with incomplete data: nothing is created; mensagem lists what is missing. Register through the console. |
| 10003050 | 400 | CNPJ not found in the public registry data. Nothing is created. |
| 10003051 | 503 | Public registry data temporarily unavailable. Nothing is created; retry the same request later. |
| 10003053 | 400 | State or city of the registered address not identified. Nothing is created; use Register company. |
