@getmandato/sdk
v0.1.0
Published
Official Node.js SDK for the Mandato EU e-invoicing API
Downloads
84
Maintainers
Readme
@getmandato/sdk
Official Node.js SDK for the Mandato EU e-invoicing API.
Installation
npm install @getmandato/sdkQuick Start
import { MandatoClient } from "@getmandato/sdk";
const mandato = new MandatoClient({
apiKey: "sk_live_...",
});
// Create and submit an invoice
const invoice = await mandato.invoices.create({
country: "RO",
supplier: {
vatNumber: "RO12345678",
name: "Acme SRL",
address: { street: "Str. Exemplu 1", city: "Bucharest", postalCode: "010101", country: "RO" },
},
customer: {
vatNumber: "RO87654321",
name: "Client SRL",
},
lines: [
{ description: "Software license", quantity: 1, unitPrice: 500, vatRate: 19 },
],
});
console.log(invoice.id); // "inv_abc123"
console.log(invoice.status); // "submitted"
// Check status
const status = await mandato.invoices.get(invoice.id);
console.log(status.status); // "accepted"
console.log(status.govId); // ANAF index numberFeatures
- Full TypeScript support with detailed types
- Automatic retries on 429 and 5xx errors
- Idempotency key generation
- Webhook signature verification
- Test and live environment support
Webhook Verification
import { verifyWebhookSignature } from "@getmandato/sdk";
app.post("/webhooks/mandato", (req) => {
const isValid = verifyWebhookSignature(
JSON.stringify(req.body),
req.headers["x-mandato-signature"],
process.env.WEBHOOK_SECRET,
);
if (!isValid) {
return res.status(401).send("Invalid signature");
}
// Handle the event
});Documentation
Full API documentation is available at getmandato.dev/docs.
License
MIT
