pocketsflow package. For installation and a first request, start with the SDK quickstart.
The SDK is server-side only and is backed by the same API key used by the REST API. It is written in TypeScript and ships its type declarations with every release.
Client
PocketsflowConfig
Method index
Products
One-time products that buyers can purchase through hosted checkout.copy duplicates a one-time product or a subscription offer, whichever owns the id. Pass { testMode: false } to copy a test-mode item into live mode; omit params to copy within the source’s own mode. The copy is named “Name (Copy)” and starts unpublished when copied into live mode.
CreateProductParams
update(id, params) accepts the editable product fields: name, description, price, currency, active, and published.
Product variants
CreateVariantParams requires productId, name, and price; description is optional.
Orders
ListOrdersParams supports productId, startDate, endDate, page, and pageSize. The date filter applies only when you pass both startDate and endDate; one bound on its own is ignored. OrdersResponse contains orders and a pagination object.
Customers
The API applies
productId, sortBy, and sortOrder from ListCustomersParams. sortBy is email, country, numberOfOrders, or createdAt; sortOrder is asc or desc. The list is not paginated: it always returns every matching customer.
Reviews
list() returns every review across your products.
Discounts
CreateDiscountParams requires name, code, value, and mainProductIds. valueType is percentage or fixed; active is optional. The update type makes all fields optional.
Upsells
CreateUpsellParams requires mainProductIds, upsellProductId, and upsellPrice. Optional fields include name, offer, upsellDescription, primaryButtonText, secondaryButtonText, and active.
Subscription offers
Subscription offers are the recurring products you sell. They are distinct from buyer subscriptions in thesubscriptions namespace.
CreateSubscriptionOfferParams
frequency must be weekly, monthly, or yearly.
Buyer subscriptions
Thesubscriptions namespace manages buyer memberships. Use subscriptionOffers to manage the recurring products themselves.
ListSubscriptionsParams supports status, startDate, endDate, page, and pageSize. The current SDK list method uses the legacy subscription-customer endpoint; the canonical REST subscriber catalog is GET /subscriptions/subscribers.
Webhooks
CreateWebhookParams requires an HTTPS url and an events array. The SDK exports the WebhookEvent union for typed event names.
Users
UpdateUserParams supports firstName, lastName, currency, country, subdomain, and contactEmail.
Checkout
Create a hosted checkout session for either a one-time product or a subscription offer.CreateCheckoutParams requires productId, successUrl, and cancelUrl. Optional fields are customerEmail, discountCode, and metadata.
Refunds
The API behind
refunds manages refund policies: the terms shown to buyers at checkout, which products reference by id (refundPolicy). A policy has name, policy (the text), period, and periodType (days or weeks).
Errors
Failed requests reject withPocketsflowError:
The SDK also maps request timeouts to a
PocketsflowError with code TIMEOUT.
TypeScript types
The package exports the request and response types used by every method, includingProduct, Order, Customer, SubscriptionOffer, Webhook, CheckoutSession, Refund, and all Create*Params, Update*Params, and list parameter types. Import them as type-only imports: