canonical: https://jentic.com/apis/sieg.com/buscar-xmls-por-nsu

# Sieg Buscar XMLs por NSU

The SIEG Buscar XMLs por NSU API lists the Brazilian fiscal documents available in a SIEG account starting from a given NSU, the sequential number SIEG assigns as documents arrive. A request sends NsuInicial and an optional LimiteResultados cap, and the response returns ListaNsuConsulta, where each entry carries its NumeroNsu, TipoXml, DataEmissao, and the CNPJ or CPF of the issuer, recipient, service taker, and sender. Storing the highest NumeroNsu seen and starting the next call after it gives an incremental sync that only picks up new documents.

## For AI agents

Sync new fiscal documents from SIEG incrementally: send a starting NSU, get back each document's NSU number, type, issue date, and party CNPJ or CPF, then resume from the last NSU on the next run.

## Scope

Does not download XML content, issue invoices, or file tax returns. Use for listing fiscal document entries from a starting NSU for incremental sync only.

## Capabilities

- List fiscal documents available from a starting NSU sent in NsuInicial
- Cap each page of results with LimiteResultados
- Return each entry's NumeroNsu, TipoXml, and DataEmissao
- Identify the parties on each document through CnpjCpfEmitente, CnpjCpfDestinatario, CnpjCpfTomador, and CnpjCpfRemetente
- Check IsSuccess, StatusCode, and ErrorMessage to confirm a sync step completed

## Use cases

### Agent-run incremental sync through Jentic

A bookkeeping agent connected through Jentic runs a scheduled sync against SIEG. It sends the last processed NSU plus one as NsuInicial with a LimiteResultados of 50, records each entry's NumeroNsu, TipoXml, and DataEmissao, and repeats until the list comes back empty. The SIEG JWT and access key are injected at call time, so the agent never handles them.

Example prompt: Call POST `/api/v1/buscar-xmls/nsu` with NsuInicial 115 and LimiteResultados 50, store the highest NumeroNsu returned, and call again from the next NSU until ListaNsuConsulta is empty

### Routing documents by party

Groups with several companies need to send each incoming document to the right entity. Each ListaNsuConsulta entry names the issuer and recipient CNPJ or CPF, and for transport documents the service taker and sender, so a sync job can route new documents to the correct company's books without opening each XML.

Example prompt: Call POST `/api/v1/buscar-xmls/nsu` from the last NSU and group the returned entries by CnpjCpfDestinatario, listing the NumeroNsu values for each company

### Detecting new events and documents

TipoXml on each entry distinguishes document types from events, such as the 'Event' value shown in the spec's example. A monitor can poll from the last NSU and alert when a new event arrives, for example to prompt a check for a cancellation, before downloading the full XML with another SIEG API.

Example prompt: Call POST `/api/v1/buscar-xmls/nsu` from the stored NSU and report every entry whose TipoXml is 'Event' with its NumeroNsu and DataEmissao

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/api/v1/buscar-xmls/nsu` | List documents from a starting NSU |

## Key resources

- **NSU listing** — Fiscal document entries from a starting NSU, each with NumeroNsu, TipoXml, DataEmissao, and party CNPJ or CPF

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 0 / 100
- **Maturity:** Non-Ready
- **Dimensions:**
  - Foundational Compliance: 100 / 100
  - Developer Experience & Jentic Compatibility: 76 / 100
  - AI-Readiness & Agent Experience: 49 / 100
  - Agent Usability: 94 / 100
  - Security: 58 / 100
  - AI Discoverability: 0 / 100
- **View full report:** https://jentic.com/apis/sieg.com/buscar-xmls-por-nsu/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring Buscar XMLs por NSU by hand means generating a SIEG JWT, pairing it with an X-API-Key or X-OAuth-Token header, and tracking the last NumeroNsu between runs yourself. Through Jentic you install once, import Buscar XMLs por NSU from the API Directory, store the credentials once, and your agent calls it.
- **Permission scoping:** Buscar XMLs por NSU carries its starting NSU inside the request body, so rules bound which operations your agent may call, not which NSU range it reads. Limit a sync agent to this listing operation and leave SIEG's download and upload operations out unless you add them.
- **Credential handling:** Your SIEG JWT and access key are stored once, encrypted, by your own Jentic One instance and injected at execution time. They never enter the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'list new SIEG documents by NSU' or 'sync fiscal documents incrementally', and Jentic returns this operation with its input schema so the agent sends NsuInicial and LimiteResultados correctly.

## Related APIs

- **SIEG Baixar XML por NSU** — Download XMLs as a ZIP by NSU sequence number
- **SIEG BaixarXml** — Download one fiscal document XML by its access key
- **SIEG BaixarXmls** — Download batches of fiscal XMLs by type and issue date
- **NotaGuard** — List and filter NF-e, NFC-e, and NFS-e documents and download their XML or DANFE

## FAQ

### What authentication does the SIEG Buscar XMLs por NSU API use?

Per its OpenAPI spec, each call needs two credentials together: a JWT sent as an HTTP bearer token, plus either an X-API-Key header or an X-OAuth-Token header carrying a SIEG OAuth 2.0 token. The JWT is generated by SIEG's authentication endpoint, which is not part of this spec. Through Jentic both credentials are stored encrypted by your own instance and attached at call time, so the agent never sees them.

### What is an NSU and how do I sync from it?

The NSU is the sequential number SIEG assigns to each document entry. Send NsuInicial, which is required, with an optional LimiteResultados, then save the highest NumeroNsu in the response and start the next call after it so each run only returns new entries.

### Does Buscar XMLs por NSU return the XML content?

The response schema lists entry metadata: NumeroNsu, TipoXml, DataEmissao, and the party CNPJ or CPF fields. To download document XML, pair it with a SIEG download API such as Baixar XML por NSU or BaixarXml.

### What are the rate limits for the SIEG Buscar XMLs por NSU API?

The OpenAPI spec does not specify rate limits. Check your SIEG plan and the documentation at https://sieg.com for current limits.

### Is there a SIEG Buscar XMLs por NSU MCP server?

You don't need an MCP server to give your agent the Buscar XMLs por NSU API. Jentic connects it directly from the API Directory: import it, store your SIEG JWT and access key once, and your agent calls the NSU listing when it syncs, discovered on demand rather than held in its context.

### Can I limit what my agent is allowed to do with the SIEG Buscar XMLs por NSU API?

Yes, at the operation level. For example, a sync agent's rule can include only this NSU listing, so it can see which documents arrived but cannot download or upload any XML through other SIEG APIs, and every call it makes is logged. The rule cannot restrict the starting NSU, because NsuInicial is sent in the request body.

### How do I run an NSU sync through Jentic?

Search Jentic for 'list new SIEG documents by NSU', load the POST `/api/v1/buscar-xmls/nsu` operation, and send NsuInicial with your last processed NSU plus one and a LimiteResultados such as 50. To run it on your own infrastructure, install Jentic One from its GitHub repo.
