Scan your whole stack
Are you using stackin-python-sdk?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.31.2
stackin-python-sdk was last scanned on 29 Nov 2026 at version 0.31.2. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.31.2 LATEST | 29 Nov 2026 | No rules fired |
| 0.31.1 | 26 Nov 2026 | No rules fired |
| 0.31.0 | 25 Nov 2026 | No rules fired |
| 0.30.0 | 24 Nov 2026 | Not shown |
| 0.29.0 | 24 Nov 2026 | Not shown |
Findings for v0.31.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.31.2; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Integrate once. Issue everywhere.
API Reference · Python SDK guide
Python SDK for fiscal document issuance — a handful of business fields, nothing about certificates, XML, XSD, signing or SOAP. The API resolves all of that from the issuer's own configuration, identified by api_key.
One class, Invoice — issue()/consult()/cancel()/reissue()/correct()/invalidate()/pdf()/history()/submissions()/received()/sync_received()/manifest()/usage(), nothing else to instantiate. Each line item is a Product (stackin.br) — description plus either unit_price or amount are universal, everything else (ncm/cfop/cest/tax groups...) is Brazil-specific and only required for NFE; NFSE ignores it.
unit_price is the price of one unit. amount is the gross total of
the line's products, before discount, freight, insurance and other
expenses. Send either; sending both asserts that they agree.
from decimal import Decimal
# One unit
Product(description="Consultoria", quantity=Decimal("1"), unit_price=Decimal("1500.00"))
# More than one unit — amount is computed as 2 x 120.00 = 240.00
Product(description="Teclado", quantity=Decimal("2"), unit_price=Decimal("120.00"))
# A fractional quantity — 1.5 x 30.00 = 45.00
Product(description="Cabo", quantity=Decimal("1.5"), unit_price=Decimal("30.00"))
# Legacy: amount alone still means the line's gross total
Product(description="Servico", quantity=Decimal("3"), amount=Decimal("150.00"))
# Both, checked against each other before the document is transmitted
Product(
description="Teclado",
quantity=Decimal("2"),
unit_price=Decimal("120.00"),
amount=Decimal("240.00"),
)
# With charges: 5000.00 - 100.50 + 40.00 + 10.00 = 4949.50 on the note
Product(
description="Servidor",
quantity=Decimal("2"),
unit_price=Decimal("2500.00"),
discount=100.50,
freight=40.00,
insurance=10.00,
)
Amounts that do not add up are refused before the authorizer sees them,
with a 422 naming the line and both numbers:
{
"detail": {
"code": "ITEM_TOTAL_MISMATCH",
"field": "items[0].amount",
"message": "amount is 50.00, but quantity x unit_price is 150.00.",
"expected": "150.00",
"received": "50.00"
}
}
Before: quantity = 3, amount = 150.00
After: quantity = 3, unit_price = 50.00
Nothing has to migrate. amount keeps the meaning it always had and is
not deprecated in this release; a line sent with amount alone is built
exactly as it was before.
pip install stackin-python-sdk
Get an api_key from the stackin dashboard — select the issuing company, then Management → Integrations → API keys (context sdk). One key per issuing company, shown once at creation. The API resolves the issuer (CNPJ, state, address, certificate, environment) entirely from it; nothing about the issuer is ever passed on a call.
from decimal import Decimal
from stackin import Invoice, DocumentType, Address
from stackin.br import Product # Brazil-specific line item — NCM/CFOP
client = Invoice(api_key="COMPANY_API_KEY") # defaults to https://sdk.stackin.io
invoice = client.issue(
document_type=DocumentType.NFSE,
client_name="John Doe",
tax_id="00000000000",
items=[Product(description="Software development", unit_price=Decimal("5000.00"))],
)
status = client.consult("ACCESS_KEY...", document_type=DocumentType.NFSE)
client.cancel(
"ACCESS_KEY...",
document_type=DocumentType.NFSE,
reason="Typo",
)
client.reissue(invoice["id"]) # retries a rejected/failed submission
# The PDF, as raw bytes: the API draws the DANFE for an NF-e and the
# DANFSe for an NFS-e itself. The XML stays the legally valid document.
with open("nota.pdf", "wb") as file:
file.write(client.pdf(access_key, document_type=DocumentType.NFSE))
# NFE requires ncm/cfop on every item, plus the buyer's full recipient_address:
client.issue(
document_type=DocumentType.NFE,
client_name="Buyer Company Ltd",
tax_id="11111111111111",
items=[
Product(
description="Teclado",
quantity=Decimal("2"),
unit_price=Decimal("120.00"),
unit="UN",
ncm="84716052",
cfop="5102",
)
],
recipient_address=Address(
street="Avenida Atlantica",
number="500",
neighborhood="Copacabana",
city="Rio de Janeiro",
state="RJ",
zip_code="22010000",
),
external_reference="order-1234",
)
external_reference is your own id for the document — an order number, a ticket. It is stored as sent, returned on every read and webhook, and GET /invoices?external_reference= finds the document by it.
recipient_address is an Address — the buyer's address, required for NFE. On NFE street, number, neighborhood, city, state and zip code are required (a buyer abroad trades the zip code for a country, see A buyer abroad): it becomes enderDest on the wire and the SEFAZ rejects a partial one. city_code (the 7-digit IBGE municipality code) may be left out — the API resolves it from city and state and answers CITY_NOT_FOUND (422) when it cannot; send it yourself when the name is ambiguous. state is also what resolves idDest — a buyer in another state is emitted as an interstate operation automatically. On NFSE it is the tomador's address: optional, except when any item has tax_retained=True (the ISSQN retained by the tomador), where the city authorizer refuses the document without it (E0237) — then every field except city_code is required. In both cases a missing or incomplete address raises a ValueError locally, before the request goes out.
items is a list of Product (stackin.br) — description/amount apply to any document type; ncm/cfop (plus everything else on Product: cest, tax groups, presumed credits...) are Brazil-specific and required per item for NFE, ignored for NFSE (a service isn't a physical good). ncm is the full 8 digits, or 00 for a service line — the SEFAZ rejects any other short code (rejection 777), so one fails at construction. recopi_number must be the 20-digit RECOPI number; the SDK checks its two modulo-11 check digits (MOC §8.5) before sending.
Each of these is left out of the request body when unset, so a call that does not use them sends exactly what it sent before. The SDK checks only types and enums locally; the fiscal rules on them are the API's, answered as an APIError that names the rule.
discount — a Decimal (zero or more) taken off the whole document; the API spreads it over the lines:
client.issue(..., discount=Decimal("15.00"))
issued_at — the emission moment, a timezone-aware datetime, sent as ISO 8601 with its offset. A naive one raises ValueError. NF-e: at most 30 days back and 5 minutes ahead; NFS-e: never ahead.
from datetime import datetime, timedelta, timezone
client.issue(..., issued_at=datetime(2026, 11, 15, 9, 30, tzinfo=timezone(timedelta(hours=-3))))
purpose — NF-e only, why it is issued: Purpose.NORMAL (the default), COMPLEMENTARY, ADJUSTMENT or RETURN:
from stackin import Purpose
client.issue(..., purpose=Purpose.COMPLEMENTARY, referenced_keys=["3526..."])
direction — NF-e only: Direction.OUT (the default) or Direction.IN, an incoming note the company issues itself, such as goods returned by the buyer:
from stackin import Direction
client.issue(..., purpose=Purpose.RETURN, direction=Direction.IN, referenced_keys=["3526..."])
referenced_keys — NF-e only, a list of the 44-character access keys this note refers to: required for COMPLEMENTARY (exactly one) and, but for a few CFOPs, for RETURN:
client.issue(..., purpose=Purpose.RETURN, referenced_keys=["35261112345678000195550010000000011000000014"])
contingency — NF-e only: True sends the document through the UF's contingency authorizer (SVC-AN or SVC-RS, tpEmis 6/7) for when its own is down. Left False, nothing is sent:
client.issue(..., contingency=True)
With contingency=True it also takes contingency_started_at (a timezone-aware datetime, written as dhCont; defaults to the emission moment and may not be later than it) and contingency_reason (15 to 256 characters, written as xJust; the API has a default reason). Both are left out of the body when unset, and the API refuses either one without contingency=True:
client.issue(
...,
contingency=True,
contingency_started_at=datetime(2026, 11, 25, 9, 0, tzinfo=timezone.utc),
contingency_reason="SEFAZ authorizer unavailable since 09:00",
)
A recipient_address with state="EX" is a buyer outside Brazil. There tax_id is left out, zip_code and city_code may be left out, and country_code (the BACEN code, not Brazil's 1058) is required, with country_name beside it. The SDK does not check the BACEN code's check digit: the official table has countries whose digit does not close.
foreign_id — the buyer's passport or other document (5 to 20 characters), in place of a CPF/CNPJ:
client.issue(..., recipient_address=Address(..., state="EX", country_code="2496", country_name="Estados Unidos"), foreign_id="P12345678")
export — an Export (stackin.br) naming where the goods leave Brazil, required for an outgoing note abroad: exit_state and place, optionally dispatch_place:
from stackin.br import Export
client.issue(..., export=Export(exit_state="SP", place="Porto de Santos"))
fuel on a Product is the layout's fuel group (comb), needed for a fuel CFOP: anp_code (9 digits), anp_description and consumer_state are required; glp_percent, natural_gas_national_percent, natural_gas_imported_percent, starting_value, codif, temperature_quantity and biodiesel_percent are optional. It travels under the product's fuel key and is refused together with extra_groups["comb"]:
from stackin.br import Fuel, Product
Product(description="Gasolina C", ncm="27101259", cfop="5656", fuel=Fuel(anp_code="320102001", anp_description="GASOLINA C COMUM", consumer_state="SP"))
ibs_cbs on a Product is the Reforma Tributária group, and what it takes depends on the document type. The API enforces it, by field name; the SDK checks only the formats.
On an NF-e: cst (3 digits), classification (the 6-digit cClassTrib), rate_state, rate_city and rate_federal (percent) are required; base defaults to the item amount. reduction_ibs and reduction_cbs (0 to 100) are the cClassTrib's pRedIBS and pRedCBS — the API takes them for CST 011, 200 and 515 only and refuses them for any other; left out, they are not sent and the API reads them from the classification table, refusing the item when the table has none. The SDK checks only the range and leaves the CST rule to the API:
from stackin.br import IbsCbs, Product
Product(description="Arroz", ncm="10063021", cfop="5102", ibs_cbs=IbsCbs(cst="200", classification="200003", rate_state=0.1, rate_city=0.0, rate_federal=0.9, reduction_ibs=60, reduction_cbs=60))
On an NFS-e: cst, classification and operation_indicator (cIndOp, the 6-digit code of the NFS-e place-of-supply table, mandatory on a production NFS-e), plus the optional groups personal_use (indFinal), government (IbsCbsGovernment), referenced_nfse (access keys), recipient (IbsCbsRecipient, with an IbsCbsRecipientAddress), real_estate (RealEstate, RealEstateLease, RealEstateUnit), movable_goods (MovableGood), regular_taxation (IbsCbsRegularTaxation), deferral (IbsCbsDeferral) and presumed_credit (cCredPres). The Sefin Nacional computes the base, rates and amounts, so the API refuses the rates, base and the reductions there. An ME/EPP may send the group only with simples_apuracao_ibs_cbs "3" (see Company.update); an MEI never:
Product(description="Consultoria", unit_price=Decimal("1000.00"), ibs_cbs=IbsCbs(cst="000", classification="000001", operation_indicator="100301"))
issue() and validate() take presence ("0", "1", "2", "3", "5" or "9"), intermediary, transport, payments (1 to 100) and change; each is left out of the body when unset, and a Product takes net_weight and gross_weight (kg per unit). reissue() reuses the terms stored on the invoice. The SDK checks only the code sets and that method "99" carries a description; every other rule is the API's, answered as an APIError:
from decimal import Decimal
from stackin.br import Intermediary, Payment, PaymentCard, SaleTerms, Transport, TransportVolume
client.issue(
...,
presence="2",
intermediary=Intermediary(tax_id="11222333000181", identifier="loja-42"),
transport=Transport(freight_mode="1", volumes=[TransportVolume(quantity=1, net_weight=Decimal("1.5"))]),
payments=[Payment(method="03", amount=Decimal("10.00"), card=PaymentCard(integration="2", brand="01"))],
)
SaleTerms.from_invoice(invoice)
SaleTerms.from_invoice() reads the five stored fields from an invoice detail, each None when absent. Items.create(), upsert() and update() take net_weight, gross_weight, ibs_cbs_cst and ibs_cbs_class.
Issuing is the one call you must not repeat blindly. If the response is lost — a timeout, a dropped connection — the document may well have been authorized, and a second attempt issues a second fiscal document: another credit, another number burned, and undoing it means cancelling, which has a deadline.
Pass idempotency_key to make the retry safe:
from decimal import Decimal
key = str(uuid.uuid4())
result = invoice.issue(
document_type=DocumentType.NFSE,
client_name="Maria Silva",
tax_id="12345678909",
items=[Product(description="Consultoria", unit_price=Decimal("1500.00"))],
idempotency_key=key,
)
Retry with the same key and the same body and you get the first response back,
replayed — no second document, no credit consumed. reissue() takes the same
argument.
| Situation | What the API does |
|---|---|
| New key | issues normally, records the response |
| Same key, same body | replays the recorded response |
| Same key, different body | APIError 422 |
| Same key, first call still running | APIError 409 |
| Previous attempt failed | key is released — the retry issues |
| Key older than 24 hours | treated as new |
Generate the key yourself and keep it for as long as you might retry — a uuid4 per
business event, not per HTTP call. The SDK never generates one, because a key minted
per call would protect nothing, and because two genuinely separate invoices for the
same customer and amount on the same day are a normal thing to issue.
Some mistakes don't need a cancellation. A wrong product name, wrong transport details, a typo in the extra information — a CC-e (carta de correção) fixes those, and it is free: no new credit, no burned series number, no reissue.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.