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

# Create a workflow

> Save a workflow, agent, bot or campaign.


## OpenAPI

```yaml openapi.json post /v1/workflows
openapi: 3.1.0
info:
  title: Ocean One API
  version: 2.3.1
servers:
  - url: https://api.plungeai.com
paths:
  /v1/workflows:
    post:
      operationId: post-v1-workflows
      tags:
        - Workflows
      summary: Save a workflow, agent, bot or campaign
      description: "The same row Studio and the MCP tools show. `yaml` is validated against the CNL schema and the kind lint before anything is stored (a bot on a frozen runtime such as harness-agent with `posture` is refused). `folder` names an existing folder or creates it. A `kind: campaign` create with `campaign_config` also sets up the ledger and the schedule. Save as YAML: send the pure workflow YAML as a `text/yaml` body and the metadata as the `kind` (required), `name` (required unless `workflow.name` is in the YAML), `description` and `folder` query parameters; a YAML body without `kind` is 400 `invalid_request`, and `campaign_config` stays JSON-only."
      security:
        - ozkBearer: []
      parameters:
        - name: kind
          in: query
          schema:
            type: string
            enum:
              - workflow
              - agent
              - bot
              - campaign
          description: text/yaml body only. Required on create; on PATCH it must equal the stored kind or be left out (400 invalid_request otherwise; change a kind with a JSON PATCH)
        - name: name
          in: query
          schema:
            type: string
            maxLength: 200
          description: "text/yaml body only. Create: required unless `workflow.name` is in the YAML (the query wins when both are set). PATCH: renames"
        - name: description
          in: query
          schema:
            type: string
          description: text/yaml body only. Optional
        - name: folder
          in: query
          schema:
            type: string
            maxLength: 120
          description: text/yaml body only. Optional; the same as the JSON `folder` field
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - kind
                - yaml
              properties:
                name:
                  type: string
                  maxLength: 200
                kind:
                  type: string
                  enum:
                    - workflow
                    - agent
                    - bot
                    - campaign
                yaml:
                  type: string
                  description: The workflow as CNL YAML
                description:
                  type: string
                folder:
                  type: string
                  maxLength: 120
                campaign_config:
                  type: object
                  description: kind campaign only (422 on any other kind). list (exactly one of table | agent | csv | inline), cycle (once | hourly | daily | weekly | monthly | continuous) and max_attempts (integer >= 1) are required; cycle_start (reset | refill), schedule (5-field cron), batch_size, max_items, pace, then (a campaign or workflow id), deliver ([{ channel, to? }], default in-app) and local are optional — the Studio campaign-config block. Invalid → 422 invalid_params, nothing is created.
                format:
                  type: string
                  enum:
                    - json
                    - yaml
                    - markdown
                    - text
                  description: "Response format override (precedence: this field → Accept header → mirror of the request Content-Type). Default json. yaml = the envelope with Markdown as block scalars; markdown = the same result the MCP plane renders; text = the bare result content. An unknown value → 400 invalid_format."
          text/yaml:
            schema:
              type: string
              description: The workflow as CNL YAML, `workflow:` at the top (also application/yaml and application/x-yaml); the other fields are the `kind`, `name`, `description` and `folder` query parameters. The reply stays JSON unless `format` or Accept say otherwise.
      responses:
        "201":
          description: Saved; the Location header names the new workflow. Response format negotiates via the `format` field, an Accept header (application/json, text/yaml, text/markdown, text/plain), or the request Content-Type mirror; default JSON.
          content:
            application/json:
              schema:
                type: object
                properties:
                  workflow:
                    type: object
                    properties:
                      id:
                        type: string
                      name:
                        type: string
                      kind:
                        type: string
                        enum:
                          - workflow
                          - agent
                          - bot
                          - campaign
                      description:
                        type:
                          - string
                          - "null"
                      folder:
                        type:
                          - string
                          - "null"
                        description: The folder name, or null when unfiled
                      updated_at:
                        type: integer
                        description: Unix seconds
                      version:
                        type:
                          - integer
                          - "null"
                        description: Number of the current saved version; null until a version is saved
                  warnings:
                    type: array
                    items:
                      type: string
                    description: Non-fatal notes (lint warnings, campaign setup notes); present only when there are any
            text/yaml:
              schema:
                type: string
            text/markdown:
              schema:
                type: string
            text/plain:
              schema:
                type: string
        "400":
          description: invalid_json / invalid_yaml / invalid_body — unreadable body; invalid_format — format must be one of json, yaml, markdown, text
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "401":
          description: unauthorized — missing, invalid or revoked ozk_ key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: "not_found — no route for this method on this path: every other method answers it"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "413":
          description: payload_too_large — body over 1 MiB (MAX_REQUEST_SIZE)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "422":
          description: invalid_workflow — the YAML failed validation or the kind lint (the envelope carries `errors` and `warnings`; nothing was written). invalid_params — a field is missing or malformed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "502":
          description: storage_error — the database or storage layer failed; no detail is returned, retry
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Error:
      type: object
      description: Standard error envelope. Every error response also carries an `X-Error-Code` response header equal to error.code, so a client branches on the header regardless of the negotiated body format (json | yaml | markdown | text). When the request created an execution, the `X-Execution-Id` response header is also set. Errors follow the negotiated format like success bodies.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            connect:
              type: object
              description: "On a 424 connection_required / credential_required: where the missing connection is made."
              properties:
                provider:
                  type: string
                method:
                  type: string
                  enum:
                    - oauth
                    - api_key
                    - wallet
                link:
                  type: string
                  example: POST /v1/connections/stripe/link
          required:
            - code
            - message
          additionalProperties: true
      required:
        - error
  securitySchemes:
    ozkBearer:
      type: http
      scheme: bearer
      description: "ozk_ platform API key (Authorization: Bearer ozk_…)"
```
