canonical: https://jentic.com/apis/sieg.com/baixar-xml-por-nsu

# Sieg Baixar XML por NSU

The SIEG Baixar XML por NSU API downloads the fiscal document XMLs associated with an NSU, the sequential number SIEG assigns to stored documents. A request sends a single Nsu value and the response is a ZIP archive containing one or more XMLs. Because NSUs are sequential, a client can walk forward from the last number it processed to collect documents in order.

## For AI agents

Download the fiscal document XMLs tied to an NSU sequence number from SIEG as a ZIP archive.

## Scope

Does not search documents by access key, filter by CNPJ, or issue invoices. Use for downloading fiscal XMLs by NSU sequence number only.

## Capabilities

- Download the XMLs associated with an NSU as a single ZIP archive
- Step through documents in sequence by incrementing the Nsu value
- Detect invalid requests or missing authorisation from the 400 and 401 responses

## Use cases

### Agent that pulls new fiscal documents in sequence

A bookkeeping agent keeps a company's ledger current by importing each new fiscal document once. Through Jentic the agent searches for 'download XML by NSU', loads the baixarXmlPorNsu operation, and sends the next Nsu after the last one it stored, with the SIEG JWT and access key injected at call time. It unpacks the ZIP, records the documents, and moves on to the following NSU.

Example prompt: Call POST `/api/v1/baixar-xml/nsu` with Nsu 1043, unzip the returned archive, and store each XML before moving to Nsu 1044

### Fiscal XML backup

Brazilian companies must keep fiscal XMLs for years, and an NSU-ordered download is a simple way to mirror them to your own storage. Each call returns a ZIP for one NSU, so a backup job can record the highest NSU it has saved and resume from there after an interruption.

Example prompt: Starting from the highest saved NSU, call POST `/api/v1/baixar-xml/nsu` for each following Nsu and write every ZIP to object storage

### Recover a document from its sequence number

When a system logs only the NSU of a document it received, the original XML can still be retrieved. Sending that Nsu returns the ZIP with the associated XMLs, which an accountant or support agent can open without searching by access key.

Example prompt: Call POST `/api/v1/baixar-xml/nsu` with Nsu 88231 and return the XML files inside the ZIP

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/api/v1/baixar-xml/nsu` | Download XMLs for an NSU as a ZIP |

## Key resources

- **NSU downloads** — ZIP archives of the fiscal XMLs associated with a given Nsu

## 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: 73 / 100
  - AI-Readiness & Agent Experience: 54 / 100
  - Agent Usability: 94 / 100
  - Security: 58 / 100
  - AI Discoverability: 0 / 100
- **View full report:** https://jentic.com/apis/sieg.com/baixar-xml-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 Baixar XML por NSU by hand means obtaining a SIEG JWT from a separate authentication endpoint, pairing it with an X-API-Key or X-OAuth-Token header, and handling a ZIP response instead of JSON. Through Jentic you install once, import it from the API Directory, store the credentials once, and your agent calls it.
- **Permission scoping:** Baixar XML por NSU sends the Nsu inside the request body, so rules bound which operations your agent may call, not which sequence numbers. Limit the agent to the operations it needs, such as the NSU download, and keep other SIEG 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 'download fiscal XMLs by NSU' or 'get the next documents after an NSU', and Jentic returns the matching SIEG operation with its input schema so the agent sends the Nsu correctly.

## Related APIs

- **NotaGuard** — List and filter NF-e, NFC-e, and NFS-e documents and download their XML
- **SIEG BaixarXml** — Download a single document XML by access key
- **SIEG Baixar Eventos** — Download events such as cancellations linked to a document

## FAQ

### What authentication does the SIEG Baixar XML por NSU API use?

Per its OpenAPI spec, each call needs a JWT sent as an HTTP bearer token plus either an X-API-Key header or an X-OAuth-Token header with a SIEG OAuth 2.0 token. The JWT comes from SIEG's authentication endpoint, which is outside this spec, and a missing or wrong credential returns 401. Through Jentic both credentials are stored by your own instance and attached at call time, so the agent never sees them.

### What does the Baixar XML por NSU API return?

A ZIP archive (application/zip) containing the one or more XMLs associated with the Nsu you send. The request body has a single required field, Nsu, a 64-bit integer. Your client or agent needs to unzip the response to read the documents.

### What are the rate limits for the SIEG Baixar XML 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 before running a long NSU backfill.

### Is there a SIEG Baixar XML por NSU MCP server?

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

### How do I download XMLs by NSU through Jentic?

Search Jentic for 'download fiscal XMLs by NSU', load the POST `/api/v1/baixar-xml/nsu` operation, and send the Nsu value. Save the returned ZIP and increment Nsu to fetch the next set. To run it on your own infrastructure, install Jentic One from its GitHub repo.

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

Yes, at the operation level. A backup agent can be given a rule that includes only this NSU download, so it can mirror XMLs but cannot reach other SIEG operations, and every call it makes is logged. The Nsu value is sent in the request body, so the rule cannot cap which sequence numbers it requests.
