Skip to main content
The official TypeScript SDK, @commenda-integrations/api, is generated from the V4 OpenAPI spec, so every path param, query filter, request body, and response is fully typed.

Installation

npm i @commenda-integrations/api
Import the client:
import { CommendaIntegrations } from "@commenda-integrations/api";

Instantiate the client

Instantiate with your API key (generate keys in the Commenda Dashboard). It targets production by default; pass baseUrl to point elsewhere for local development.
const commenda = new CommendaIntegrations({ apiKey: process.env.COMMENDA_API_KEY! });
Resources are namespaced: commenda.core.* for platform & management endpoints, and commenda.dataModels.* for the unified data models.

Run your first request

Core API

// Create an invite link a customer uses to connect their integration
const { data: inviteLink } = await commenda.core.inviteLinks.create({
  integration: "NETSUITE",
  companyName: "Test Company",
});

// List the organisation's companies
const { data: companies } = await commenda.core.companies.list();

Unified API

// List a company's invoices, filtered
const { data: invoices } = await commenda.dataModels.invoices.list(companyId, {
  "status[eq]": "PAID",
  "posted_date[gte]": "2024-01-01",
  limit: 50,
});

// Get one record
const { data: invoice } = await commenda.dataModels.invoices.get(companyId, invoiceId);

// Create (proxied to the connected platform)
await commenda.dataModels.invoices.create(companyId, { data: { /* fields */ } });
Iterate every page with the paginate helper:
import { paginate } from "@commenda-integrations/api";

for await (const invoice of paginate(next => commenda.dataModels.invoices.list(companyId, { limit: 100, next }))) {
  // ...
}

Error handling

Non-2xx responses throw a CommendaApiError:
import { CommendaApiError } from "@commenda-integrations/api";

try {
  await commenda.dataModels.invoices.get(companyId, invoiceId);
} catch (err) {
  if (err instanceof CommendaApiError) {
    console.error(err.statusCode, err.message, err.errorCode, err.requestId);
  }
}