Skip to main content

Function: triggerCustomerPortalFlow()

triggerCustomerPortalFlow(session, subscriptionId, action): Promise<TriggerCustomerPortalFlowResponse>

Trigger the store's active customer portal flow for a subscription.

The flow is queued, not finished: a successful result only means the job was enqueued.

Works with a customer portal session (only for that customer's own subscriptions), or with an API token that has both the read_subscriptions and write_flows scopes.

The store needs the enable_customer_portal_triggered_flows beta flag and an active customer_portal_triggered_flow with trigger subscription/unpack and limits.max_times_per_customer: -1.

Throws a RechargeRequestError with one of these statuses on failure:

  • 403: the feature is not enabled for the store, or the token is missing a scope. Not retryable.
  • 404: the subscription does not exist or does not belong to the customer.
  • 422 "Unable to trigger flows, please try again": temporary, safe to retry. Any other 422 means the action was invalid.
  • 429: this subscription was already triggered for this action in the last 24h. Treat it as already done rather than retrying.

Parameters​

ParameterType
sessionSession
subscriptionIdstring | number
action"unpack"

Returns​

Promise<TriggerCustomerPortalFlowResponse>