Guides
Account opening
Request an Efí account for your customer, simulate their approval and fetch the credentials and certificate of the new application.
The Account opening API (Abertura de contas) opens an Efí account on behalf of your customer (simplified account) with an application already integrated with yours. The end client approves through a link Efí sends by SMS or WhatsApp; after that you fetch the new application's credentials and certificate. At Efí access depends on commercial approval; in Mimicr it is open to every sandbox.
| Efí (homologation) | Mimicr |
|---|---|
https://abrircontas-h.api.efipay.com.br | https://abrircontas.efi.mimicr.dev |
1. Get a token
curl --request POST \
--url https://abrircontas.efi.mimicr.dev/v1/oauth/token \
--header 'Authorization: Basic <base64(client_id:client_secret)>' \
--header 'Content-Type: application/json' \
--data '{ "grant_type": "client_credentials" }'Scopes: gn.registration.write, gn.registration.read, gn.registration.webhook.write and gn.registration.webhook.read. Reference: Get a token (Account opening).
2. Register a webhook
Without a webhook, the account request answers 412 webhook_nao_cadastrado.
curl --request POST \
--url https://abrircontas.efi.mimicr.dev/v1/webhook \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "webhookUrl": "https://sua-app.dev/abertura" }'{ "identificadorWebhook": "e44c5d68-7ead-4f7b-b191-57393e4deb7d" }Before saving, Efí tests the URL with a POST {"evento": "teste_webhook"} and requires a 2xx; if the URL fails, the response is 400 (url_falhou_com_erro, url_inacessivel or limite_de_tempo_atingido_para_url). Reference: Register a webhook.
3. Request the account
curl --request POST \
--url https://abrircontas.efi.mimicr.dev/v1/conta-simplificada \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"clienteFinal": {
"cpf": "94271564656",
"nomeCompleto": "Gorbadoc Oldbuck",
"dataNascimento": "15/01/1977",
"nomeMae": "Maria Oldbuck",
"celular": "31987654321",
"email": "oldbuck@example.com",
"endereco": { "cep": "35400000", "estado": "MG", "cidade": "Ouro Preto", "bairro": "Bauxita", "logradouro": "Avenida Juscelino Kubitschek", "numero": "909", "complemento": "apto 101" }
},
"meioDeNotificacao": ["sms", "whatsapp"],
"escoposIntegrados": ["cob.write", "cob.read", "pix.write", "pix.read", "webhook.write", "webhook.read"]
}'{ "contaSimplificada": { "identificador": "1c0a1b4a-0ff9-4596-aab7-57b12d864f14" } }With clienteFinal.cnpj and razaoSocial, the account is Efí Empresas; without them, Efí Pro. The customer must be of legal age (400 menoridade) and have a valid CPF. While a request is open for the CPF, another answers 409 solicitacao_duplicada. Reference: Request an account.
4. The end client approves
At Efí, the client receives the link by SMS or WhatsApp. In Mimicr the link is a page on the host, https://abrircontas.efi.mimicr.dev/aprovar/{identificador}, with Abrir minha conta (open my account) and Recusar (refuse) buttons. In an automated test:
npx mimicr action efi abrircontas.decide id=1c0a1b4a-0ff9-4596-aab7-57b12d864f14 approve=true
| State in Mimicr | Credentials and certificate | Webhook |
|---|---|---|
| Waiting for the client | 412 conta_nao_aprovada_ou_recusada | |
| Approved, opening (a few seconds) | 412 conta_em_processamento | |
| Open | 200 / 201 | conta_aberta |
| Refused | 412 conta_nao_aprovada_ou_recusada | conta_recusada_pelo_cliente_final |
The API has no route to query the account state: follow it through the webhook (see Webhooks and errors).
5. Fetch the credentials
curl --url https://abrircontas.efi.mimicr.dev/v1/conta-simplificada/1c0a1b4a-0ff9-4596-aab7-57b12d864f14/credenciais \ --header 'Authorization: Bearer <token>'
{
"clientId": "Client_Id_47a3a6920be2632028d5aa988b927b316da3f356",
"clientSecret": "Client_Secret_e0c0a586d29009b4ab7b58cdfbe957cfcd64a6ab",
"conta": { "digito": "9", "numero": "373622", "payeeCode": "04622a3682bc9e88379cd6df" },
"escopos": ["cob.write", "cob.read", "pix.write", "pix.read", "webhook.write", "webhook.read"],
"ativo": true
}In Mimicr these credentials are fictitious: they don't authenticate on the sandbox's other APIs. Reference: Get the credentials.
6. Create the certificate
curl --request POST \ --url https://abrircontas.efi.mimicr.dev/v1/conta-simplificada/1c0a1b4a-0ff9-4596-aab7-57b12d864f14/certificado \ --header 'Authorization: Bearer <token>'
The response is 201 with a JSON string: the base64 of the .p12 file. Decode it and write the file. In Mimicr the content is not a real PKCS#12 (the sandbox has no certificate authority) and each account accepts up to 5 certificates; the sixth answers 403 quantidade_limite_de_certificados. Reference: Create a certificate.