Docs / wallet / setMonetization

setMonetization

utilitysince 0.2.6not for built apps

Client function: set a site's monetization (paywall) configuration.

import { setMonetization } from 'flowstack-sdk'

Non-React client function. Writes the paywall/pricing config for an app (Stripe and/or AGENT payment). POST /billing/app-access/monetization/{siteId}. 0.3.0 (P0-162): the stripe.subscription block configures a monthly plan; requires Connect payouts enabled (400 SUBSCRIPTION_REQUIRES_CONNECT otherwise — a hard error, unlike the soft warnings[]).

Signature

setMonetization(credentials, siteId, monetization, config?): Promise<ApiResponse<{ site_id: string; monetization: Monetization; warnings?: string[] }>>

Parameters

ParamTypeNotesDescription
credentialsFlowstackCredentialsrequiredThe app owner's credentials (owner-scoped JWT).
siteIdstringrequiredThe site/app id to operate on.
monetizationMonetizationrequiredThe paywall config to save (enabled, payment_mode, stripe/agent, revenue_share_bps).
configFlowstackClientConfigsince 0.2.6Client config (baseUrl, appScope, tenantId as needed).

Returns

FieldTypeDescription
Promise<ApiResponse<{ site_id: string; monetization: Monetization; warnings?: string[] }>>The saved config. warnings (0.2.9+) lists non-blocking config issues — e.g. a payment mode enabled without its rail fully set up. Surface them to the builder.

Examples

Enable an AGENT-token paywall
await setMonetization(credentials, siteId, {
  enabled: true,
  payment_mode: 'agent',
}, { appScope });
WarningOwner/management operation — call it with the app owner's credentials from a builder/dashboard/server context, not from inside the generated app's end-user runtime. builtAppSafe is false.

See also

getMonetization · Monetization · getBuilderEarnings · getConnectStatus · MonetizationSubscriptionConfig

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