Skip to main content
SIEG is a Brazilian fiscal document platform used by accounting firms and finance teams. It automatically captures every electronic fiscal document issued by or against a company and stores it in the Cofre SIEG. This source brings those documents (the original XML files) into your Lakehouse.

Configuring SIEG as a Source

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

1. Add account access

SIEG requires three credentials, and all of them are issued by SIEG to you. The Client ID and the Secret Key identify your integration. They are created when SIEG approves an integration request:
1

Request the integration

Fill in the integration form on the SIEG integrations portal with your company and system details.
2

Wait for approval

SIEG reviews the request and replies by email with a link to your credentials.
3

Copy both values

Open the link and copy the ClientId and the SecretKey.
The credentials page can only be opened once. Copy both values somewhere safe before closing it: if they are lost, SIEG has to issue new ones.
The API Key selects which vault is read, and is created by an administrator of your own SIEG account:
1

Open the API settings

Sign in to app.sieg.com and go to Minha Conta > Integrações API SIEG.
2

Generate a new key

Click Gerar nova chave API, give it an identification name, choose an expiration date (minimum 3 months, maximum 5 years) and select the read access level.
3

Copy the key

Copy the value of the Chave API field. Like the other two, it is shown only once.
The following configurations are available:
  • Client ID: The Client ID issued for your integration.
  • Secret Key: The Secret Key issued for your integration.
  • API Key: The API key to access your vault.
  • Initial sync date (Advanced): Starting point for data extraction, shared by both streams: documents issued from this date on, and events SIEG received from this date on. Leave empty to extract everything the regular extraction reaches, about the last 90 days of documents. Older documents can be recovered for specific companies with History CNPJs, back to this date.
  • Document types (Advanced): Which types to extract. Leave it empty to bring all of them.
  • Event types (Advanced): SEFAZ event type codes the events stream fetches, for example 110111 (cancellation) or 110110 (correction letter). Leave empty for the default set.
  • History CNPJs (Advanced): CNPJs (or CPFs) whose documents older than the ~90 days the regular extraction reaches should be recovered, back to the Initial sync date: every document where the CNPJ is the issuer, recipient, sender or payer.
  • History end date (Advanced): Date SIEG received the documents where the history stops and the regular extraction takes over. Leave empty to have it set automatically on the first run.
  • History time per run (minutes) (Advanced): How long each run may spend extracting the history of History CNPJs. What is not done continues in the next runs. Defaults to 300 minutes.
Add the account access and click Next.

2. Select streams

SIEG has a single stream, documents, which carries every document type. Select it 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 the table (which will contain the fetched documents), and the type of sync.
  • Layer: choose between the existing layers on your catalog. This is where you will find your new extracted table once 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.
  • Sync Type: use INCREMENTAL. Each run resumes exactly where the previous one stopped (driven by the unique document number), so only new documents are fetched. 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. This decision usually depends on how frequently you need the new table data updated. 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.
  • Additional Full Sync: Run a full export periodically in addition to incremental syncs. (Note: historical syncs are subject to SIEG’s roughly 90-day retention window, unless backfilled using History CNPJs).
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.

Streams and Fields

Fiscal XML layouts change with every schema version, and NFS-e has no national standard: each municipality publishes its own. A fixed set of typed columns would break every time a layout changes, so SIEG documents follow the same model Nekt uses for NoSQL sources: the whole document lands in a single column, next to the metadata needed to identify and filter it.
Stream containing all captured electronic fiscal documents and their attached events.Key Fields:

Document types

All types share the documents table and are told apart by the document_type field.
Nota Fiscal Eletrônica (model 55), the invoice used for goods transactions between companies. Delivered with document_type set to NFe.
Nota Fiscal de Consumidor Eletrônica (model 65), the invoice used for retail sales to end consumers. Delivered with document_type set to NFCe.
Conhecimento de Transporte Eletrônico, the document that covers freight and transport services. Delivered with document_type set to CTe.
Nota Fiscal de Serviço Eletrônica, the invoice used for services. Delivered with document_type set to NFSe.
NFS-e has no national standard: each municipality defines its own XML layout. Many carry no access key, and some arrive wrapped in a consultation envelope rather than as a standalone note. For those, access_key is empty and the structure inside document varies by municipality.
Cupom Fiscal Eletrônico, the electronic sales receipt issued by SAT and MFE devices. Delivered with document_type set to CFe.
Events attached to a document: cancellations, correction letters (CC-e), and operation manifestations. Delivered with document_type set to Evento, carrying the access_key of the document they refer to and their code in event_codes.

Data Model

The connector has a single stream. Documents are uniquely identified by their document_id.

Transformation example: reading data out of a document

The metadata columns exist so that the most common filters (by party, by type, by date) never require parsing the document column. To read a specific field out of document, parse it in a Query or Notebook using standard JSON functions. For example:

Implementation Notes

The main SIEG API route keeps roughly 90 days of documents, and that window moves forward every day. Anything older is no longer served by the main NSU sequence. However, older documents can be recovered for specific companies by configuring History CNPJs, which uses an alternative, slower date-filtered route.This makes a first historical load time-sensitive: while it runs, SIEG keeps trimming the oldest documents from the main sequence. A full 90-day window is around 2.4 million documents and takes roughly a day and a half of uninterrupted extraction. It finishes comfortably if it is left alone, but every interrupted run gives back ground that the trimming takes permanently.If the extraction ever falls behind the trimming, the source warns you in the run log: documents between where it stopped and where SIEG’s history now begins were removed before they could be read.

History Backfill

Set History CNPJs and the documents stream, after the NSU walk, recovers the documents of those CNPJs that are older than the NSU route reaches, back to the Initial sync date: every document where the CNPJ is the issuer, recipient, sender or payer.
  • Split by upload date: NSUs are handed out in order of arrival, so the history covers what reached the vault before the point where the NSU route begins, and the two routes never return the same document. The cut-off is configured in History end date or derived automatically on the first run.
  • Progress is kept per CNPJ: The stream state saves the oldest upload date covered, so a stopped run keeps what it did. Adding a CNPJ later backfills only that one; an earlier Initial sync date resumes every CNPJ further back.
  • Time budget: The backfill runs up to the History time per run (default 300 minutes), then stops and continues in the next run. A full sync ignores both the saved progress and the budget because it entirely rebuilds the table.

API Limits & Performance

  • The regular extraction (NSU route) allows 60 requests per minute and returns at most 50 documents per call, which caps the extraction at roughly 1,500 documents per minute. A first load covering the full retention window can take a day or more for high-volume accounts, and the incremental runs after it are quick.
  • The date-filtered route used for the History backfill is much slower, serving about 6 requests a minute per API key. The connector paces requests to one every 12 seconds and honors Retry-After on 429. Backfilling ~18 months of history for a moderately busy CNPJ can take around 3 hours.
  • Adaptive Pacing: The connector implements adaptive API pacing that measures each endpoint against its own normal latency threshold. Because operations vary widely in latency (e.g. quick listings vs. 3-5s batch downloads or heavy event paginations), this granular pacing avoids false degradation signals and optimizes overall extraction speed without tipping the API over.
  • The NSU sequence can have gaps. Whole stretches of NSUs might answer 404; the connector handles this and automatically adjusts its date search probes.
  • Each run resumes from the document right after the last one extracted, so nothing is fetched twice and nothing is skipped.
  • Selecting fewer document types does not make the extraction faster, since SIEG numbers every type in a single sequence, but it avoids storing what you do not need.

Skills for agents

Download SIEG skills file

SIEG connector documentation as plain markdown, for use in AI agent contexts.