For the complete documentation index, see llms.txt. This page is also available as Markdown.

Getting Started

You can install the package using your favorite package manager.

npm install @firmhouse/firmhouse-sdk
# or
yarn add @firmhouse/firmhouse-sdk

To get started, you need to create a new instance of the FirmhouseClient and provide it with an API token.

import { FirmhouseClient } from '@firmhouse/firmhouse-sdk';

const client = new FirmhouseClient({
  apiToken: "<your-api-token>"
});

You can use both Storefront and Write access tokens to interact with the Firmhouse API. Depending on the access type, you can perform different operations. If you try to perform an operation that is not allowed by the access type, you will receive an error.

Storefront Access

This access type is used for Storefront operations such as fetching products, creating carts, adding products to carts etc.

import { FirmhouseClient } from '@firmhouse/firmhouse-sdk';

const client = new FirmhouseClient({
 apiToken: "<storefront-access-token>",
});

const { results } = await client.products.fetchAll();
const cart = await client.carts.create();
const { orderedProduct, subscription } = await client.carts.addProduct(cart.token, { productId: results[0].id, quantity: 1 });

Available Resources

Write Access

This access type has access to all resources and operations available in the Firmhouse API.

Available Resources

All resources available with Storefront access are also available with Write access.

Common Actions

The following examples assume that you have created client with a Storefront access token and writeAccessClient with a Write access token as shown above.

Fetch Products and Plans

Create a Cart and Add a Product

Apply a Discount Code and Calculate Cart Totals

calculateCartTotals uses the largest active promotion when multiple promotions are present; promotions do not stack. Discounts are capped at the subtotal, and shipping is not included.

Fetch Project Details and Invoices

Retrieve a Subscription Through Self-Service Login

First, send the subscriber a Self Service Center login link:

When the subscriber follows the link, exchange its login token for the subscription:

Use Subscription and Extra-Field Helpers

Last updated

Was this helpful?