The SDK provides methods for all Space Invoices API endpoints, organized by resource.
Method Description invoices.list(options?)List invoices with filtering, pagination, and entity context invoices.get(id, params?, options?)Get invoice by ID invoices.create(body, options?)Create an invoice invoices.update(id, body, options?)Update an invoice invoices.void(id, body?, options?)Void an issued invoice invoices.renderPdf(id, params?, options?)Render an invoice as PDF documents.finalizeDocument(id, body?, options?)Finalize a draft document documents.delete(id, params?, options?)Move a draft document to trash email.sendEmail(body, options?)Send a document by email
const _invoices = await sdk.invoices.list ({
entity_id: "ent_123" ,
limit: 20 ,
});
const _invoice = await sdk.invoices.get ("inv_123" , undefined , { entity_id: "ent_123" });
const _newInvoice = await sdk.invoices.create ({
date: "2024-01-15" ,
items: [{ name: "Service" , price: 100 }],
}, { entity_id: "ent_123" });
await sdk.invoices.update ("inv_123" , { date_due: "2024-02-15" }, { entity_id: "ent_123" });
await sdk.documents.delete ("inv_123" , undefined , { entity_id: "ent_123" });
Method Description customers.list(options?)List customers customers.get(id, options?)Get customer by ID customers.create(body, options?)Create customer customers.update(id, body, options?)Update customer customers.delete(id, options?)Move customer to trash
const _customers = await sdk.customers.list ({
entity_id: "ent_123" ,
});
const _customer = await sdk.customers.get ("cus_123" , { entity_id: "ent_123" });
const _newCustomer = await sdk.customers.create ({
name: "Acme Corp" ,
email: "billing@acme.com" ,
address: "123 Business St" ,
city: "New York" ,
country: "United States" ,
}, { entity_id: "ent_123" });
await sdk.customers.update ("cus_123" , { email: "new-email@acme.com" }, { entity_id: "ent_123" });
Method Description items.list(options?)List items/products items.create(body, options?)Create item items.update(id, body, options?)Update item items.delete(id, options?)Move item to trash
const _items = await sdk.items.list ({
entity_id: "ent_123" ,
});
const _item = await sdk.items.create ({
name: "Consulting Hour" ,
unit: "hour" ,
price: 150 ,
tax_ids: ["tax_123" ],
}, { entity_id: "ent_123" });
await sdk.items.update ("item_123" , { price: 175 }, { entity_id: "ent_123" });
Method Description businessUnits.list(params?)List business units businessUnits.get(id, params?)Get business unit by ID businessUnits.create(body)Create business unit businessUnits.update(id, body)Update business unit businessUnits.delete(id)Archive business unit
Method Description financialCategories.list(params?)List financial categories financialCategories.create(body)Create financial category financialCategories.update(id, body)Update financial category financialCategories.delete(id)Archive financial category financialCategories.getRevenueByFinancialCategory(params)Get revenue summary grouped by category financialCategories.updateDocumentItemFinancialCategory(id, body)Update a saved document line category financialCategories.updateDocumentItemFinancialCategories(body)Batch update saved document line categories
Method Description exports.exportDocuments(params)Export documents to CSV or XLSX exports.exportSalesPerItem(params)Export sales per item for a period exports.exportRevenueByCategory(params)Export accrued revenue by category for a period exports.startPdfExport(body)Start async bulk PDF export exports.downloadPdfExport(jobId)Download completed PDF export archive exports.startEslogExport(body)Start async bulk e-SLOG export exports.downloadEslogExport(jobId)Download completed e-SLOG export archive ujp.download(id)Download a UJP provider/B2B ZIP package for a supported Slovenian invoice or credit note
Method Description payments.list(options?)List payments payments.get(id, options?)Get payment by ID payments.create(body, options?)Record payment; use document_id in the body payments.delete(id, options?)Move payment to trash
const _payments = await sdk.payments.list ({
query: JSON.stringify ({ invoice_id: "inv_123" }),
entity_id: "ent_123" ,
});
const _payment = await sdk.payments.create ({
document_id: "inv_123" ,
amount: 500 ,
date: "2024-01-20" ,
type : "bank_transfer" ,
}, { entity_id: "ent_123" });
await sdk.payments.delete ("pay_123" , { entity_id: "ent_123" });
Method Description entities.list(options?)List entities entities.get(id, options?)Get entity by ID entities.create(body, options?)Create entity entities.update(id, body, options?)Update entity
const _entities = await sdk.entities.list ();
const _entity = await sdk.entities.get ("ent_123" );
const _newEntity = await sdk.entities.create ({
name: "New Business" ,
email: "contact@business.com" ,
country: "United States" ,
country_code: "US" ,
});
await sdk.entities.update ("ent_123" , { name: "Updated Business Name" });
Method Description taxes.list(options?)List tax rates taxes.create(body, options?)Create tax rate taxes.update(id, body, options?)Update tax rate taxes.delete(id, options?)Move tax rate to trash
The SDK also supports:
estimates — Estimates and proforma invoices
creditNotes — Credit notes
advanceInvoices — Advance invoices
recurringInvoices — Recurring invoices
Resource-specific create, list, get, update, and void methods live on those namespaces. Shared lifecycle operations such as finalize, delete, restore, share, and send live on sdk.documents.
Account keys and entity keys
Entity keys already carry their entity scope. With an account key, pass { entity_id: "ent_..." } in the SDK options argument (or in the combined options object for list methods).
All list methods support cursor-based pagination:
const page1 = await sdk.invoices.list ({
entity_id: "ent_123" ,
limit: 20 ,
});
if (page1.pagination.next_cursor ) {
const _page2 = await sdk.invoices.list ({
entity_id: "ent_123" ,
limit: 20 ,
next_cursor: page1.pagination.next_cursor ,
});
}
Filter results using query parameters:
const _invoices = await sdk.invoices.list ({
entity_id: "ent_123" ,
query: JSON.stringify ({ date: { between: ["2024-01-01" , "2024-01-31" ] } }),
});
const _unpaid = await sdk.invoices.list ({
entity_id: "ent_123" ,
query: JSON.stringify ({ paid_in_full: false }),
});
const _customers = await sdk.customers.list ({
entity_id: "ent_123" ,
search: "acme" ,
});
The SDK throws errors for failed requests:
try {
const _invoice = await sdk.invoices.get ("invalid_id" );
} catch (error) {
if (error.status === 404 ) {
} else if (error.status === 401 ) {
} else {
}
}