Skip to main content
TOTVS Protheus is an ERP widely used by Brazilian companies for finance, sales, inventory, and invoicing. This connector reads Protheus through its own REST service, using the standard framework API that queries Protheus tables (GenericQuery), so it works on Protheus servers on TOTVS Cloud and on your own infrastructure.

Before you start

Ask your Protheus administrator (or your TOTVS partner) to check the following:
  • The Protheus REST service is running and reachable from the internet over HTTPS, for example https://mycompany.protheus.cloudtotvs.com.br:4050/rest. Nekt runs in the cloud, so an address that only works inside your network cannot be used. The connection sends the Protheus user and password on every request, so http:// addresses are refused.
  • The REST service has security enabled (SECURITY=1 in the REST configuration). The API this connector uses only runs with security on.
  • The Protheus framework library (LIB) is up to date. The GenericQuery API is part of the framework libraries released since 2022. Environments on TOTVS Cloud on a supported release already have it.
  • A Protheus user for the integration with access to the tables of the streams you want (for example, accounts receivable, customers, products). To receive CPF/CNPJ, e-mail, and phone numbers, the user also needs access to personal and sensitive data (LGPD) in the Protheus Configurator: otherwise Protheus hides those columns and they arrive empty (the run log lists them).
  • The company group code and a branch code the user can access (for example, 01 and 0101).
Each request opened by the connector uses a Protheus REST thread, like any other integration with the Protheus API. Schedule the source outside peak hours if your REST service has few threads.

Configuring TOTVS Protheus as a Source

In the Sources tab, click on the “Add source” button located on the top right of your screen. Then, select the TOTVS Protheus option from the list of connectors. Click Next and you’ll be prompted to add your access.

1. Add account access

The following configurations are available:
  • Protheus REST URL: Address of the Protheus REST service including its path, as reached from the internet, for example https://mycompany.protheus.cloudtotvs.com.br:4050/rest.
  • Username and Password: The Protheus user for the integration.
  • Company group code: The Protheus company group (grupo de empresas) to extract, for example 01. To extract more than one company group, create one source per group.
  • Branch code: Any branch (filial) of that group the user can access, for example 0101. It only opens the session: the data of every branch of the group is extracted, and each record carries its branch in the *_filial column.
  • Start date (optional): Limits accounts receivable to those issued on or after this date, plus every receivable that is still open, and sales orders and their items to orders issued on or after this date. Leave it empty to read the whole history. If you set it, keep in mind:
    • A receivable issued before this date stays in the table only while it is open. When it is paid, it disappears from the table (it does not show up as paid).
    • Receivables issued before this date that were already paid are never loaded.
    • Moving the date forward makes the tables smaller.
    • Totals of received amounts from this table are complete only for receivables issued on or after this date.
  • Page size (advanced): Records requested per call. Lower it if the Protheus REST service times out.
  • Verify SSL certificate (advanced): Turn off only if your Protheus server uses a self-signed or incomplete certificate.
Once you’re done, click Next.

2. Select streams

Choose which data streams you want to sync. Before extracting anything, Nekt checks every selected stream with Protheus. If the user cannot read a table, or a table is not used in your Protheus environment, the run stops before extracting anything and the run log lists each stream and what to fix. Give the user access to the table or unselect the stream. Select the streams and click Next.

3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.
  • Layer: Choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
  • Folder: A folder can be created inside the selected layer to group all tables being created from this new data source.
  • Table name: We suggest a name, but feel free to customize it. You have the option to add a prefix to all tables at once and make this process faster!
  • Sync Type: Every stream is FULL_TABLE: each run replaces the table with what Protheus has at that moment, within the Start date limit described above. Read more about Sync Types here.
Once you are done configuring, click Next.

4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters. To define your Trigger, consider how often you want data to be extracted from this source and the load on your Protheus REST service. Accounts receivable and sales orders are usually the largest tables: use the Start date to keep them bounded. Optionally, you can define some additional settings:
  • Delta Log Retention: Determine for how long we should store old states of this table as it gets updated. Read more about this resource here.
Once you are ready, click Next to finalize the setup.

5. Check your new source

You can view your new source on the Sources page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.
For you to be able to see it on your Catalog, you need at least one successful source run.

Good to know

  • Column names are the Protheus field names in lower case (E1_NUM becomes e1_num), so anyone who knows the Protheus data dictionary recognizes them. Custom fields (*_X...) and any other field Protheus returns are kept in the extra_fields column as JSON.
  • Bank slips (2nd copy): the accounts receivable stream brings the bank’s own number (e1_numbco, nosso número), the barcode as stored in Protheus (e1_codbar), the due dates, the amount, and the open balance. Nekt also derives the 47-digit typeable line (boleto_digitable_line) from the barcode, validating the check digits. The barcode is only present for receivables already registered with the bank (CNAB return, online bank API, or slip printing). The slip PDF or a slip URL is not available through the Protheus API.
  • Stock: b2_qatu is the physical quantity per product and warehouse. Reserved (b2_reserva) and committed (b2_qemp) quantities are separate columns, so the available quantity is b2_qatu - b2_reserva - b2_qemp.
  • Prices: the commercial prices are in the Price table items stream (da1_prcven per table and product). b1_prv1 in Products is only the base price registered on the product.
  • Deleted records in Protheus are not extracted, and they disappear from the tables on the next run.
  • Text values come without the trailing blanks Protheus pads its fields with. Dates are stored as YYYY-MM-DD; an empty Protheus date is stored empty.
  • Records changed during a run: Nekt reads each table in the order of its key, continuing from the last record read, so records added or removed elsewhere in the table during the run do not make it skip others. A record added during the run in a part of the table already read, or removed after it was read, shows up correctly on the next run.

Streams and Fields

Available streams

The table below lists every stream, its slug (the exact identifier to pass when creating the source via API), the Protheus table it reads, and its sync type.

Fields by stream

Stream name: accounts_receivable. Source: SE1 - Contas a Receber.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): e1_filial, e1_prefixo, e1_num, e1_parcela, e1_tipo, e1_cliente, e1_loja
Stream name: customers. Source: SA1 - Clientes.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): a1_filial, a1_cod, a1_loja
Stream name: products. Source: SB1 - Produtos.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): b1_filial, b1_cod
Stream name: product_complements. Source: SB5 - Complemento de Produto.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): b5_filial, b5_cod
Stream name: price_tables. Source: DA0 - Tabelas de Preço.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): da0_filial, da0_codtab
Stream name: price_table_items. Source: DA1 - Itens da Tabela de Preço.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): da1_filial, da1_codtab, da1_item, da1_codpro
Stream name: stock_balances. Source: SB2 - Saldos em Estoque.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): b2_filial, b2_cod, b2_local
Stream name: warehouses. Source: NNR - Locais de Estoque.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): nnr_filial, nnr_codigo
Stream name: sales_orders. Source: SC5 - Pedidos de Venda.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): c5_filial, c5_num
Stream name: sales_order_items. Source: SC6 - Itens dos Pedidos de Venda.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): c6_filial, c6_num, c6_item, c6_produto
Stream name: sellers. Source: SA3 - Vendedores.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): a3_filial, a3_cod
Stream name: payment_terms. Source: SE4 - Condições de Pagamento.Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): e4_filial, e4_codigo
Stream name: branches. Source: Company group branches (framework API).Sync Strategy:
  • Full table (the whole table is read on every run)
  • Primary key(s): enterprise_group, code