> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Workflow

> Create an inactive draft workflow in your workspace

Creates an inactive unpublished draft owned by the API key user. Creating a workflow does not publish it or start schedules and webhooks.

## Base URL

```
https://api.langdock.com/workflows/v1/create
```

<Warning>
  **Dedicated deployments**

  Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.
</Warning>

## Required scopes

This endpoint requires the `WORKFLOW_WRITE_API` scope (**Workflow Write API**). The key user also needs the `createWorkflows` permission.

<Info>
  `shareWith` requires the `shareWorkflows` permission. An unknown or unshareable target fails the request with `404` and the workflow is not created.
</Info>

## Parameters

| Parameter            | Type   | Required | Description                                                                                                                                                                                                                                                                                    |
| -------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`               | string | Yes      | Workflow name. Maximum: 60 characters.                                                                                                                                                                                                                                                         |
| `description`        | string | No       | Workflow description. Maximum: 500 characters.                                                                                                                                                                                                                                                 |
| `timezone`           | string | No       | Valid IANA timezone, for example `Europe/Berlin`.                                                                                                                                                                                                                                              |
| `initialTriggerKind` | string | No       | Starter trigger: `manual`, `webhook`, `scheduled`, `form`, `integration`, or `meeting_end` (**Meeting End**). Do not send this together with `nodes` and `edges`. `meeting_end` requires Meetings for the key user. Otherwise the request returns `403` with `MEETINGS_FEATURE_FLAG_DISABLED`. |
| `nodes`              | array  | No       | Draft nodes. Must be sent together with `edges`.                                                                                                                                                                                                                                               |
| `edges`              | array  | No       | Draft edges. Must be sent together with `nodes`.                                                                                                                                                                                                                                               |
| `shareWith`          | object | No       | Users and groups to share with. `userIds` and `groupIds` are UUID arrays (maximum 100 each). `role` is `user` (viewer) or `editor` (default `editor`).                                                                                                                                         |
| `limits`             | object | No       | Execution caps. `monthlyCostUsd` is 1 to 10000. `perRunCostUsd` is 1 to 100. `maxExecutionsPerHour` is 1 to 5000. Send `null` on a field to clear it. Omitted fields use builder defaults: $25 monthly (or the workspace default), $2 per run, and 100 executions per hour.                    |

The graph uses the same node and edge schema as the workflow builder. Templates cannot be created through this API.

## Example

```javascript theme={null}
const axios = require("axios");

async function createWorkflow() {
  const response = await axios.post(
    "https://api.langdock.com/workflows/v1/create",
    {
      name: "Sync content",
      description: "Synchronizes content",
      timezone: "Europe/Berlin",
      initialTriggerKind: "manual",
      shareWith: {
        userIds: ["7c9e6679-7425-40de-944b-e07fc1f90ae7"],
        groupIds: [],
        role: "editor"
      }
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log("Created workflow:", response.data.workflow.id);
}

createWorkflow();
```

## Response format

### Success response (200 OK)

```typescript theme={null}
{
  status: "success";
  message: "Workflow created successfully";
  workflow: object;
}
```

`workflow` matches the object on [Workflow API Overview](/en/developer/workflow-api/workflows-overview). Without `shareWith`, only the key (and workspace admins in governance) can see the draft until it is shared.

## Error handling

| Status code | Description                                                                                                                                          |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Invalid body, mixed `initialTriggerKind` with a graph, or `nodes` without `edges`                                                                    |
| 401         | Invalid or missing API key                                                                                                                           |
| 403         | Missing `WORKFLOW_WRITE_API` scope, `createWorkflows`, or `shareWorkflows`. `meeting_end` without Meetings returns `MEETINGS_FEATURE_FLAG_DISABLED`. |
| 404         | A `shareWith` target is unknown or cannot be shared                                                                                                  |
| 429         | Rate limit exceeded                                                                                                                                  |
| 500         | Internal server error                                                                                                                                |

<Info>
  Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


## OpenAPI

````yaml POST /workflows/v1/create
openapi: 3.0.0
info:
  title: Langdock API
  version: 3.0.0
servers:
  - url: https://api.langdock.com
    description: Production
security:
  - bearerAuth: []
paths:
  /workflows/v1/create:
    post:
      tags:
        - Workflows
      summary: Create a workflow
      description: Creates an inactive unpublished draft owned by the API key user.
      operationId: createWorkflow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 60
                description:
                  type: string
                  maxLength: 500
                timezone:
                  type: string
                  description: Valid IANA timezone.
                initialTriggerKind:
                  type: string
                  enum:
                    - manual
                    - webhook
                    - scheduled
                    - form
                    - integration
                    - meeting_end
                  description: >-
                    Starter trigger. Do not send this together with nodes and
                    edges.
                nodes:
                  type: array
                  items:
                    type: object
                  description: Draft nodes. Must be sent together with edges.
                edges:
                  type: array
                  items:
                    type: object
                  description: Draft edges. Must be sent together with nodes.
                shareWith:
                  type: object
                  properties:
                    userIds:
                      type: array
                      items:
                        type: string
                        format: uuid
                      maxItems: 100
                    groupIds:
                      type: array
                      items:
                        type: string
                        format: uuid
                      maxItems: 100
                    role:
                      type: string
                      enum:
                        - user
                        - editor
                      default: editor
                limits:
                  type: object
                  description: Execution caps. Send null on a field to clear it.
                  properties:
                    monthlyCostUsd:
                      type: number
                      minimum: 1
                      maximum: 10000
                      nullable: true
                    perRunCostUsd:
                      type: number
                      minimum: 1
                      maximum: 100
                      nullable: true
                    maxExecutionsPerHour:
                      type: integer
                      minimum: 1
                      maximum: 5000
                      nullable: true
      responses:
        '200':
          description: Workflow created successfully
        '400':
          description: >-
            Invalid body, mixed initialTriggerKind with a graph, or nodes
            without edges
        '401':
          description: Invalid or missing API key
        '403':
          description: >-
            Missing WORKFLOW_WRITE_API scope, createWorkflows, or
            shareWorkflows. meeting_end without Meetings returns
            MEETINGS_FEATURE_FLAG_DISABLED.
        '404':
          description: A shareWith target is unknown or cannot be shared
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````