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

# Update workflow

> **Endpoint:** `v1/workflows/{id}`

Update a workflow's name, status, or design. This endpoint supports multiple update scenarios:

**Update Scenarios:**
- **Name-only update:** Update just the workflow name
- **Status change:** Change workflow status (draft/active/paused)
- **Publish workflow:** Update and activate workflow design (creates new version)
- **Update draft:** Modify draft workflow design

**Special Behavior:**
When changing an active workflow to draft status, the system automatically copies the active workflow files to the draft folder, allowing you to make changes without affecting the currently active version.

**Note:** Creating and editing workflow logic (nodes/edges) is only supported through the dashboard due to the complex ReactFlow JSON format that requires backend transformation.




## OpenAPI

````yaml api-reference/openapi.yml patch /workflows/{id}
openapi: 3.1.0
info:
  title: Send Email API
  description: >
    Send transactional emails through MailDiver.


    ### Base URL

    All API endpoints are prefixed with `api.` subdomain:

    ```

    https://api.maildiver.com

    ```


    For the self-hosted version, if your domain is `example.com`:

    ```

    https://api.example.com

    ```


    ### Endpoint

    ```

    v1/emails

    ```


    ### Authentication

    All API requests require authentication using your API key in the
    Authorization header:

    ```

    Authorization: Bearer your-api-key

    ```
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: https://api.maildiver.com/v1
    description: Production server
    variables:
      domain:
        default: yourdomain.com
        description: Your domain (without the api. prefix)
security:
  - bearerAuth: []
paths:
  /workflows/{id}:
    patch:
      tags:
        - Automation Workflow
      summary: Update workflow
      description: >
        **Endpoint:** `v1/workflows/{id}`


        Update a workflow's name, status, or design. This endpoint supports
        multiple update scenarios:


        **Update Scenarios:**

        - **Name-only update:** Update just the workflow name

        - **Status change:** Change workflow status (draft/active/paused)

        - **Publish workflow:** Update and activate workflow design (creates new
        version)

        - **Update draft:** Modify draft workflow design


        **Special Behavior:**

        When changing an active workflow to draft status, the system
        automatically copies the active workflow files to the draft folder,
        allowing you to make changes without affecting the currently active
        version.


        **Note:** Creating and editing workflow logic (nodes/edges) is only
        supported through the dashboard due to the complex ReactFlow JSON format
        that requires backend transformation.
      operationId: updateWorkflow
      parameters:
        - name: id
          in: path
          required: true
          description: Unique identifier of the workflow
          schema:
            type: string
          example: 0199f234-d327-7cd8-9dc5-4fd8e5e249df
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: >
                    Workflow name. Must be:

                    - At least 1 character long

                    - Maximum 100 characters

                    - Can only include letters, numbers, spaces, hyphens, and
                    underscores
                  minLength: 1
                  maxLength: 100
                  example: Welcome Email Series
                status:
                  type: string
                  enum:
                    - draft
                    - active
                    - paused
                  description: |
                    Workflow status:
                    - `draft`: Workflow is in draft mode (not active)
                    - `active`: Workflow is active and will trigger on events
                    - `paused`: Workflow is paused (will not trigger)
                  example: active
                design:
                  type: object
                  description: >
                    ReactFlow JSON workflow design. This is a complex object
                    structure that should be created through the dashboard.


                    **Note:** This field is only used when updating workflow
                    logic through the API. Most workflow updates should be done
                    through the dashboard due to the complexity of the ReactFlow
                    JSON format and backend transformation requirements.
                  example:
                    nodes:
                      - id: trigger
                        type: trigger
                        position:
                          x: 100
                          'y': 100
                        data:
                          eventName: user_signed_up
                    edges: []
            examples:
              updateName:
                summary: Update workflow name
                value:
                  name: Updated Welcome Series
              changeStatus:
                summary: Change workflow status
                value:
                  status: paused
              activateWorkflow:
                summary: Activate workflow
                value:
                  status: active
              updateDraft:
                summary: Update draft workflow design
                value:
                  design:
                    nodes:
                      - id: trigger
                        type: trigger
                        position:
                          x: 100
                          'y': 100
                        data:
                          eventName: user_signed_up
                    edges: []
      responses:
        '200':
          description: Workflow successfully updated
          content:
            application/json:
              examples:
                success:
                  summary: Success response
                  value:
                    workflow_id: 0199f234-d327-7cd8-9dc5-4fd8e5e249df
                    workspace_id: 0195a927-b706-725a-94dd-372770d920f2
                    name: Updated Welcome Series
                    status: active
                    current_version: 2
                    active_version: 2
                    created: 1742299707142
                    updated: 1742301234567
                    created_by: admin@company.com
                    created_by_type: user
        '400':
          description: Bad request
          content:
            application/json:
              examples:
                missingBody:
                  summary: Missing request body
                  value:
                    error: Request body is required
                invalidJson:
                  summary: Invalid JSON
                  value:
                    error: Invalid JSON in request body
                nameValidation:
                  summary: Name validation failed
                  value:
                    error: >-
                      Name validation failed: must be 1-100 characters and
                      contain only letters, numbers, spaces, hyphens, and
                      underscores
                invalidStatus:
                  summary: Invalid status
                  value:
                    error: 'Status must be one of: draft, active, paused'
                validationFailed:
                  summary: Workflow validation failed
                  value:
                    error: Workflow validation failed
                transformationFailed:
                  summary: Workflow transformation failed
                  value:
                    error: >-
                      Workflow transformation failed: Invalid ReactFlow JSON
                      structure
        '403':
          description: Forbidden (API key is missing or invalid)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Workflow not found
          content:
            application/json:
              examples:
                notFound:
                  summary: Workflow not found error
                  value:
                    error: Workflow not found
        '500':
          description: Internal server error
          content:
            application/json:
              examples:
                copyFailed:
                  summary: Failed to copy workflow for editing
                  value:
                    error: Failed to copy workflow for editing
                    details: Error details
                publishFailed:
                  summary: Failed to publish workflow
                  value:
                    error: Failed to publish workflow
                    details: Error details
                updateFailed:
                  summary: Failed to update workflow
                  value:
                    error: Failed to update workflow
                    details: Error details
components:
  schemas:
    Error:
      type: object
      properties:
        message:
          type: string
          description: Error description
      description: |
        Error response with message.

        ### Common Errors

        #### 400 Bad Request
        Validation errors return only the error message:
        ```json
        {
          "message": "from field is required"
        }
        ```

        Common validation messages:
        - `"from field is required"`
        - `"to field is required"`
        - `"subject field is required"`
        - `"html content size (42MB) exceeds maximum of 40MB"`
        - `"Too many recipients: 51. Maximum allowed is 50"`
        - `"Invalid email format in from field"`
        - `"template_id cannot be used together with html"`

        #### 403 Forbidden
        Authentication errors include both message and code:
        ```json
        {
          "message": "Invalid API key",
          "code": "invalid_api_key"
        }
        ```
        ```json
        {
          "message": "Invalid authorization header",
          "code": "invalid_authorization_header"
        }
        ```

        #### 404 Not Found
        ```json
        {
          "message": "Template 'welcome-email' not found"
        }
        ```
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key with format "Bearer {your-api-key}"

````