> For the complete documentation index, see [llms.txt](https://guide.cryosparc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.cryosparc.com/processing-data/automated-workflows/launching-automated-workflows-using-scripts-v5.1+.md).

# Launching Automated Workflows using scripts (v5.1+)

[Automated Workflows](/processing-data/automated-workflows.md) in CryoSPARC provide a powerful mechanism for processing single particle cryo-EM data in an unattended fashion, making use of the CryoSPARC [Workflows](/application-guide/workflows.md) UI feature to streamline the creation, connection, and launching of jobs into a single click.

**In CryoSPARC v5.1**, Workflows can be created, edited, and launched programatically using the [CryoSPARC API](https://tools.cryosparc.com/api/cryosparc.api.html#), which allows workflows to be triggered automatically, for example when new data is available, or when a [CryoSPARC Live](/live/managing-a-cryosparc-live-session-from-the-cli-v5.0.md) session completes, etc.

### Connecting to the CryoSPARC API

The CryoSPARC API can be accessed in multiple ways, all [explained here](https://tools.cryosparc.com/api/cryosparc.api.html#module-cryosparc.api). The simplest way is to use the interactive CryoSPARC command line, which can be started on the CryoSPARC master node, by running `cryosparcm icli` . Once inside this interactive Python shell, you can type Python commands and execute them. You can also write Python scripts that use the API.

### Workflows API

The full documentation for the Workflows API can be [found here](https://tools.cryosparc.com/api/cryosparc.api.html#cryosparc.api.WorkflowsAPI). The API is simple to use, with a few Python examples given here:

#### List saved Workflows

```
workflows = api.workflows.find(limit=10)
for workflow in workflows:
    print(workflow.title)
```

#### Fetch a workflow

```
workflow = api.workflows.find(limit=10)[0]
workflow = api.workflows.find_one(workflow.id)
```

#### Apply a workflow

This example uses[ cryosparc-tools](https://tools.cryosparc.com/api/cryosparc.api.html#) to connect to the API.

```
from cryosparc.tools import CryoSPARC
from cryosparc.models.blueprint import BlueprintParameter
from cryosparc.models.workflow import ApplyWorkflowRequest, WorkflowParameter
from cryosparc.models.workspace import JobGroupCreate, JobGroupUpdate

cs = CryoSPARC("<https://cryosparc.example.com>")
api = cs.api

workflow = api.workflows.find(limit=10)[0]
workflow = api.workflows.find_one(workflow.id)
api.workflows.apply(
    ApplyWorkflowRequest(
        workflow=workflow,
        parent_juids=[],  # supply existing J-UIDs if the workflow has parents
        lane=None,        # set a lane name to enqueue created jobs
    ),
    project_uid="P1",
    workspace_uid="W1",
)
```

#### Change a parameter for a job in workflow that has been saved

```
api.workflows.set_job_param(
    workflow.id,
    "J1",                # workflow-local job ID, not a project J-UID
    "param_name",
    WorkflowParameter(value=42),
)
```
