Before you start
You need a TMB API token. In the TMB Producer Portal, open Produtos > TMB API and copy the token (you can also revoke it or generate a new one there). The token is available once your product is registered and the contract with TMB is signed. If you generate a new token, the previous one stops working: update it in the source configuration.Configuring TMB as a Source
In the Sources tab, click on the “Add source” button located on the top right of your screen. Then, select the TMB 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:- API token: the token copied from Produtos > TMB API in the TMB Producer Portal.
- Start date: orders from this date on are extracted. TMB filters orders by date without saying which date it uses (creation or effectiveness), so orders around the start date may follow either one.
- Lookback days: (Default: 30) on each incremental extraction, the orders of this many days before the last order already extracted are read again, to catch late changes.
-
Full refresh interval (days): (Default: 7) every this many days, the whole order history since the start date is read again, so the financial status of older orders stays up to date. TMB does not report when an order changes, so this is the only way to refresh it. Set
0to turn it off; then the financial status of an order is only refreshed while it is inside the lookback window, and an order that becomes effective long after it was created may only be read by a full sync. - Page size: (Default: 100) how many records are asked for in each request. Lower it only if TMB refuses large pages.
2. Select streams
Choose which data streams you want to sync. For faster extractions, select only the streams that are relevant to your analysis.Tip: The stream can be found more easily by typing its name.The Order details stream is not selected by default: it makes one request per order (see API limits and performance). 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: you can choose between INCREMENTAL and FULL_TABLE.
- Incremental: every time the extraction happens, we’ll get only the new data, which is good if, for example, you want to keep every record ever fetched.
- Full table: every time the extraction happens, we’ll get the current state of the data, which is good if, for example, you don’t want to have deleted data in your catalog.
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. This decision usually depends on how frequently you need the new table data updated (every day, once a week, or only at specific times). Optionally, you can define some additional settings:- Configure Delta Log Retention and determine for how long we should store old states of this table as it gets updated. Read more about this resource here.
- Determine when to execute an Additional Full Sync. This will complement the incremental data extractions, ensuring that your data is completely synchronized with your source every once in a while. The connector already re-reads all orders every Full refresh interval (days); an Additional Full Sync also removes orders that TMB no longer lists.
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.Streams and Fields
Available streams
The table below lists every stream, its slug (the exact identifier to pass when creating the source via API) and a short description.
Every table has a
raw_data column (detalhe in Order details) with the record exactly as TMB returned it, including any field not listed as a column.
Fields by stream
Orders (pedidos)
Orders (pedidos)
One row per effective order.Identification:
pedido_id- Unique identifier of the order (primary key)produto_id- Product orderedprodutor,produtor_id- Producer who sells the productlancamento- Launch (campaign) the order belongs tostatus_pedido- Status of the order (e.g. Efetivado)status_financeiro- Financial status of the customer’s installments (e.g. Adimplente). It changes over time: see How orders stay up to date
valor_total- Total amount of the ordervalor_entrada- Down paymentparcelas- Number of installmentsvalor_parcela- Amount of each installmenttaxa_administracao- Administration fee charged by TMB, as returned by the APImelhor_dia_pagamento- Day of the month the customer chose to pay
criado_em- When the order was created (incremental replication key)data_efetivado- When the order became effective. TMB sends it without a timezone; it is read as São Paulo time
cliente,documento(CPF/CNPJ),email,telefone,nascimentopais,cep,endereco_estado,endereco_cidade,endereco_bairro,endereco_logradouro,endereco_numero,endereco_complemento,endereco_completo
utm_source,utm_medium,utm_campaign,utm_content- UTM parameters of the customer’s first visitutm_last_source,utm_last_medium,utm_last_campaign,utm_last_content- UTM parameters of the last visit before ordering
raw_data- The order as TMB returned it (JSON)
Order details (pedidos_detalhe)
Order details (pedidos_detalhe)
One row per order whose detail was read. TMB does not document the format of the detail, so it is kept whole as JSON.
pedido_id- Order the detail belongs to (primary key)criado_em- When the order was created (incremental replication key)detalhe- The full detail returned by TMB (JSON)
Products (produtos)
Products (produtos)
One row per product of the producer.
produto_id- Unique identifier of the product (primary key)produto_nome- Name of the productdescricao- Description of the productvalor_total- Average ticket as TMB formats it for display (e.g. “R$ 1.000,00”)valor_total_numerico- The same average ticket as a numberativo- Whether the product is activeraw_data- The product as TMB returned it (JSON)
Offers (ofertas)
Offers (ofertas)
One row per offer of each product.
produto_id- Product the offer belongs tooferta_key- What identifies the offer within its product: its id when TMB sends one, else its URL (primary key, withproduto_id)oferta_id- Identifier of the offer, when TMB sends onetitulo- Title of the offerurl- URL of the offer’s checkout pageraw_data- The offer as TMB returned it (JSON)
Implementation Notes
How orders stay up to date
TMB exposes no “last updated” date on orders, and an order’s financial status keeps changing while the customer pays the installments. The connector therefore:- On the first extraction (and on a full sync), reads every order since the Start date.
- On each incremental extraction, reads the orders of the last Lookback days before the most recent order already extracted.
- Every Full refresh interval (days), reads all orders since the Start date again, updating the financial status of older orders. That extraction takes longer than the others.
pedido_id, so re-reading an order updates its row. An order that TMB stops listing is not removed by incremental extractions; a full sync rebuilds the table from what TMB lists.
API limits and performance
- TMB allows only a few requests per minute (about 10 per minute when listing orders, about 20 on the other endpoints). When the limit is reached, the extraction waits for the next minute instead of failing, so long histories take longer.
- Order details needs one request per order, about 1,200 orders per hour. On the first extraction (and on a full sync) it reads every order since the start date, so with a long history that first extraction can take hours. After that, each extraction only reads the details of orders created or made effective since the previous one, plus the ones that failed before.
- If you select Order details on a source whose orders were already extracted, only the details of new orders are read from then on. Run a full sync of the source to read the details of the older orders.
- An order whose detail could not be read is reported as a failure of the Order details table at the end of the run. The orders and the other details are still loaded, and the detail is asked again on the next extractions. A detail that TMB answers as “not found” three times is no longer asked, with a warning.
- The details of an order are read once. If you need them refreshed (for example, after changes in the installments), run a full sync of the source.
Data Quality Considerations
- Amounts are stored as numbers in BRL; the product’s
valor_totalalso keeps TMB’s display format. - Dates are stored in UTC.
data_efetivado, which TMB sends without a timezone, is read as São Paulo time. - If a value comes in a format the column cannot hold, the column is left empty and the original value stays in
raw_data.