Docs / wallet / subscribeToApp

subscribeToApp

utilitysince 0.3.0

Client function: open Stripe Checkout for an app's monthly subscription plan (P0-162).

import { subscribeToApp } from 'flowstack-sdk'

Non-React client function. Creates a Stripe Checkout session (mode=subscription) for the builder's monthly plan and returns its URL — redirect the end-user there. POST /billing/app-access/subscribe. React apps should prefer useAppAccess().subscribe(), which does the redirect for you.

Signature

subscribeToApp(credentials, siteId, urls, config?): Promise<ApiResponse<{ url: string; site_id: string }>>

Parameters

ParamTypeNotesDescription
credentialsFlowstackCredentialsrequiredThe end-user's credentials (the subscriber, not the builder).
siteIdstringrequiredThe app to subscribe to (typically config.appScope).
urls{ success_url: string; cancel_url: string }requiredWhere Stripe Checkout redirects after success/cancel (HTTPS or localhost).
configFlowstackClientConfigClient config (baseUrl, appScope, tenantId as needed).

Returns

FieldTypeDescription
Promise<ApiResponse<{ url: string; site_id: string }>>The Checkout URL to redirect the user to.

Examples

Subscribe from a non-React context
const res = await subscribeToApp(credentials, siteId, {
  success_url: window.location.href,
  cancel_url: window.location.href,
}, { appScope: siteId });
if (res.data?.url) window.location.href = res.data.url;
Note409 already_subscribed if an active (or past_due) subscription exists; 409 ALREADY_UNLOCKED if the user owns lifetime access — a subscription would be strictly worse than what they have.

See also

cancelAppSubscription · useAppAccess · AppSubscriptionStatus · MonetizationSubscriptionConfig

Source: src/api/client.ts (App Subscriptions, P0-162) · Also available in llms-full.txt and registry.json.