Skip to content

// Developers

Examples

Working @appneurox/sdk examples: tenant setup, invoices, access checks, file uploads, pagination and revision conflicts.

At a glance
  • SDK examples
  • Real v1 operations
  • Copyable code

Create a client

One client reaches every module. origin defaults to https://api.appneurox.com; pass http://localhost:8787 for a local Worker.

server.ts
import { AppNeuroX, staticCredentials } from "@appneurox/sdk";

// Server-side only: a Worker, route handler or Node service.
const app = new AppNeuroX({
  credentials: staticCredentials(env.PLATFORM_ACCESS_TOKEN, env.PLATFORM_TENANT_ID),
});

List and create invoices

Reads take a query; writes take a JSON body. Responses are untyped unless you pass a type.

server.ts
const page = await app.invoice.invoices.list({ limit: 50 });

const invoice = await app.invoice.invoices.create({
  billingSnapshotId: order.id,
  groupingKey: "default",
  invoiceType: "PROFORMA",
});

Update with a revision and handle conflicts

Read the revision from the response metadata, send it with the update, and re-read on conflict.

server.ts
import { isPlatformError } from "@appneurox/sdk";

let revision: string | null = null;
const project = await app.project.projects.get(id, undefined, {
  onResponse: (meta) => (revision = meta.revision),
});

try {
  await app.project.projects.update(id, { name: "Renamed" }, { revision: revision! });
} catch (error) {
  if (isPlatformError(error, "REVISION_CONFLICT")) {
    // re-read, merge, try again
  }
  throw error;
}

Upload and download a file

objects.create computes the X-Content-SHA256 header for byte, Blob and string bodies.

server.ts
await app.storage.objects.create(bytes, {
  contentType: "application/pdf",
  objectName: "invoice.pdf",
});

const file: Response = await app.storage.objects.get(objectId);

Check access before an action

Module-level actions sit on the module itself, for example access.check, tax.calculate and featureflag.evaluate.

server.ts
const decision = await app.access.check({ /* principal, action, resource, … */ });

Ready to start?

Build on shared modules instead of rebuilding them.

Start with the quickstart, or tell us about your product and we will map it to platform modules.