npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@walnut-insurance/partner-api

v1.0.2

Published

TypeScript SDK for the Walnut Partner API - create referrals, manage customers, and integrate with Walnut insurance products

Readme

Walnut Partner API – TypeScript SDK

TypeScript/JavaScript SDK for the Walnut Partner API. Use it to create referrals, manage customers, and integrate Walnut insurance products (card, digital protection, group tenant, home warranty, creditor, cobrand, headless) from your own backend or scripts.

Install

npm install @walnut-insurance/partner-api

Authentication

The Partner API uses API keys. Pass your key when creating the client. Do not commit API keys to source control; use environment variables or a secrets manager.

  • Get your API key from Walnut.
  • Use header x-api-key (the SDK sets this automatically from your config).

Quick start

import { WalnutPartnerApi } from '@walnut-insurance/partner-api';

const api = new WalnutPartnerApi({
  apiKey: process.env.WALNUT_API_KEY!,
  environment: 'production', // or 'staging' for test
});

// Create a customer
const { id } = await api.customers.create({
  firstName: 'Jane',
  lastName: 'Doe',
  email: '[email protected]',
});

// Create a home referral (returns checkout URL for the customer)
const ref = await api.referrals.createHomeReferral({
  email: '[email protected]',
  address: { streetNum: '123', streetName: 'Main St', city: 'Toronto', province: 'ON', postalCode: 'M5V 1A1' },
  owners: [{ firstName: 'Joe', lastName: 'Smith', currentAddress: { ... } }],
  coverageStart: '2025-03-01',
});
console.log(ref.checkoutUrl); // redirect user here

Environment / Base URL

Configure the environment to pick the base URL, or pass a custom baseUrl:

| Environment | Base URL | |---------------|-----------------------------------| | production | https://partner.api.gowalnut.com (default) | | staging | https://partner.api.gowalnut.xyz |

// Use staging (test) environment
const api = new WalnutPartnerApi({
  apiKey: process.env.WALNUT_API_KEY!,
  environment: 'staging',
});

// Production is the default; you can set it explicitly
const prodApi = new WalnutPartnerApi({
  apiKey: process.env.WALNUT_API_KEY!,
  environment: 'production',
});

// Or override with a custom base URL (e.g. for a proxy or local dev)
const customApi = new WalnutPartnerApi({
  apiKey: process.env.WALNUT_API_KEY!,
  baseUrl: 'https://partner.api.gowalnut.xyz',
});

Constants PRODUCTION_BASE_URL and STAGING_BASE_URL are exported if you need the URLs elsewhere.

API overview

| Area | Description | |------|-------------| | Customers | Create, get, update, delete customers; list memberships | | Card | Card insurance memberships and claims under a customer | | Digital | Digital protection memberships under a customer | | Group tenant | Quotes, users, coverages, certificates (e.g. income protection group) | | Referrals | Home, travel, tenant, group-tenant, bill payment protection, PNC referrals; get user coverage | | Cobrand / Headless | Proxy APIs for cobrand and headless integrations | | Creditor | Bill payment protection and other creditor endpoints (proxy) | | Home warranty | Create user, add/update coverage (proxy) |

Customers

await api.customers.create({ firstName, lastName, email, phone?, address?, ... });
await api.customers.get(customerId);
await api.customers.getMemberships(customerId);
await api.customers.update(customerId, { firstName, ... });
await api.customers.delete(customerId);

Card insurance (per customer)

const cardApi = api.card(customerId);
await cardApi.createMembership(body);
await cardApi.listMemberships();
await cardApi.getMembership(membershipId);
await cardApi.updateMembership(membershipId, body);
await cardApi.deleteMembership(membershipId);
await cardApi.createClaim(membershipId, body);
await cardApi.addClaimAttachment(membershipId, claimId, body);
await cardApi.getClaimAttachmentUrl(membershipId, claimId, attachmentId);

Digital protection (per customer)

const digitalApi = api.digital(customerId);
await digitalApi.createMembership(body);
await digitalApi.listMemberships();
await digitalApi.getMembership(membershipId);
await digitalApi.deleteMembership(membershipId);

Group tenant

await api.groupTenant.getQuote({ address: { ... } }); // or leadId + groupTenantLeadId
await api.groupTenant.createUser(body);
await api.groupTenant.getUser(userId);
await api.groupTenant.addCoverage(userId, body);
await api.groupTenant.updateUser(userId, body);
await api.groupTenant.deleteUser(userId);
await api.groupTenant.updatePolicyCoverage(userId, policyId, body);
await api.groupTenant.getPolicyCertificate(userId, policyId);
await api.groupTenant.deletePolicyCoverage(userId, policyId);
await api.groupTenant.getUserCertificate(userId);

Referrals

await api.referrals.createHomeReferral(body);
await api.referrals.createTravelReferral(body);
await api.referrals.createTenantReferral(body);
await api.referrals.createGroupTenantReferral(body);
await api.referrals.createBillPaymentProtectionReferral(body);
await api.referrals.createPncReferral(body);
await api.referrals.getPncReferral(id);
await api.referrals.getUserCoverage(userId);

Cobrand / Headless / Creditor / Home warranty

For proxy-style APIs you can use the typed helpers or a generic request:

await api.cobrand.createUser(body);
await api.cobrand.request('GET', '/some/path');

await api.headless.createUser(body);
await api.headless.request('POST', '/path', body);

await api.creditor.request('POST', '/bill-payment/...', body);

await api.homeWarranty.createUser(body);
await api.homeWarranty.addCoverage(userId, body);
await api.homeWarranty.updateCoverage(userId, policyId, body);
await api.homeWarranty.request('GET', '/path');

Error handling

Failed requests throw PartnerApiError with message, status, and optional body:

import { WalnutPartnerApi, PartnerApiError } from '@walnut-insurance/partner-api';

try {
  await api.customers.get(invalidId);
} catch (err) {
  if (err instanceof PartnerApiError) {
    console.error(err.status, err.body);
  }
  throw err;
}

Types

The package exports TypeScript types for requests and responses (e.g. CustomerBase, CreateReferralResponse, Address). Use them for type-safe payloads and responses.

License

MIT