> 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/createworkflow.md).

# Create Workflow

createWorkflow Mutation

Creates a new Workflow definition in the system.

## Arguments

| Name    | Type                   | Description                          |
| ------- | ---------------------- | ------------------------------------ |
| `input` | `CreateWorkflowInput!` | Input data for creating the workflow |

## Return Type

`Workflow` - The created workflow definition.

## Input Fields

`CreateWorkflowInput`:

| Field               | Type      | Description                                                     |
| ------------------- | --------- | --------------------------------------------------------------- |
| `dataTypeID`        | `UUID`    | Optional data type ID to associate with the workflow            |
| `dataTypeSlug`      | `String`  | Optional data type slug                                         |
| `data`              | `Map`     | Custom data associated with the workflow                        |
| `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 |
| `workflowsignalIDs` | `[ID!]`   | IDs of workflow signals to associate with this workflow         |

## Usage Example

```graphql
mutation {
  createWorkflow(
    input: {
      name: "Inventory Restock Workflow",
      active: true,
      filterRule: "item.quantity < item.minimum_stock",
      data: {
        "description": "Automatically triggers when inventory falls below minimum stock",
        "priority": "high",
        "department": "inventory_management",
        "notification_channels": ["email", "slack"],
        "escalation_rules": {
          "after_hours": 2,
          "business_hours": 4
        }
      },
      dataTypeSlug: "inventory_workflow",
      workflowsignalIDs: ["signal_123", "signal_456"]
    }
  ) {
    id
    name
    active
    filterRule
    data
    dataTypeSlug
    createdAt
    createdBy
    workflowSignals {
      id
      eventName
      start
    }
  }
}
```

## JavaScript Example

```javascript
const CREATE_WORKFLOW = gql`
  mutation CreateWorkflow($input: CreateWorkflowInput!) {
    createWorkflow(input: $input) {
      id
      name
      active
      filterRule
      data
      dataTypeSlug
      createdAt
      createdBy
      workflowSignals {
        id
        eventName
        start
      }
    }
  }
`;

const { data } = await client.mutate({
  mutation: CREATE_WORKFLOW,
  variables: {
    input: {
      name: "Inventory Restock Workflow",
      active: true,
      filterRule: "item.quantity < item.minimum_stock",
      data: {
        description: "Automatically triggers when inventory falls below minimum stock",
        priority: "high",
        department: "inventory_management",
        notification_channels: ["email", "slack"],
        escalation_rules: {
          after_hours: 2,
          business_hours: 4
        }
      },
      dataTypeSlug: "inventory_workflow",
      workflowsignalIDs: ["signal_123", "signal_456"]
    }
  }
});

console.log(`Created workflow: ${data.createWorkflow.name} with ID: ${data.createWorkflow.id}`);
```

## Important Notes

* Workflows define reusable business logic that can be triggered by events
* The `filterRule` determines when the workflow should be activated based on data conditions
* Inactive workflows (`active: false`) will not be triggered even if conditions are met
* The `data` field supports flexible JSON structures for workflow configuration
* Workflow signals define the entry points and event handlers for the workflow
* Once created, workflows can be managed through the Temporal workflow engine


---

# 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/createworkflow.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.
