Guides
Account opening webhooks and errors
The account opened and refused events, the URL test on registration, retries and the API errors.
Webhooks
Account events go to every URL registered with Register a webhook. At Efí the POST uses mTLS (your server validates Efí's certificate); in Mimicr it goes straight.
{ "contaSimplificada": { "identificador": "1c0a1b4a-0ff9-4596-aab7-57b12d864f14" }, "evento": "conta_aberta" }evento | When |
|---|---|
conta_aberta | The client approved and the account opened; credentials and certificate now answer |
conta_recusada_pelo_cliente_final | The client refused; a new request for them can be made |
On registration, the URL receives a test POST, {"evento": "teste_webhook"}, and must answer 2xx to be saved. To edit a URL, send webhookUrl and its identificadorWebhook. List webhooks accepts inicio, fim, paginacao.paginaAtual and paginacao.itensPorPagina.
Retries
Without a 2xx, Efí retries up to 10 times, at these minutes after the failure: 5, 10, 20, 40, 80, 160, 320, 640, 1280 and 52560. In Mimicr each attempt waits up to 10 seconds. Deliveries are in the control API with api=abrircontas, kind=ac_conta, ref equal to the account identifier and event equal to the event:
npx mimicr wait efi delivery api=abrircontas event=conta_aberta ref=1c0a1b4a-0ff9-4596-aab7-57b12d864f14
With controlled chaos on for the abrircontas area, the request can be refused by the client right at creation (conta_recusada_pelo_cliente_final).
Errors
Format {nome, mensagem}:
{ "nome": "webhook_nao_cadastrado", "mensagem": "Sua conta não possui webhook cadastrado na API de Cadastro." }| HTTP | nome | When |
|---|---|---|
| 400 | nomeCompleto_invalido, nome_completo_invalido | No name, or no last name |
| 400 | cpf_invalido | Invalid CPF |
| 400 | data_nascimento_invalida, menoridade | Date not in DD/MM/AAAA, or client under 18 |
| 400 | nome_mae_invalido, celular_invalido, email_invalido, cep_invalido | Invalid contact or address data |
| 400 | cnpj_invalido, razao_social_invalida | Company account with an invalid CNPJ or no legal name |
| 400 | cupom_invalido | Coupon outside 1 to 20 characters |
| 403 | escopo_invalido | Scope outside the allowed list in escoposIntegrados |
| 409 | solicitacao_duplicada | There is already an open request for the CPF |
| 409 | email_cadastrado, celular_cadastrado | Already used by an opened account |
| 412 | webhook_nao_cadastrado | No webhook registered |
| 404 | conta_nao_encontrada | Unknown account identifier |
| 412 | conta_nao_aprovada_ou_recusada, conta_em_processamento | Credentials or certificate before the account opens |
| 403 | quantidade_limite_de_certificados | More than 5 certificates (Mimicr limit) |
| 400 | url_webhook, protocolo_da_url, url_cadastrada, chave_invalida | Webhook registration without a URL, without HTTPS, repeated, or unknown identifier |
| 400 | url_falhou_com_erro, url_inacessivel, limite_de_tempo_atingido_para_url | The URL failed the test POST |
| 400 | identificador_webhook | Unknown webhook |
| 400 | data_invalida | fim before inicio in the list |
| 404 | rota_nao_encontrada | Unknown route |
| 500 | erro_aplicacao | Internal error |
Mimicr doesn't simulate the Protege+ errors (405) or Efí's CPF restrictions (cpf_restrito, cpf_inativo). Authentication uses 401 invalid_client, 401 invalid_token and 403 insufficient_scope, like the other APIs.