Skip to content

Quickstart

1. Get Your API Key

Sign up at app.spaceinvoices.com. Your account includes a default entity (business). Grab your sandbox API key from Settings → API Keys.

2. Install the SDK

Installbash
npm install @space-invoices/js-sdk
# or
bun add @space-invoices/js-sdk

3. Initialize

Initialize SDKtypescript
import SpaceInvoices from "@space-invoices/js-sdk";

const sdk = new SpaceInvoices("YOUR_API_KEY");

4. Create Your First Invoice

Create invoicetypescript
const invoice = await sdk.invoices.create({
  customer: {
    name: "Acme Corporation",
    email: "billing@acme.com",
  },
  items: [
    {
      name: "Consulting",
      quantity: 10,
      price: 150,
    },
  ],
});

console.log(invoice.number); // INV-2024-0001
console.log(invoice.total_with_tax); // 1500

5. Download PDF or Send by Email

Render pdftypescript
// title: Render PDF
const pdf = await sdk.invoices.renderPdf(invoice.id);

// Save to file
fs.writeFileSync("invoice.pdf", pdf);

// Or send as response
res.setHeader("Content-Type", "application/pdf");
res.send(pdf);

Or send directly to your customer:

Send emailtypescript
// title: Send invoice
await sdk.email.send(invoice.id, {
  to: invoice.customer.email,
  subject: "Your invoice #{document_number}",
  body: "Thank you for your business!",
});

Done. You’ve created an invoice and delivered it.

Next Steps