Developers

Code examples & sample project

The anemone-server-js package ships TypeScript source under src/ (client, webhook, types) — use it as the source of truth for request/response types and default paths. See also the API, Optional UI, and Webhooks pages.

Minimal client example

In the demo app, partner → Anemone contact pushes live in pushContactUpdatesToPrimary (called from PUT /api/user/contact). Client construction is in getAnemoneClientOrNull.

// Server route, Node or serverless
const res = await client.saveContactInfo({
  externalUserId: session.userIdOnYourApp,
  kind: "address",
  address: { line1, city, region, postalCode, countryCode: "US" },
});
console.log(res.status, res.correlationId);

Merchant field mapping

See the API — Contact field mapping section for rename maps and custom set / get functions. The Paws and Tails demo applies inbound events in applyContactChangeFromPrimary (from POST /api/webhooks/contact-changed). You can replace hand-rolled transforms with ContactInfoMapping helpers from the SDK.

// Webhook handler — apply primary change to your user row
import { mapContactEventToMerchant } from "anemone-server-js";

const patch = mapContactEventToMerchant(event, mapping);
await db.users.update(event.externalUserId, patch);

Paws and Tails demo

The paws-and-tails-demo project (companion Next.js app) demonstrates how a business-facing experience can be wired to Anemone patterns. Open that repo next to anemone-server-js and anemone to compare a full app integration to the minimal SDK.

Key source deep links