Extract Employment Information in Brazil (API)

So, want to get employment data about your users in Brazil? Well, you've come to the right place 😎

In this guide, we walk you through everything you need to extract employment data about your users using our API. This includes:

  • A general overview of the data flow
  • Generating your API keys
  • Providing a webhook URL (to receive events from Belvo)
  • Generating a widget access token and creating a link
  • Getting employment and owner information

📘

What data can I get about my users?

For a detailed list of data that our Employment Record API returns for your users, see our:

General flow of data

👍

Average time to retrieve employment data

The average time it takes for Belvo to retrieve employment data from an employment institution and send you a webhook event is 15 seconds. However, this can vary depending on the institution's responsiveness and their current request load.

Belvo uses asynchronous workflows to improve your data flow (check the diagram below).

Belvo uses asynchronous workflows to improve your data flow (check the diagram below). Whenever your user successfully creates a link using the Hosted Widget, Belvo automatically extracts all the Employment data for you in the background, and once we have all the data, we notify you via a webhook that the data is ready to be retrieved (see the purple WEBHOOK sections in the diagram below). So that we can notify you once the data is ready, you need to provide a URL to where we can send events.

Generate API Keys

To use our API, you will need to generate some API keys to authenticate all your request.

To generate your API keys:

  1. Sign in to your Belvo Dashboard.
  2. Choose the Production environment to create your API keys.

    Note: Currently, employment data for Brazil is only supported in the production environment.

  3. Go to Developers -> API Keys.
  4. Click on Generate API Keys, which will automatically generate your API keys.
  5. In the pop-up, copy and securely save the values for Secret ID and Secret Password.
    Note: In the pop-up, you also have the option of forking Belvo's API collection. For more information on how to use Postman and Belvo's collection, see our Getting started in 10 minutes guide.

✳️ Done! You've just generated your API keys! But before you can start making API calls, you just need to set up a webhook where we can send events to.

Add a webhook URL

📘

Just testing out?

If you're just starting your integration and aren't sure how to get a URL for a webhook, you can use a service like Pipedream. Check out our Getting started in 10ish minutes to see how it's done!

To set up a new webhook:

  1. Sign in to your Belvo Dashboard.
  2. Choose the Production environment to receive webhook events.
  3. Go to Developers -> Webhooks.
  4. Click +New webhook.
  5. Fill in the New webhook form with the required information.
    1. URL: the URL to receive the webhook notifications.
    2. Authorization: an optional bearer token to use if your URL is protected.
  6. Click Create webhook.

✳️ Done! You've now created a webhook and can start creating links and receiving events!

Whitelisting Belvo IP addresses

Belvo will send events to your webhook URL from the IP addresses listed below. Your security team may want to add these to their list of IP addresses that they allow events from (otherwise, your system may block events from reaching your system).

  • 3.130.254.46
  • 18.220.61.186
  • 18.223.45.212

Generate an access token

For the widget to appear to your end users, you need to generate an access token in your server-side and send it to Belvo. Once we receive the request, you'll receive an object with two keys: access and refresh. Pass the value of the access key when starting the hosted widget.

🚧

The returned values are valid for 10 minutes and we invalidate the token as soon as a user successfully connects their account.

To generate an access token, simply make a call from your server-side to Belvo:

curl -X POST \
  https://production.belvo.com/api/token/ \
  -H 'Content-Type: application/json' \
  -H 'Host: production.belvo.com' \
  -d 'see example payloads below'
{
  "id": "YOUR_SECRET_ID",
  "password": "YOUR_SECRET_PASSWORD",
  "scopes": "read_institutions,write_links",
  "stale_in": "365d",
  "credentials_storage": "store",
  "fetch_resources": ["EMPLOYMENTS", "OWNERS"],
  "widget": {
    "callback_urls": {
      "success": "your_deeplink_here://success",
      "exit": "your_deeplink_here://exit",
      "event": "your_deeplink_here://error"
    },
    "branding": {
      "company_icon": "https://mysite.com/icon.svg",
      "company_logo": "https://mysite.com/logo.svg",
      "company_name": "ACME",
      "company_terms_url": "https://belvo.com/terms-service/",
      "overlay_background_color": "#F0F2F4",
      "social_proof": true
    },
    "theme": [] // See our dedicated widget customization article
  }
}

Where:

Parameter Type Required Description
id string true Replace YOUR_SECRET_ID with the secretID you generated in the Belvo dashboard.
password string true Replace YOUR_SECRET_PASSWORD with the secretPassword you generated in the Belvo dashboard.
scopes string true The scopes parameter contains a list of permissions that allow you to create a link for the user. This is a required parameter and must be sent exactly as shown.
stale_in string optional The stale_in parameter allows you to control for how long Belvo stores user-derived data. For more information, check out the stale_in section of our Data retention controls article.
credentials_storage string optional The credentials_storage parameter allows you to control how long Belvo should store credentials for users. If you create recurrent links, this must be set to store. For more information, check out the credentials_storage section of our Data retention controls article.
fetch_resources array of strings true In the fetch_resources parameter, you provide a list of resources that you want Belvo to asynchronously retrieve for the user. For employment data in Brazil, you must send through ["EMPLOYMENTS", "OWNERS"].
widget.callback_urls object true In the callback_urls object, you must add links to where your user should be redirected to in the following cases:
  • success (your user successfully connected their accounts)
  • exit (your user exited the widget before they completed the process)
  • event (an error occurred during the connection process)
For more information, check out the callback_urls section in our Hosted Widget (OFDA) guide. Belvo will also send additional event information depending on the event. For more information, please make sure to check out the Handling callback events section of the Hosted Widget (OFDA) guide.
widget.branding object true In the branding object, you must add your:
  • company_icon
  • company_logo
  • company_name
  • company_terms_url
You can also optionally add a custom background color for when the widget opens, as well as disable Belvo's messaging regarding how many accounts have been connected. For more information about the branding and customization options of the widget, check out our dedicated guide.
widget.theme array of objects optional You can optionally add your brand colors to the widget using the theme parameter. For more information regarding where these colors will appear in the widget, check out the dedicated Add custom colors to the widget section of our Branding guide.

Start the widget in your application for your user

Next, you will need to redirect your user to the widget in a webview inside your application, using the access token you received from the /api/token/ request:

https://widget.belvo.io/
	?access_token={access_code}
  	&locale=pt
    &institutions=inss_br_employment
  	&access_mode=single
  	&external_id=HJLSI-897809
ParameterRequiredDescription
access_tokentrueReplace access_code with the access token you received.
localetrueFor the hosted widget to function correctly for your users in Brazil, you must set the locale query parameter to pt.
institutionsfalseWith the institutions parameter, you can provide one (or more) institutions that should display in the widget. In the case of Employments in Brazil, we recommend setting this parameter to inss_br_employment.
access_modefalseYou can use the access_mode parameter to define which type of link you want to create (single or recurrent). By default, Belvo creates recurrent links.

For more information regarding the different link types, see theLinks section of our Links and Institutions guide.
external_idhighly recommendedYou can add an additional identifier to be associated with the link in the Belvo database. The external_id that you provide:

- should be a unique ID for each user in your database.
- must be at least three characters long.
can only be composed of letters, numbers, dashes (-), and underscores (_).
- cannot contain any personally identifiable information about the user (email, name, phone number, credit card number, and so on).For more details, see the Adding your own identifier section of our Link creation best practices guide.

Additionally, check out ourStarting the widget and callback events sections of our Hosted Widget (Multi-Region) guide.

✳️ Done! Belvo will now connect to the institution and validate that the provided CPF is correct. Once validated and your link is created, Belvo will asynchronously load the employment data.We will send you a webhook once we have retrieved the data for the given link, and you can then extract it with a get request.

Wait for a webhook and get employment data

As soon as your banking recurrent link is created, we asynchronously load the employment information available for the link and will send you the following webhook:

Webhook CodeDescription
historical_updateThe total number of employments found for the link.

In the webhook payload we include the number of employments found for the link.

{
  "webhook_id": "03d1ca0d62db4f769488265d141047b7",
  "webhook_type": "EMPLOYMENTS",
  "process_type": "historical_update",
  "webhook_code": "historical_update",
  "link_id": "2f5d361d-dad6-45d4-a0bf-26d479766067",
  "request_id": "4363b08b-51eb-4350-9c74-5df5ac92a7f6",
  "external_id": "your_external_id",
  "data": {
    "total_employments": 1 // The total number of employment record profiles found for the link
  }
}

Once you receive the notification, you can get further details by making the following request:

curl --request GET 'https://api.belvo.com/api/br/employments/?link={id}' \
-u [Secret Key ID]:[Secret Key PASSWORD]
Query ParameterDescriptionExample
linkThe link_id you received in the webhook notification.2f5d361d-dad6-45d4-a0bf-26d479766067

👍

For details about the response body, make sure to check out our List Employments (Brazil) API reference documentation or Employment (Brazil) Data Dictionary.

Wait for a webhook and get owner data

As soon as your banking link is created, we asynchronously load the owner information available for the link and will send you the following webhook:

Webhook CodeDescription
historical_updateThe total number of owners found for the link.

In the webhook payload we include the number of owners found for the link.

{
  "webhook_id": "aadf41a1fc8e4f79a49f7f04027ac999",
  "webhook_type": "OWNERS",
  "process_type": "historical_update",
  "webhook_code": "historical_update",
  "link_id": "16f68516-bcbc-4cf7-b815-c500d4204e28",
  "request_id": "4363b08b-51eb-4350-9c74-5df5ac92a7f6",
  "external_id": "your_external_id",
  "data": {
    "total_owners": 2 // Total number of owners
  }
}

Once you receive the notification, you can get further details by making the following request:

curl --request GET 'https://api.belvo.com/api/owners/?link=link_id' \
-u [Secret Key ID]:[Secret Key PASSWORD]
Query ParameterDescriptionExample
linkThe link_id you received in the webhook notification.2f5d361d-dad6-45d4-a0bf-26d479766067