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
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
const _invoices = await sdk.invoices.list({
entity_id: "ent_123",
limit: 10,
});4. Create an Invoice
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
const _pdf = await sdk.invoices.renderPdf(invoice.id);
// pdf is a Blob - save or send itTree-Shakeable Imports
For smaller bundle sizes, import individual modules:
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
- Quickstart — the full account -> entity -> key -> invoice flow
- Authentication — key types and environments
- Configuration — Advanced configuration options
- API Methods — All available methods
- Zod Schemas — Form validation with Zod