Docs / built-apps / setDataPlan

setDataPlan

utilitysince 0.2.7not for built apps

Client function: merge collection schemas into the site's data plan (PUT-with-merge).

import { setDataPlan } from 'flowstack-sdk'

Non-React client function. Merges collection schemas: new names override, other existing names are preserved. PUT /api/v1/sites/{siteId}/data-plan with { collections }.

Signature

setDataPlan(credentials, siteId, collections, config?): Promise<ApiResponse<{ site_id: string; saved: string[]; mongoCollections: Record<string, unknown> }>>

Parameters

ParamTypeNotesDescription
credentialsFlowstackCredentialsrequiredThe app owner's credentials (owner-scoped JWT).
siteIdstringrequiredThe site/app id to operate on.
collectionsRecord<string, unknown>requiredCollection-name → schema map to merge into the plan.
configFlowstackClientConfigsince 0.2.7Client config (baseUrl, appScope, tenantId as needed).

Returns

FieldTypeDescription
Promise<ApiResponse<{ site_id: string; saved: string[]; mongoCollections: Record<string, unknown> }>>The saved collection names and the resulting merged mongoCollections.

Examples

Merge a collection schema
await setDataPlan(credentials, siteId, {
  tasks: { fields: { title: 'string', done: 'boolean' } },
}, { appScope });
NoteMerge semantics: a name present in collections overrides that collection; names you omit are left untouched. It never wipes the whole plan.
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

getDataPlan

Source: src/api/client.ts (Site Ops, P0-156) · Also available in llms-full.txt and registry.json.