Skip to content

Quick Start

1. Create Your Entity And Generate The Right Key

Sign up at app.spaceinvoices.com, create your first entity, then generate the API key that matches your setup from Settings → API Keys.

  • use an account key if your backend manages multiple entities
  • use an entity key if you want one isolated business context only

If you are unsure, start with the main Quickstart and Authentication guides first.

2. Initialize the SDK

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

const _sdk = new SpaceInvoices({
  accessToken: "YOUR_API_KEY",
  accountId: "acc_123", // Optional for multi-account user-token flows
});

If you use an account key, include the target entity context on requests that operate on entity data.

3. List Invoices

List Invoicestypescript
const _invoices = await sdk.invoices.list({
  entity_id: "ent_123",
  limit: 10,
});

4. Create an Invoice

Create Invoicetypescript
const _invoice = await sdk.invoices.create({
  date: "2024-01-15",
  date_due: "2024-01-30",
  customer: {
    name: "Acme Corp",
    email: "billing@acme.com",
  },
  items: [
    {
      name: "Consulting Services",
      quantity: 10,
      unit: "hours",
      price: 150,
    },
  ],
});

SDK request and response fields intentionally match the REST contract exactly and use snake_case. Per-call transport options follow the same convention: use entity_id, account_id, and request_id.

Migrating to v4

Version 4 removes the deprecated v2/v3 compatibility aliases and the old generated client declarations. Import canonical generated types such as CreateInvoice, CreateCustomerBody, and InvoiceList directly from @spaceinvoices/js-sdk. Runtime methods and payloads use the API’s snake_case field names without a camelCase translation layer.

Upload and file metadata responses use canonical secure_url and public_id fields. The former secureUrl and publicId names remain available as deprecated runtime and type aliases for API compatibility; migrate new SDK code to the snake_case names.

5. Download as PDF

Render PDFtypescript
const _pdf = await sdk.invoices.renderPdf(invoice.id);

// pdf is a Blob - save or send it

Tree-Shakeable Imports

For smaller bundle sizes, import individual modules:

Tree-Shakeable Importtypescript
import { customers, initSDK, invoices } from "@spaceinvoices/js-sdk";

// Initialize once at startup
initSDK({ accessToken: "YOUR_API_KEY" });

// Use individual modules
const _result = await invoices.list({ entity_id: "ent_123" });
const _customer = await customers.get("cust_123");

Next Steps