Create or ensure a draft App for a workspace (v1)
Idempotent per workspace. Ensures a draft App exists for the caller’s workspace: creates a new draft on first call (returns the new draft) or returns the existing draft on re-entry (with any supplied app-field overrides applied as a PATCH). Always returns 200 with the resulting draft App. Status code is the same on first call and subsequent calls — clients distinguish create-vs-existing by tracking whether they previously held this draft’s id, not by the response status.
Authorizations
Body
Request body for POST /apps/drafts. Idempotent per workspace.
On first call (no draft linked to this workspace yet), creates a new draft App with isDraft=true, vanityUrlNamespace=AppDrafts, entryPoint=null, authorId=caller, and projectId resolved from the workspace; missing app fields use defaults (name=Draft App, visibility=GRANT_BASED, etc.). The new draft's id is then linked to the workspace.
On re-entry (workspace already has a draft), returns the existing draft with any supplied DraftAppFields applied as a PATCH; missing fields leave the existing draft untouched. If the workspace's draft pointer references an App that was deleted out-of-band, the pointer is self-healed: a fresh draft is created and re-linked.
Optional initialVersion sub-flow: when initialVersion is supplied, a createAndStart is performed against the resulting draft after the draft itself has been ensured. The new version inherits draft defaulting (omitted content reference fields default to the previous running version when one exists), bundleId is forced empty on the draft App's version, and an instance is initiated. The response then carries the version (and instance, when start initiation succeeds) alongside the draft App.
The workspace this draft is scoped to. Required. Must be visible to the caller; unknown or hidden workspaces return 404.
Optional draft App field overrides. On create, missing fields use defaults. On re-entry, supplied fields PATCH the existing draft; missing fields leave the existing values untouched.
Optional initial-version createAndStart payload. When present, a createAndStart is performed against the draft after the draft is ensured. entryScript is required when initialVersion is supplied (drafts always require entryScript on the version since entryPoint is null on the App).
Optional id of an existing App the client plans to publish into. Not persisted. Currently advisory; the backend ignores it during draft creation.
Response
Success
Response body for POST /apps/drafts. The draft App is always present; version and instance are populated only when an initialVersion was supplied. If the initial-version start initiation fails, the version is still returned alongside a warnings array describing the failure.