canonical: https://jentic.com/apis/sieg.com/contar-xmls

# Sieg Contar Xmls

The SIEG Contar Xmls API counts the Brazilian fiscal document XMLs stored in a SIEG Cofre, broken down by document type. A request filters by issue date (DataEmissaoInicio and DataEmissaoFim), by upload date (DataUploadInicio and DataUploadFim), or both, with a window of up to three months, and can narrow the count to a CNPJ for the issuer, recipient, or, for CT-e transport documents, the service taker and sender. The response returns separate totals for NFe, NFCe, CTe, CFe, and NFSe.

## For AI agents

Count the fiscal XMLs stored in SIEG for a date window of up to three months, optionally filtered by issuer, recipient, taker, or sender CNPJ, and get totals for NF-e, NFC-e, CT-e, CF-e, and NFS-e.

## Scope

Does not download XML content, issue invoices, or file tax returns. Use for counting fiscal XMLs stored in SIEG by type, date, and CNPJ only.

## Capabilities

- Count stored fiscal XMLs per type, returned as NFe, NFCe, CTe, CFe, and NFSe totals
- Bound the count by issue date with DataEmissaoInicio and DataEmissaoFim
- Bound the count by upload date with DataUploadInicio and DataUploadFim
- Narrow the count to one company with CnpjEmit for the issuer or CnpjDest for the recipient
- Count CT-e transport documents by service taker or sender with CnpjTom and CnpjRem

## Use cases

### Agent-run document volume checks through Jentic

An accounting agent connected through Jentic answers 'how many invoices did this client receive in October?' by calling Contar Xmls with CnpjDest and the month's DataEmissaoInicio and DataEmissaoFim. It reports the NFe, NFCe, CTe, CFe, and NFSe totals from the response. The SIEG JWT and access key are injected at call time, so the agent never holds them.

Example prompt: Call POST `/api/v1/contar-xmls` with CnpjDest '12345678000199', DataEmissaoInicio 2026-10-01T00:00:00Z, and DataEmissaoFim 2026-10-31T23:59:59Z, then report the NFe and NFSe totals

### Month-end completeness check

Before closing a period, an accounting office confirms that the documents it expects have reached SIEG. Counting by upload date with DataUploadInicio and DataUploadFim shows how many XMLs arrived in the window, and comparing that with the count by issue date highlights documents issued in the period but not yet uploaded.

Example prompt: Call POST `/api/v1/contar-xmls` twice for the same CnpjEmit, once with DataEmissaoInicio and DataEmissaoFim and once with DataUploadInicio and DataUploadFim for the month, and report any type whose totals differ

### Sizing an export before downloading

Batch downloads are easier to plan when the volume is known. A count by issue date tells a sync job how many documents of each type to expect, so it can choose page sizes and confirm the download returned everything. The three-month window limit means longer periods are counted in consecutive slices.

Example prompt: Call POST `/api/v1/contar-xmls` for each of the four quarters of 2026 with DataEmissaoInicio and DataEmissaoFim and sum the NFe totals for the year

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/api/v1/contar-xmls` | Count stored XMLs by type |

## Key resources

- **XML counts** — Totals of stored NFe, NFCe, CTe, CFe, and NFSe documents for date and CNPJ filters

## 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:** 62 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 74 / 100
  - Developer Experience & Jentic Compatibility: 53 / 100
  - AI-Readiness & Agent Experience: 54 / 100
  - Agent Usability: 94 / 100
  - Security: 58 / 100
  - AI Discoverability: 50 / 100
- **View full report:** https://jentic.com/apis/sieg.com/contar-xmls/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 Contar Xmls by hand means obtaining a SIEG JWT, pairing it with an X-API-Key or X-OAuth-Token header, and splitting long periods into windows of three months or less. Through Jentic you install once, import Contar Xmls from the API Directory, store the credentials once, and your agent calls it.
- **Permission scoping:** Contar Xmls carries its CNPJ and date filters inside the request body, so rules bound which operations your agent may call, not which companies it counts. Limit a reporting agent to this count 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 'count fiscal XMLs in SIEG' or 'how many NF-e this month', and Jentic returns the Contar Xmls operation with its input schema so the agent sends the date windows and CNPJ filters correctly.

## Related APIs

- **SIEG BaixarXmls** — Download batches of fiscal XMLs by type and issue date
- **SIEG Buscar XMLs por NSU** — List documents incrementally from a starting NSU
- **SIEG Baixar Eventos** — Download events linked to NF-e, CT-e, and NFC-e documents with CNPJ and date filters
- **NotaGuard** — List and filter NF-e, NFC-e, and NFS-e documents and download their XML or DANFE

## FAQ

### What authentication does the SIEG Contar Xmls 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. Through Jentic both credentials are stored encrypted by your own instance and attached at call time, so the agent never sees them.

### Which filters does Contar Xmls require?

The request must include an issue-date window (DataEmissaoInicio and DataEmissaoFim), an upload-date window (DataUploadInicio and DataUploadFim), or both, and the spec limits the window to three months. The CNPJ filters CnpjEmit, CnpjDest, CnpjTom, and CnpjRem are optional and take 14 digits. Missing or inconsistent dates return 400.

### Which document types does Contar Xmls count?

The response returns five totals: NFe, NFCe, CTe, CFe, and NFSe. The CnpjTom and CnpjRem filters apply to CT-e transport documents.

### What are the rate limits for the SIEG Contar Xmls 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 Contar Xmls MCP server?

You don't need an MCP server to give your agent the Contar Xmls API. Jentic connects it directly from the API Directory: import it, store your SIEG JWT and access key once, and your agent calls the count operation when it needs a total, discovered on demand rather than held in its context.

### Can I limit what my agent is allowed to do with the SIEG Contar Xmls API?

Yes, at the operation level. A reporting agent can have a rule that includes only this count operation, so it can answer volume questions but cannot download or upload any document through other SIEG APIs, and every call it makes is logged. The rule cannot restrict which CNPJ is counted, because the CNPJ filters are sent in the request body.

### How do I count a client's invoices through Jentic?

Search Jentic for 'count fiscal XMLs in SIEG', load the POST `/api/v1/contar-xmls` operation, and send CnpjDest with the client's CNPJ plus DataEmissaoInicio and DataEmissaoFim for the period. To run it on your own infrastructure, install Jentic One from its GitHub repo.
