create_workflow
Create a new workflow in your Storyblok space by specifying a name and content types it applies to.
Instructions
Creates a new workflow in a Storyblok space via the Management API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the workflow | |
| content_types | Yes | List of content types this workflow applies to |
Implementation Reference
- src/tools/workflows.ts:54-79 (handler)The create_workflow tool handler. Defines the tool with name 'create_workflow', accepts 'name' (string) and 'content_types' (string array) as input, and POSTs to '/workflows' via the Storyblok Management API.
// Tool: create_workflow server.tool( 'create_workflow', 'Creates a new workflow in a Storyblok space via the Management API.', { name: z.string().describe('Name of the workflow'), content_types: z.array(z.string()).describe('List of content types this workflow applies to'), }, async ({ name, content_types }) => { try { const payload = { workflow: { name, content_types, }, }; const data = await apiPost('/workflows', payload); return createJsonResponse(data); } catch (error) { if (error instanceof APIError) { return createErrorResponse(error); } throw error; } } - src/tools/workflows.ts:58-60 (schema)Input schema for create_workflow: requires 'name' (z.string()) and 'content_types' (z.array(z.string())).
{ name: z.string().describe('Name of the workflow'), content_types: z.array(z.string()).describe('List of content types this workflow applies to'), - src/tools/index.ts:59-61 (registration)Registration of registerWorkflows (which includes create_workflow) in the central tool aggregator.
registerWorkflows(server); registerWorkflowStages(server); registerWorkflowStageChanges(server); - src/tools/index.ts:27-29 (registration)Import of registerWorkflows from './workflows.js' in the tool aggregator.
import { registerWorkflows } from './workflows.js'; import { registerWorkflowStages } from './workflow-stage.js'; import { registerWorkflowStageChanges } from './workflow-stage-changes.js'; - src/utils/api.ts:195-206 (helper)The apiPost helper used by create_workflow to POST the workflow payload to the Storyblok Management API.
export async function apiPost<T = unknown>( path: string, body: unknown ): Promise<T> { const url = buildManagementUrl(path); const response = await fetch(url, { method: 'POST', headers: getManagementHeaders(), body: JSON.stringify(body), }); return handleResponse<T>(response, url); }