Skip to main content

Webhook

This section gathers endpoints for managing notifications by the receiving PSP to the receiving end user.


mTLS Validation

To use the Account Opening API, your server must have a minimum version of TLS 1.2 and comply with the mTLS communication standard.


Understanding the mTLS pattern​

By Central Bank regulation, it will be necessary to insert an Efí public key into your server so that communication follows the mTLS standard. In the domain representing your server, you should configure the requirement of the public key (mTLS) that we are providing, so that mutual authentication occurs.

Efí will make 2 requests to your domain (server):

  1. First Request: We will ensure that your server is requiring an Efí public key. To do this, we will send a request without a certificate and your server should not accept the request. If your server responds with refusal, we will send the 2nd request.
  2. Second Request: Your server, which must contain the provided public key, should perform the "Hand-Shake" so that communication is established.

Your server must have a minimum TLS version of 1.2.

On your server, configure a 'POST' route with a default response as a string "200". Include our production or Sandbox certificate on your server, below are some examples.

Dedicated Servers

It is recommended that you have a dedicated server to be able to perform webhook configurations, as you need access to some files to make the configurations, as in the examples below.


Examples of server settings​

To configure your server, you will need the Efí public keys. Below are the addresses of the keys for the Production and Sandbox environments. These keys must be downloaded and placed on your server.

AttributePublic Key URL
Productionhttps://certificados.efipay.com.br/webhooks/certificate-chain-prod.crt
Sandboxhttps://certificados.efipay.com.br/webhooks/certificate-chain-homolog.crt


The code snippets below are intended to exemplify the settings required on your server so that it is possible to perform the hand-shake with our servers.
from flask import Flask, jsonify, request
import ssl
import json
app = Flask(__name__)

@app.route("/", methods=["POST"])
def imprimir():
response = {"status": 200}
return jsonify(response)


@app.route("/pix", methods=["POST"])
def imprimirPix():
imprime = print(request.json)
data = request.json
with open('data.txt', 'a') as outfile:
outfile.write("\n")
json.dump(data, outfile)
return jsonify(imprime)

if __name__ == "__main__":
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations('caminho-certificados/certificado-público.crt')
context.load_cert_chain(
'caminho-certificados/server_ssl.crt.pem',
'caminho-certificados/server_ssl.key.pem')
app.run(ssl_context=context, host='0.0.0.0')
#Developed by the Technical Consulting Team at Efí

To have a valid SSL, you must contact a Certificate Authority and generate the private key server_ssl.key.pem and a public one server_ssl.crt.pem, thus validating the integrity of the connection. You can do this for free using a utility like Certbot, for example.


Configure webhook​

Configures webhook for the Account Opening API.

POST /v1/webhook
Requires authorization for the scope: gn.registration.webhook.write


Request

{
"webhookUrl": "https://sejaefi.com.br/meu-webhook"
}

Responses

The responses below represent Success(200) and consumption failures/errors.

{
"identificadorWebhook": "92ecc0a8-9631-4601-a188-feacf8288c13"
}

Detail webhook​

Details the webhook configured for the Account Opening API.

GET /v1/webhook/:identificadorWebhook
Requires authorization for the scope: gn.registration.webhook.read


Responses

The responses below represent Success(200) and consumption failures/errors.

{
"webhookUrl": "https://sejaefi.com.br/meu-webhook",
"identificadorWebhook": "92ecc0a8-9631-4601-a188-feacf8288c13",
"criacao": "2021-10-26T11:23:35.000Z"
}

List webhooks​

Lists webhooks configured for the Account Opening API.

GET /v1/webhooks
Requires authorization for the scope: gn.registration.webhook.read


Request

The request sent to this endpoint doesn't need a body, just the OAuth authorization headers, parameters and the account certificate.

Responses

The responses below represent Success(200) and consumption failures/errors.

Success
{
"parametros": {
"inicio": "2020-04-01T00:00:00.000Z",
"fim": "2020-04-01T23:59:59.000Z",
"paginacao": {
"paginaAtual": 0,
"itensPorPagina": 100,
"quantidadeDePaginas": 1,
"quantidadeTotalDeItens": 1
}
},
"webhooks": [
{
"webhookUrl": "https://sejaefi.com.br/meu-webhook",
"identificadorWebhook": "92ecc0a8-9631-4601-a188-feacf8288c13",
"criacao": "2021-10-26T11:23:35.000Z"
}
]
}

Cancel webhook​

Cancels the webhook configured for the Account Opening API.

DELETE /v1/webhook/:identificadorWebhook
Requires authorization for the scope: gn.registration.webhook.write


Request

The request sent to this endpoint doesn't need a body, just the authorization headers, OAuth, parameter and the account certificate.

Responses

The responses below represent Success(204) and consumption failures/errors.

No content 

* Webhook configured for registration has been canceled.

Receiving Callbacks​

This service is protected by an mTLS authentication layer. Callbacks are sent by Efí via POST url-webhook-registered.


Request​