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

# Apply Graph Operations

> Apply graph operations with optimistic concurrency.

Validates base_version matches current graph_version.
Returns 409 Conflict with latest graph if versions mismatch.



## OpenAPI

````yaml https://platform.tracecat.com/api/openapi.json patch /workspaces/{workspace_id}/workflows/{workflow_id}/graph
openapi: 3.1.0
info:
  title: Tracecat API
  summary: Tracecat API
  description: The open source AI automation platform for security teams and agents.
  termsOfService: >-
    https://docs.google.com/document/d/e/2PACX-1vQvDe3SoVAPoQc51MgfGCP71IqFYX_rMVEde8zC4qmBCec5f8PLKQRdxa6tsUABT8gWAR9J-EVs2CrQ/pub
  contact:
    name: Tracecat Founders
    email: founders@tracecat.com
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1'
servers:
  - url: /api
security: []
tags:
  - name: public
    description: Public facing endpoints
  - name: workflows
    description: Workflow management
  - name: actions
    description: Action management
  - name: triggers
    description: Workflow triggers
  - name: secrets
    description: Secret management
  - name: variables
    description: Workspace variable management
paths:
  /workspaces/{workspace_id}/workflows/{workflow_id}/graph:
    patch:
      tags:
        - graph
      summary: Apply Graph Operations
      description: |-
        Apply graph operations with optimistic concurrency.

        Validates base_version matches current graph_version.
        Returns 409 Conflict with latest graph if versions mismatch.
      operationId: graph-apply_graph_operations
      parameters:
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Workspace Id
        - name: workflow_id
          in: path
          required: true
          schema:
            anyOf:
              - type: string
                pattern: wf_[0-9a-zA-Z]+
              - type: string
                pattern: wf-[0-9a-f]{32}
            title: Workflow Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GraphOperationsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GraphResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyCookie: []
        - ServiceAccountApiKeyBearer: []
components:
  schemas:
    GraphOperationsRequest:
      properties:
        base_version:
          type: integer
          title: Base Version
          description: Expected current graph_version. Returns 409 if mismatched.
        operations:
          items:
            $ref: '#/components/schemas/GraphOperation'
          type: array
          title: Operations
          description: List of operations to apply atomically
      type: object
      required:
        - base_version
        - operations
      title: GraphOperationsRequest
      description: |-
        Request for PATCH /workflows/{id}/graph.

        Applies a batch of graph operations with optimistic concurrency.
    GraphResponse:
      properties:
        version:
          type: integer
          title: Version
          description: Graph version for optimistic concurrency
        nodes:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Nodes
          description: React Flow nodes
        edges:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Edges
          description: React Flow edges
        viewport:
          additionalProperties: true
          type: object
          title: Viewport
      type: object
      required:
        - version
        - nodes
        - edges
      title: GraphResponse
      description: |-
        Response for GET /workflows/{id}/graph.

        Returns the canonical graph projection from Actions.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    GraphOperation:
      properties:
        type:
          $ref: '#/components/schemas/GraphOperationType'
        payload:
          additionalProperties: true
          type: object
          title: Payload
          description: Operation-specific payload
      type: object
      required:
        - type
        - payload
      title: GraphOperation
      description: A single graph operation.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    GraphOperationType:
      type: string
      enum:
        - add_node
        - update_node
        - delete_node
        - add_edge
        - delete_edge
        - move_nodes
        - update_trigger_position
        - update_viewport
      title: GraphOperationType
      description: Graph operation types.
  securitySchemes:
    APIKeyCookie:
      type: apiKey
      in: cookie
      name: fastapiusersauth
    ServiceAccountApiKeyBearer:
      type: http
      description: Tracecat service account API key.
      scheme: bearer

````