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.setAbandonedCheckout, users.entitlements,
users.updateTrackingPixels, checkout.abandonedSummary, the plans
namespace and FeatureLockedError ship in the next SDK release. Until you can
upgrade, call their endpoints directly (listed in each section below).
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.
setAbandonedCheckout
Turns the recovery email for buyers who leave this product’s checkout on or off. Turning it on needs the Growth plan and otherwise throws
FeatureLockedError; turning it off always works. Product.abandonedCheckoutEnabled reads the current value (off unless turned on; when on, the checkout also asks the buyer for an email).
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.
Since SDK 3.5.0, status filters like the dashboard’s Orders page (paid, refunded, disputed or failed for declined payments, one value or an array) and search matches the buyer’s email. Every order carries its status (OrderStatus). paymentDetails(id) (GET /orders/{id}/payment-details) returns the payment’s totals, tax, refunds and itemised fees; journey(id) (GET /orders/{id}/journey) returns the checkout timeline and the card attempts on it.
platformFee is the platform fee locked at checkout (in the order currency) and platformFeeRate the rate it was charged at: 0.02, 0.01 on the Volume plan, 0.005 on Volume Max (null on legacy sales with no platform line). Use them to reconcile sales after a plan change; a later plan change never rewrites an order.
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.
updateSellingProfile records what the creator sells (sellingPath: digital, membership, software, services or other) and where buyers pay (sellingSetup: pages or code), the answers users.me() returns; null clears one (SDK 3.4.0). users.entitlements() is the same call as plans.entitlements(). updateTrackingPixels sets or removes the ad-platform ids on your buyer pages (facebookPixel, googlePixel, googleTagManager, tiktokPixel, pinterestTag, snapchatPixel, twitterPixel, twitterPurchaseEventId, linkedinPartnerId, linkedinConversionId, redditPixel, microsoftUetTag); "" or null removes one. Adding or changing a pixel needs the Starter plan and otherwise throws FeatureLockedError.
Plans
plans.list() calls a public endpoint (the API does not need the key for it) and returns every self-serve plan: plan, name, pricePerMonth, pricePerYear, feeRate, seats, subscriber and email caps, maxUploadMb and features (the feature keys it includes). Plans are bought in the dashboard only. See Plans and limits.
Checkout
Create a hosted checkout session for either a one-time product or a subscription offer.CreateCheckoutParams type requires productId, successUrl, and cancelUrl (the HTTP API itself only requires productId). Optional fields are customerEmail, discountCode, and metadata.
abandonedSummary
Live checkouts lost over the last 30 days (the buyer typed their details and never paid), once per buyer and product.
amountUsd sums the USD checkouts only. Readable on every plan.
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).
Payouts
Read only, since SDK 3.5.0: withdrawing money stays in the dashboard.status() (GET /payouts/status) says whether payouts are on (payoutsEnabled) and, if not, why (state: not_connected, setup_required, identity_verification_required, information_requested, in_review or on_hold), with a message and the dashboard page to act on (actionUrl). balance() calls GET /payouts/balances. list({ status?, limit? }) (GET /payouts, limit 1-50, default 20) returns { data, hasMore }, newest first; each Payout has status (requested, awaiting_payment, in_transit, completed, failed, canceled or denied), amount, feeAmount, netAmount, currency, estimatedArrival and, when it did not go through, failureMessage. The payout.created and payout.updated webhook events carry the same Payout.
Penny
Pocketsflow Penny 1, the decision model. Since SDK 3.6.0. API keys only.decide calls POST /v1/penny/decide; usage calls GET /v1/penny/usage.
PennyDecideParams
PennyDecision
model ("pocketsflow-penny-1"), type, confidence (0-1), probs (one per answer), auto (safe to act without a person) and usage (free_remaining, credits_remaining). Plus the answer for the type: choice and index (choice), yes (yes_no) or score (score, 1-5).
PennyUsage has free_limit, free_used, free_remaining, credits_remaining (null when unreadable) and buy_url (null when credits are not on sale).
When the month’s free decisions and your credits are used up, decide rejects with a PocketsflowError with status 402; error.body.error is penny_credits_exhausted and error.body.buy_url links to more credits.
Errors
Failed requests reject withPocketsflowError:
The SDK also maps request timeouts to a
PocketsflowError with code TIMEOUT.
FeatureLockedError
A 403 with code FEATURE_LOCKED rejects with FeatureLockedError, a subclass of PocketsflowError: the call would turn on a feature the account’s plan does not include. Nothing was saved and retrying fails the same way.
TypeScript types
The package exports the request and response types used by every method, includingProduct, Order, Customer, SubscriptionOffer, Webhook, CheckoutSession, Refund, Entitlements, Plan, PlanId, FeatureKey, and all Create*Params, Update*Params, and list parameter types. Import them as type-only imports: