setDataPlan
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
| Param | Type | Notes | Description |
|---|---|---|---|
credentials | FlowstackCredentials | required | The app owner's credentials (owner-scoped JWT). |
siteId | string | required | The site/app id to operate on. |
collections | Record<string, unknown> | required | Collection-name → schema map to merge into the plan. |
config | FlowstackClientConfig | since 0.2.7 | Client config (baseUrl, appScope, tenantId as needed). |
Returns
| Field | Type | Description |
|---|---|---|
| — | 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
Source: src/api/client.ts (Site Ops, P0-156) · Also available in llms-full.txt and registry.json.