# Creating a Workflow

Workflows allow you to automate running sequential actions and development workflows based on contextual data that exist inside your workspace. On this page, learn how to create a Workflow in the Cortex UI.

For information on creating Workflows via GitOps, see [Workflows as code](https://docs.cortex.io/streamline/workflows/create/workflows-as-code).

### Examples and additional resources

For a quicker start, you can use one of the Workflow templates provided in-app for common development workflows.

{% hint style="success" %}
Looking for a quick introduction to building and managing Workflows? Check out the [Cortex Academy "Understanding Workflows" course](https://academy.cortex.io/courses/understanding-workflows), available to all Cortex customers and POVs.
{% endhint %}

## How to create a Workflow

### Prerequisites

Before getting started:

* You must have the `Edit Workflows` permission.
* If you plan to manage Workflows in the UI, make sure GitOps editing is disabled under [**Settings > GitOps > Workflows**](https://app.getcortexapp.com/admin/settings/gitops?activeGitopsTab=WORKFLOWS).

#### Understanding RBAC for Workflows

It is possible to configure specific users, teams, or roles who are allowed to run a Workflow, or you can require the user to be an Owner or Editor of an entity in order to run the Workflow. This is described in more detail under [Step 2: Configure your Workflow settings](#step-2-configure-your-workflow-settings).

It is also possible to add a "Manual approval" block to your Workflow, requiring approval from specific team members. Read more about configuring this under [Step 3: Add blocks to your Workflow](#step-3-add-blocks-to-your-workflow).

### Step 1: Choose a template or a blank Workflow

You can choose to create a Workflow from a template or you can choose to create one from scratch.

1. In the lefthand navigation menu of Cortex, click **Workflows**.
2. In the upper right corner of the page, click **Create Workflow**.
3. Choose whether to start with a template or a blank workflow.
   * **Workflow Template**: Click the tile for the template you wish to use.
     * There are templates available for the following common Workflows: Create a AWS S3 bucket, create an AWS EC2 instance, create a ServiceNow incident, create an Azure function, and create a Jira issue.
     * Note: Each tile displays the requirements for secrets you must define before using the template; make sure to follow the template's requirements before you proceed.
   * **Blank Workflow**: Click the "Start from scrach" button at the top of the page.\ <img src="https://826863033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJW7pYRxS4dHS3Hv6wxve%2Fuploads%2Fgit-blob-a272216c349bbd5d9cb8b436e9be5169d0a28aa1%2Fblank-workflow.jpg?alt=media" alt="" data-size="original">

### Step 2: Configure your Workflow settings

1. On the Create Workflow page, fill in the fields to configure your Workflow. The name, slug, and description are prepopulated for templates.
   * **Name**: Enter a descriptive name for your Workflow.
   * **Slug**: Enter a unique slug. If you have previously used a template, make sure to update the prepopulated slug when you use the template again.
   * **Description**: Optionally enter a description of the Workflow.
   * **Display icon**: Select an icon that will be used when displaying this Workflow across Cortex.
   * **Run response template**: Optionally enter a response template for successful runs.
     * See more information about templating in the [Blocks documentation](https://docs.cortex.io/streamline/workflows/blocks/states).
   * **Failed run response template**: Optionally enter a response template for failed runs.
     * See more information about templating in the [Blocks documentation](https://docs.cortex.io/streamline/workflows/blocks/states).
   * **Scope**: Select `Entity` to narrow the Workflow's scope to a specific entity, or select `Global` if the Workflow should not be scoped to a specific entity.
     * If you choose `Entity`:
       * **Entity Type**: Select the entity type that this Workflow applies to.
         * Optionally, you can also choose groups to include or exclude.
       * **User relation to entities**: Specify the relation to the entity that the user running the Workflow must have in order to run the Workflow. You can require the user to be an Owner or an Editor of the entity in order to run the Workflow. If you choose Editor, you must have the [Team ownership entity setting](https://docs.cortex.io/configure/settings/managing-users/permissioning/team-entity-editing) enabled.
       * **Restrict to initiator only**: When this setting is toggled on, only the person who started the Workflow can provide any required input during the Workflow run.
   * **Variables:** Declared variables on the Workflow that can be referenced from every block. To set or update their values, use the Set variable(s) block.
     1. **Slug**: Enter a unique slug for the variable.
     2. **Description**: Enter a description of the variable.
     3. **Variable type**: Select a type. The options are boolean, number, object, or string. To include an array of the variable type, enable the toggle next to **Is array**.
     4. **Default value**: Optionally enter a default value.
2. By default, your Workflow will be in draft mode. To publish the Workflow, toggle off the **Draft** setting at the top of the page.
   * When a Workflow is saved as a draft, it is only visible to users with the `Workflow edit` permission.
3. By default, a Workflow will be visible to all users in your organization who have permission to view Workflows. If you want to adjust view permissions for your Workflow:
   1. Click **Access** at the top of the page.
   2. Turn **off** the toggle for **Organization access**.
   3. Configure the users, teams, or roles who should have access to your Workflow.
      * In order for a user to run the Workflow, they must have the `Workflow runs execute` permission *and* they must match at least one of the users, teams, or roles that you specify here.
   4. Click **Apply**.

      <figure><img src="https://826863033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJW7pYRxS4dHS3Hv6wxve%2Fuploads%2Fgit-blob-5c2dba6c33e795e173910e721575299867d52af7%2Fworkflow-access.jpg?alt=media" alt=""><figcaption></figcaption></figure>
4. At the top of the page, click **Save workflow**.

### Step 3.1: Add blocks to your Workflow

Workflows are made of individual blocks, which are each responsible for a specific task when a Workflow is run. Cortex provides a [library of blocks](https://docs.cortex.io/streamline/workflows/blocks) to choose from, including core blocks, Cortex-based blocks, and integration-related blocks.

To add a block to your Workflow:

1. Click **+** in the Workflow visual in the center of the page.
2. Choose the type of block.

<div align="left"><figure><img src="https://826863033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJW7pYRxS4dHS3Hv6wxve%2Fuploads%2Fgit-blob-7d82d14fe53fe7b755a40ab01853b1a39d75f856%2Fadd-workflow-step.jpg?alt=media" alt="Click the + in the center of the Workflow page to start adding blocks."><figcaption><p>Click + to add a block</p></figcaption></figure></div>

### Step 3.2: Configure the blocks in your Workflow

For instructions specific to each type of block, see the [Blocks documentation](https://docs.cortex.io/streamline/workflows/blocks).

{% hint style="warning" %}
Note: The slug for each block must be unique across a Workflow.
{% endhint %}

#### Additional information on blocks

To learn about using request signing with blocks, duplicating a block, and templating a block, see the [Blocks documentation](https://docs.cortex.io/streamline/workflows/blocks).

For information on referencing previous blocks and Workflow states, see [Referencing Workflow state in a block](https://docs.cortex.io/streamline/workflows/blocks/states).

## Next step: Running a Workflow

To learn more, see [Running a Workflow](https://docs.cortex.io/streamline/workflows/run).
