@nemphi/sdk
Typed TypeScript client for the Nemphi API. Zero runtime
dependencies. It uses the platform fetch. Business tool invocations use the
same tenant scoping, policy, idempotency, and action ledger as the product UI.
Install
npm install @nemphi/sdk
# or: pnpm add @nemphi/sdk / yarn add @nemphi/sdk
Requires Node 20+ (or any runtime with global fetch).
Quick start
import { createClient } from "@nemphi/sdk";
const nemphi = createClient({
baseUrl: "https://api.nemphi.com",
// API key (nk_…) is tenant-bound. Session tokens (nse_…) also need tenantId.
token: process.env.NEMPHI_API_KEY!,
});
const { invoice, journal_entry } = await nemphi.postInvoice(invoiceId, {
idempotencyKey: `post-${invoiceId}`,
});
console.log(invoice.status, journal_entry.entry_number);
Configuration
| Option | Description |
|---|---|
baseUrl | API origin, e.g. https://api.nemphi.com |
token | Bearer credential: API key (nk_…) or session token (nse_…) |
tenantId | Required for tenant-scoped calls when using a user session |
headers | Extra headers on every request |
fetch | Custom fetch (defaults to the global) |
Auth
- API keys are created in the workspace settings and are already bound to one
tenant — pass them as
token, notenantIdneeded. - User sessions need both
tokenandtenantId(X-Tenant-Id).
const session = createClient({
baseUrl: "https://api.nemphi.com",
token: sessionToken,
tenantId: workspaceId,
});
Errors
import { ApiError } from "@nemphi/sdk";
try {
await nemphi.postInvoice(id);
} catch (err) {
if (err instanceof ApiError) {
// status, code (e.g. "approval_required"), message, body
console.error(err.status, err.code, err.message);
}
throw err;
}
What it covers
The client mirrors the HTTP surface used by the Nemphi web app: auth, workspaces,
tools (invoke / typed helpers), actions, runs, dashboards, mail, CRM, and more.
Types live next to the client in the same module.
For the design contract, see docs/backbone.md in the monorepo (§3 pillars, §9
API contracts).
Maintainer workflow
The web and mobile apps use workspace:*. Rebuild their SDK with
pnpm build:sdk after source changes. Merging an SDK change to master
publishes it to npm; PUBLISHING.md covers versioning, package
checks, and releases.
The private @nemphi/admin-sdk owns /v1/admin/*; those methods do not belong
in this public package.