---
title: "workflows.SubmitSubtasks"
description: "Submit multiple subtasks to the runner."
image: "https://tilebox.com/images/tilebox-docs-social-preview.png"
---

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

# workflows.SubmitSubtasks

import { Fragment } from "astro/jsx-runtime";

import ApiReference from "@docs/components/ApiReference.astro";

import ParamField from "@docs/components/ParamField.astro";

```go
workflows.SubmitSubtasks(
	ctx context.Context,
	tasks []workflows.Task,
	options ...subtask.SubmitOption,
) ([]subtask.FutureTask, error)
```

Submit multiple subtasks to the runner. Same as [SubmitSubtask](/docs/api-reference/go/workflows/SubmitSubtask), but accepts a list of tasks.

This function is intended to be used in tasks.

## Parameters

**tasks**

type: []Task

A list of tasks to submit
**options**

type: []subtask.SubmitOption

Options for the subtasks

## Options

**WithDependencies(dependencies ...FutureTask)**

Set dependencies for the tasks
**WithClusterSlug(clusterSlug string)**

default: cluster of the runner

Set the cluster slug of the cluster where the tasks will be executed.
**WithMaxRetries(maxRetries int64)**

default: 0

Set the maximum number of [retries](/docs/workflows/concepts/tasks#retry-handling) for the subtasks in case it fails
**WithOptional()**

default: false

Mark the subtasks as [optional](/docs/workflows/concepts/tasks#optional-tasks). Optional subtasks will not fail the job if they fail. Tasks that depend on them will still execute even if they failed.

## Returns

A list of future tasks that can be used to set dependencies between tasks.

<h2 id="request-example">Usage example</h2>

```go

type MySubTask struct {
	Sensor string
	Value  float64
}

type Task struct{}

func (t *Task) Execute(ctx context.Context) error {
	err := workflows.SubmitSubtasks(ctx, 
		[]workflows.Task{
			&MySubTask{
				Sensor: "A",
				Value:  42,
			},
			&MySubTask{
				Sensor: "B",
				Value:  42,
			}
		},
	)
	if err != nil {
		return fmt.Errorf("failed to submit subtasks: %w", err)
	}

	return nil
}
```

Source: https://tilebox.com/docs/api-reference/go/workflows/SubmitSubtasks/index.mdx
