Skip to main content
This page is the method reference for the official 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.
ListCustomersParams also types email, limit, and offset, but the API ignores them today. Filter or page the returned array in your own code.

Reviews

list() returns every review across your products.
ListReviewsParams types an optional productId, but GET /reviews ignores it and returns every review. Filter by productId on the returned array.

Discounts

CreateDiscountParams requires name, code, value, and mainProductIds. valueType is percentage or fixed; active is optional. The update type makes all fields optional.
The SDK types also accept expiration, but the API does not store it on create or update, so the discount stays valid until you deactivate or delete it. Set active: false when a promotion ends.

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 the subscriptions namespace.

CreateSubscriptionOfferParams

frequency must be weekly, monthly, or yearly.

Buyer subscriptions

The subscriptions namespace manages buyer memberships. Use subscriptionOffers to manage the recurring products themselves.
cancel and refund call legacy routes keyed by a Stripe subscription id (sub_…). Current subscriptions don’t carry one, so these calls return 404. To cancel (at period end), pause, or resume a subscriber, call POST /subscriptions/{id}/cancel (or /pause, /resume) with the subscriber _id or membership id (mem_…). Issue refunds from the dashboard.
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.
The current SDK webhooks.update implementation uses PUT, while the public REST endpoint is PATCH /webhooks/{id}. Use the REST endpoint for updates until the SDK method is aligned in a follow-up release.

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).
The SDK’s Refund / CreateRefundParams types describe order refunds (orderId, amount, reason). The API does not process them: those fields are dropped and no payment is refunded. Refund a payment from the dashboard. Use list() and get(id) to read your refund policies.

Errors

Failed requests reject with PocketsflowError:
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, including Product, Order, Customer, SubscriptionOffer, Webhook, CheckoutSession, Refund, and all Create*Params, Update*Params, and list parameter types. Import them as type-only imports:
For the corresponding HTTP operation, request body, response codes, and full schema, see the REST endpoint reference or open the interactive API explorer.