> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/graphql-api/mutations/updateworkflow.md).

# Update Workflow

updateWorkflow Mutation

Updates an existing Workflow definition in the system with new data.

## Arguments

| Name    | Type                   | Description                                     |
| ------- | ---------------------- | ----------------------------------------------- |
| `id`    | `ID!`                  | The unique identifier of the workflow to update |
| `input` | `UpdateWorkflowInput!` | Input data for updating the workflow            |

## Return Type

`Workflow` - The updated workflow definition.

## Input Fields

`UpdateWorkflowInput`:

| Field                     | Type      | Description                                                     |
| ------------------------- | --------- | --------------------------------------------------------------- |
| `dataTypeID`              | `UUID`    | Optional data type ID to associate with the workflow            |
| `clearDataTypeID`         | `Boolean` | Clear the existing data type ID                                 |
| `dataTypeSlug`            | `String`  | Optional data type slug                                         |
| `clearDataTypeSlug`       | `Boolean` | Clear the existing data type slug                               |
| `data`                    | `Map`     | Custom data associated with the workflow                        |
| `clearData`               | `Boolean` | Clear the existing custom data                                  |
| `name`                    | `String`  | Name of the workflow                                            |
| `active`                  | `Boolean` | Whether the workflow is active and can be triggered             |
| `filterRule`              | `String`  | Filter rule to determine when this workflow should be triggered |
| `clearFilterRule`         | `Boolean` | Clear the existing filter rule                                  |
| `addWorkflowSignalIDs`    | `[ID!]`   | IDs of workflow signals to add to this workflow                 |
| `removeWorkflowSignalIDs` | `[ID!]`   | IDs of workflow signals to remove from this workflow            |
| `clearWorkflowSignals`    | `Boolean` | Clear all associated workflow signals                           |

## Usage Example

```graphql
mutation {
  updateWorkflow(
    id: "workflow_123"
    input: {
      name: "Enhanced Inventory Restock Workflow",
      active: true,
      filterRule: "(item.quantity < item.minimum_stock) OR (item.quantity == 0)",
      data: {
        "description": "Enhanced workflow with zero-stock handling",
        "priority": "critical",
        "department": "inventory_management",
        "notification_channels": ["email", "slack", "sms"],
        "escalation_rules": {
          "after_hours": 1,
          "business_hours": 2
        },
        "auto_reorder": true,
        "reorder_multiplier": 1.5
      },
      dataTypeSlug: "critical_inventory_workflow",
      addWorkflowSignalIDs: ["signal_789"]
    }
  ) {
    id
    name
    active
    filterRule
    data
    dataTypeSlug
    updatedAt
    updatedBy
    workflowSignals {
      id
      eventName
      start
    }
  }
}
```

## JavaScript Example

```javascript
const UPDATE_WORKFLOW = gql`
  mutation UpdateWorkflow($id: ID!, $input: UpdateWorkflowInput!) {
    updateWorkflow(id: $id, input: $input) {
      id
      name
      active
      filterRule
      data
      dataTypeSlug
      updatedAt
      updatedBy
      workflowSignals {
        id
        eventName
        start
      }
    }
  }
`;

const { data } = await client.mutate({
  mutation: UPDATE_WORKFLOW,
  variables: {
    id: "workflow_123",
    input: {
      name: "Enhanced Inventory Restock Workflow",
      active: true,
      filterRule: "(item.quantity < item.minimum_stock) OR (item.quantity == 0)",
      data: {
        description: "Enhanced workflow with zero-stock handling",
        priority: "critical",
        department: "inventory_management",
        notification_channels: ["email", "slack", "sms"],
        escalation_rules: {
          after_hours: 1,
          business_hours: 2
        },
        auto_reorder: true,
        reorder_multiplier: 1.5
      },
      dataTypeSlug: "critical_inventory_workflow",
      addWorkflowSignalIDs: ["signal_789"]
    }
  }
});

console.log(`Updated workflow: ${data.updateWorkflow.name}`);
```

## Important Notes

* Updating a workflow may affect running workflow instances depending on the changes
* Use the clear flags to explicitly remove optional fields
* The `data` field supports flexible JSON structures for workflow configuration
* Changes to the `filterRule` will affect when the workflow is triggered in the future
* Deactivating a workflow (`active: false`) will prevent new instances from starting
* Workflow signal associations can be managed incrementally using add/remove operations
* Consider the impact on existing workflow instances when making significant changes


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pyck.cloud/graphql-api/mutations/updateworkflow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
