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

# Update Workflow (PATCH)

Partially update a Workflow by creating a new version from an existing base version. Use this endpoint when you want to change only selected nodes or version metadata without resending the complete workflow graph.

## Behavior Notes

* If `base_version` is omitted, PromptLayer patches from the latest version.
* `nodes` are merged by name: unmentioned nodes are preserved, object values add or update nodes, and `null` removes a node.
* Node `configuration` is deep-merged, while `dependencies`, `required_input_variables`, and `edges` are replaced when provided.
* `release_labels` are moved or attached to the newly created version.

## Related

* [Create Workflow](/reference/create-workflow)
* [Run Workflow](/reference/run-workflow)
* [Workflows](/why-promptlayer/workflows)


## OpenAPI

````yaml PATCH /rest/workflows/{workflow_id_or_name}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /rest/workflows/{workflow_id_or_name}:
    patch:
      tags:
        - workflow
      summary: Patch Workflow
      operationId: patchWorkflow
      parameters:
        - name: workflow_id_or_name
          in: path
          required: true
          schema:
            type: string
          description: The ID or name of the workflow to update.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchWorkflow'
            examples:
              updateNode:
                summary: Update one node
                value:
                  commit_message: Updated prompt template version
                  nodes:
                    response_generator:
                      configuration:
                        template:
                          prompt_name: response-v2
                          label: production
              addNode:
                summary: Add a node
                value:
                  commit_message: Added logging node
                  nodes:
                    logger:
                      node_type: CODE_EXECUTION
                      configuration:
                        code: 'print(f''Processing: {input_data}'')'
                        language: PYTHON
                      dependencies:
                        - input_data
                      is_output_node: false
              removeNode:
                summary: Remove a node
                value:
                  commit_message: Removed deprecated node
                  nodes:
                    old_processor: null
              branchFromVersion:
                summary: Branch from a specific version
                value:
                  base_version: 5
                  commit_message: Hotfix based on v5
                  nodes:
                    output:
                      configuration:
                        value:
                          type: string
                          value: fixed
      responses:
        '201':
          description: Workflow version created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWorkflowResponse'
              examples:
                patched:
                  summary: Workflow version created
                  value:
                    success: true
                    workflow_id: 123
                    workflow_name: greeting-workflow
                    workflow_version_id: 456
                    version_number: 3
                    base_version: 2
                    release_labels:
                      - staging
                    nodes:
                      - id: node-uuid
                        name: greeting
                        node_type: VARIABLE
                        is_output_node: true
                    required_input_variables: {}
                    external_ids: []
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    PatchWorkflow:
      type: object
      properties:
        base_version:
          type: integer
          nullable: true
          description: >-
            The version number to base changes on. Defaults to the latest
            version.
        commit_message:
          type: string
          nullable: true
          description: A message describing the changes.
        nodes:
          type: object
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/NodeUpdate'
              - type: 'null'
          nullable: true
          description: >-
            Node updates keyed by node name. Provide an object to add/update a
            node, or null to remove a node. Node configuration is deep-merged;
            dependencies are replaced.
        required_input_variables:
          type: object
          additionalProperties:
            type: string
          nullable: true
          description: If provided, replaces the input variables entirely.
        edges:
          type: array
          items:
            $ref: '#/components/schemas/Edge'
          nullable: true
          description: >-
            If provided, replaces edges entirely. If omitted, existing edges are
            copied except edges that reference removed nodes.
        release_labels:
          type: array
          items:
            type: string
          nullable: true
          description: Labels to move or attach to the newly created workflow version.
      description: >-
        Request body for partially updating a workflow. The server fetches
        base_version (latest if omitted), merges node updates, and creates a new
        version.
    CreateWorkflowResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the request was successful.
        workflow_id:
          type: integer
          description: The ID of the workflow.
        workflow_name:
          type: string
          description: The name of the workflow.
        workflow_version_id:
          type: integer
          description: The ID of the created workflow version.
        version_number:
          type: integer
          description: The version number.
        base_version:
          type: integer
          nullable: true
          description: The base version this was created from (PATCH only).
        release_labels:
          type: array
          items:
            type: string
          nullable: true
          description: Labels attached to this version.
        nodes:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              node_type:
                type: string
              is_output_node:
                type: boolean
          description: Summary of nodes in the workflow.
        required_input_variables:
          type: object
          additionalProperties:
            type: string
          description: Required input variables for the workflow.
        external_ids:
          type: array
          items:
            $ref: '#/components/schemas/ExternalId'
          description: External ID mappings for the workflow.
      required:
        - success
        - workflow_id
        - workflow_name
        - workflow_version_id
        - version_number
        - external_ids
      description: Response after creating or patching a workflow.
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    NodeUpdate:
      type: object
      properties:
        node_type:
          type: string
          nullable: true
          description: The node type (required for new nodes).
        configuration:
          type: object
          nullable: true
          description: Node configuration to merge.
        dependencies:
          type: array
          items:
            type: string
          nullable: true
          description: Dependencies to replace.
        is_output_node:
          type: boolean
          nullable: true
          description: Whether this is an output node.
      description: Partial update for a single node.
    Edge:
      type: object
      properties:
        source_node_name:
          type: string
          description: The source node name.
        target_node_name:
          type: string
          description: The target node name.
        is_and:
          type: boolean
          description: >-
            Whether multiple conditionals use AND logic (true) or OR logic
            (false).
        conditionals:
          type: array
          items:
            $ref: '#/components/schemas/EdgeConditional'
          minItems: 1
          description: At least one conditional.
      required:
        - source_node_name
        - target_node_name
        - is_and
        - conditionals
    ExternalId:
      properties:
        source:
          type: string
          maxLength: 128
          minLength: 1
          title: Source
          description: The external system or namespace that owns the ID.
        external_id:
          type: string
          maxLength: 512
          minLength: 1
          title: External Id
          description: The identifier for this entity in the external system.
      type: object
      required:
        - source
        - external_id
      additionalProperties: false
      title: ExternalId
      description: >-
        Customer-defined mapping between a PromptLayer entity and an external
        system identifier.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    EdgeConditional:
      type: object
      properties:
        position:
          type: integer
          minimum: 0
          description: Order of evaluation.
        operator:
          type: string
          enum:
            - '='
            - '!='
            - <
            - '>'
            - <=
            - '>='
            - in
            - not_in
            - is_null
            - is_not_null
          description: Comparison operator.
        left_config:
          type: object
          description: Left side of comparison. Can be static_value or source.
        right_config:
          type: object
          description: Right side of comparison. Can be static_value or source.
      required:
        - position
        - operator
        - left_config
        - right_config
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Not found - requested resource does not exist or is not accessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````