> ## 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.

# Workflow erstellen

> Erstelle einen inaktiven Workflow-Entwurf in deinem Workspace

Erstellt einen inaktiven, unveröffentlichten Entwurf, der dem API-Key-User gehört. Das Erstellen veröffentlicht den Workflow nicht und startet keine Zeitpläne oder Webhooks.

## Basis-URL

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

<Warning>
  **Dedicated Deployments**

  Ersetze `api.langdock.com` durch `<your-deployment-url>/api/public` in allen Anfragen.
</Warning>

## Erforderliche Scopes

Dieser Endpoint erfordert den `WORKFLOW_WRITE_API` Scope (**Workflow-Schreib-API**). Der Key-User braucht außerdem die Berechtigung `createWorkflows`.

<Info>
  `shareWith` erfordert die Berechtigung `shareWorkflows`. Ein unbekanntes oder nicht teilbares Ziel bricht die Anfrage mit `404` ab, und der Workflow wird nicht erstellt.
</Info>

## Parameter

| Parameter            | Typ    | Erforderlich | Beschreibung                                                                                                                                                                                                                                                                                                                     |
| -------------------- | ------ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`               | string | Ja           | Workflow-Name. Maximum: 60 Zeichen.                                                                                                                                                                                                                                                                                              |
| `description`        | string | Nein         | Workflow-Beschreibung. Maximum: 500 Zeichen.                                                                                                                                                                                                                                                                                     |
| `timezone`           | string | Nein         | Gültige IANA-Zeitzone, zum Beispiel `Europe/Berlin`.                                                                                                                                                                                                                                                                             |
| `initialTriggerKind` | string | Nein         | Starter-Trigger: `manual`, `webhook`, `scheduled`, `form`, `integration` oder `meeting_end` (**Meeting End**). Nicht zusammen mit `nodes` und `edges` senden. `meeting_end` braucht Meetings für den Key-User. Sonst kommt `403` mit `MEETINGS_FEATURE_FLAG_DISABLED`.                                                           |
| `nodes`              | array  | Nein         | Entwurf-Nodes. Muss zusammen mit `edges` gesendet werden.                                                                                                                                                                                                                                                                        |
| `edges`              | array  | Nein         | Entwurf-Kanten. Muss zusammen mit `nodes` gesendet werden.                                                                                                                                                                                                                                                                       |
| `shareWith`          | object | Nein         | User und Gruppen zum Teilen. `userIds` und `groupIds` sind UUID-Arrays (jeweils maximal 100). `role` ist `user` (Betrachter) oder `editor` (Standard `editor`).                                                                                                                                                                  |
| `limits`             | object | Nein         | Ausführungslimits. `monthlyCostUsd` ist 1 bis 10000. `perRunCostUsd` ist 1 bis 100. `maxExecutionsPerHour` ist 1 bis 5000. Sende `null` auf einem Feld, um es zu leeren. Weggelassene Felder nutzen die Builder-Standards: 25 USD monatlich (oder den Workspace-Standard), 2 USD pro Ausführung und 100 Ausführungen pro Stunde. |

Der Graph nutzt dasselbe Node- und Kanten-Schema wie der Workflow-Builder. Vorlagen kannst du über diese API nicht erstellen.

## Beispiel

```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();
```

## Antwortformat

### Erfolgreiche Antwort (200 OK)

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

`workflow` entspricht dem Objekt in der [Workflow API Übersicht](/de/developer/workflow-api/workflows-overview). Ohne `shareWith` sieht nur der Key (und Workspace-Admins in der Governance) den Entwurf, bis er geteilt wird.

## Fehlerbehandlung

| Statuscode | Beschreibung                                                                                                                                             |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400        | Ungültiger Body, `initialTriggerKind` zusammen mit einem Graphen, oder `nodes` ohne `edges`                                                              |
| 401        | Ungültiger oder fehlender API-Key                                                                                                                        |
| 403        | Fehlender `WORKFLOW_WRITE_API` Scope, `createWorkflows` oder `shareWorkflows`. `meeting_end` ohne Meetings gibt `MEETINGS_FEATURE_FLAG_DISABLED` zurück. |
| 404        | Ein `shareWith`-Ziel ist unbekannt oder nicht teilbar                                                                                                    |
| 429        | Rate Limit überschritten                                                                                                                                 |
| 500        | Interner Serverfehler                                                                                                                                    |

<Info>
  Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen und die Sicherheit deiner Anwendungen zu gewährleisten. Weitere Informationen findest du in unserem Guide zu [Best Practices für API-Schlüssel](/de/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"

````