# Standalone Activities Go quickstart

> Last updated: 2026-11-27.
> For the complete documentation index, see [llms.txt](https://docs.temporal.io/llms.txt).
> Any documentation page is available as raw Markdown by appending `.md` to its URL.
> For related questions, query `https://docs.temporal.io/api/retrieve?q=<question>&jtb=<job-to-be-done>&src=md-page&agent=<your-name>` (no auth; returns JSON `{content, source_url, page_url}`, with `source_url` pointing to Markdown for docs pages). Don't include personal data or credentials.
> If this page is wrong or missing something you needed, or Temporal behaves differently from what it says, report it with `https://docs.temporal.io/api/feedback?title=<summary>&message=<what-happened>&category=documentation&page_url=/develop/go/activities/standalone-activities-quickstart&src=md-page&agent=<your-name>` (use `category=product` when the product, not the page, is wrong). Report only a specific problem you hit, send it once, and don't include personal data or credentials.

> Execute a Standalone Activity with the Temporal Go SDK without writing a Workflow.

# Quickstart

Standalone Activities are Activity Executions that run independently, without being orchestrated by a Workflow. Instead
of starting an Activity from within a Workflow Definition using `workflow.ExecuteActivity()`, you start a Standalone
Activity directly from a Temporal Client using `client.ExecuteActivity()`.

The Activity definition and Worker registration are identical to regular Activities, and only the execution path
differs.

> **📝 Note:**
>
> This documentation uses source code from the
> [go-sandbox/activities/standalone](https://github.com/temporalio/documentation-sdk-code-examples/tree/main/go-sandbox/activities/standalone)
> sample.
>

## Get started with Standalone Activities 

Prerequisites:

- **[Go](https://go.dev/dl/)** 1.26+, the version the sample's `go.mod` requires

- **[Temporal Go SDK](/develop/go/set-up-your-local-go#install-the-temporal-go-sdk)** (v1.49.0 or higher)

- **Temporal CLI** v1.9.1 or higher. Install with Homebrew, or see the [Temporal CLI install guide](/cli/setup-cli) for other platforms. Verify the installation with `temporal --version`.

Start the Temporal development server with `temporal server start-dev`.

This command automatically starts the Temporal development server with the Web UI, and creates the `default` Namespace.
It uses an in-memory database, so do not use it for real use cases.

The Temporal Server should now be available for client connections on `localhost:7233`, and the
Temporal Web UI should now be accessible at [http://localhost:8233](http://localhost:8233).

```bash
brew install temporal
```

```bash
temporal --version
```

```bash
temporal server start-dev
```

## Clone the sample

Clone the [documentation-sdk-code-examples](https://github.com/temporalio/documentation-sdk-code-examples) repository
and switch to the `go-sandbox` directory to follow along.
Run every command on this page from that directory.

```bash
git clone https://github.com/temporalio/documentation-sdk-code-examples.git
cd documentation-sdk-code-examples/go-sandbox
```

The sample is structured as follows:

```
activities/standalone/
├── activity.go
├── worker/
│   └── main.go
└── starter/
    └── main.go
```

<!--SNIPSTART go-standalone-activity-quickstart-activity-->
[go-sandbox/activities/standalone/activity.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/activity.go)
```go
package standalone

import (
	"context"
	"fmt"
)

const (
	TaskQueue  = "standalone-activity-helloworld"
	ActivityID = "standalone_activity_helloworld_ActivityID"
)

func Activity(ctx context.Context, name string) (string, error) {
	return fmt.Sprintf("Hello %s!", name), nil
}
```
<!--SNIPEND-->

## Define your Activity 

Define your Activity in a shared package so that both the Worker and the starter can reference it.
The package also holds the Task Queue name and Activity ID that the Worker and the starter use.

<!--SNIPSTART go-standalone-activity-quickstart-worker-->
[go-sandbox/activities/standalone/worker/main.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/worker/main.go)
```go
package main

import (
	"log"

	"go.temporal.io/sdk/client"
	"go.temporal.io/sdk/contrib/envconfig"
	"go.temporal.io/sdk/worker"

	"my-org/quickstart/activities/standalone"
)

func main() {
	c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
	if err != nil {
		log.Fatalln("Unable to create client", err)
	}
	defer c.Close()

	// Registering a Standalone Activity is the same as registering any other Activity.
	w := worker.New(c, standalone.TaskQueue, worker.Options{})
	w.RegisterActivity(standalone.Activity)

	if err := w.Run(worker.InterruptCh()); err != nil {
		log.Fatalln("Unable to start Worker", err)
	}
}
```
<!--SNIPEND-->

```bash
go run ./activities/standalone/worker
```

## Run a Worker with the Activity registered 

Running a Worker for Standalone Activities is the same as running a Worker for Workflow-driven Activities — you create a
Worker, register the Activity, and call `Run()`. The Worker doesn't need to know whether the Activity will be invoked
from a Workflow or as a Standalone Activity.

See [Develop a Worker in Go](/develop/go/workers/run-worker-process#develop-worker) for more details on Worker setup and
configuration options.

Open a new terminal, switch to the `go-sandbox` directory, and run the Worker.
Leave this terminal running - the Worker needs to stay up to process Activities.

<!--SNIPSTART go-standalone-activity-quickstart-execute-->
[go-sandbox/activities/standalone/starter/main.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/starter/main.go)
```go
options := client.StartActivityOptions{
	ID:                  standalone.ActivityID,
	TaskQueue:           standalone.TaskQueue,
	StartToCloseTimeout: 10 * time.Second,
}

handle, err := c.ExecuteActivity(context.Background(), options, standalone.Activity, "Temporal")
if err != nil {
	log.Fatalln("Unable to execute activity", err)
}
log.Println("Started Standalone Activity", "ActivityID", handle.GetID(), "RunID", handle.GetRunID())
```
<!--SNIPEND-->

<!--SNIPSTART go-standalone-activity-get-result-->
[go-sandbox/activities/standalone/starter/main.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/starter/main.go)
```go
var result string
err = handle.Get(context.Background(), &result)
if err != nil {
	log.Fatalln("Activity failed", err)
}
log.Println("Activity result:", result)
```
<!--SNIPEND-->

```bash
go run ./activities/standalone/starter
```

```bash
temporal activity execute \\
  --type Activity \\
  --activity-id standalone_activity_helloworld_ActivityID \\
  --task-queue standalone-activity-helloworld \\
  --start-to-close-timeout 10s \\
  --input '"Temporal"'
```

## Execute a Standalone Activity 

Use [`client.ExecuteActivity()`](https://pkg.go.dev/go.temporal.io/sdk/client#Client) to start a Standalone Activity
Execution. This is called from application code (for example, a starter program), not from inside a Workflow Definition.

`ExecuteActivity` returns an [`ActivityHandle`](https://pkg.go.dev/go.temporal.io/sdk/client#ActivityHandle) that you
can use to get the result, describe, cancel, or terminate the Activity.
The starter calls `handle.Get()` to wait for the Activity to finish and read its result.

`client.StartActivityOptions` requires `ID`, `TaskQueue`, and at least one of `ScheduleToCloseTimeout` or
`StartToCloseTimeout`. See [`StartActivityOptions`](https://pkg.go.dev/go.temporal.io/sdk/client#StartActivityOptions)
in the API reference for the full set of options.

To run the starter:

1. Make sure the Temporal Server is running (from the [Get Started](#get-started) step above).
2. Make sure the Worker is running (from the [Run a Worker](#run-worker) step above).
3. Open a new terminal, switch to the `go-sandbox` directory, and run:
    ```
    go run ./activities/standalone/starter
    ```

The last line of output shows the result:

```
Activity result: Hello Temporal!
```

Or use the Temporal CLI to execute a Standalone Activity.

<!--SNIPSTART go-standalone-activity-quickstart-execute-by-name-->
[go-sandbox/activities/standalone/starter/main.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/starter/main.go)
```go
handle, err := c.ExecuteActivity(context.Background(), options, "Activity", "Temporal")
```
<!--SNIPEND-->

```bash
go run ./activities/standalone/starter -command start-by-name
```

## Execute a Standalone Activity by type name 

You can pass the Activity to `ExecuteActivity` as a function reference, as in the previous step, or as a string
Activity type name.
Use the type name when the code that starts the Activity can't import the Activity function, for example when the
Activity is written in another language.

The type name of a Go Activity registered with `RegisterActivity` is the function name, `Activity` in this sample.

<!--SNIPSTART go-standalone-activity-list-->
[go-sandbox/activities/standalone/starter/main.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/starter/main.go)
```go
resp, err := c.ListActivities(context.Background(), client.ListActivitiesOptions{
	Query: "TaskQueue = 'standalone-activity-helloworld'",
})
if err != nil {
	log.Fatalln("Unable to list activities", err)
}

for info, err := range resp.Results {
	if err != nil {
		log.Fatalln("Error iterating activities", err)
	}
	log.Printf("ActivityID: %s, Type: %s, Status: %v\n",
		info.ActivityID, info.ActivityType, info.Status)
}
```
<!--SNIPEND-->

<!--SNIPSTART go-standalone-activity-count-->
[go-sandbox/activities/standalone/starter/main.go](https://github.com/temporalio/documentation-sdk-code-examples/blob/main/go-sandbox/activities/standalone/starter/main.go)
```go
resp, err := c.CountActivities(context.Background(), client.CountActivitiesOptions{
	Query: "TaskQueue = 'standalone-activity-helloworld'",
})
if err != nil {
	log.Fatalln("Unable to count activities", err)
}

log.Println("Total activities:", resp.Count)
```
<!--SNIPEND-->

```bash
go run ./activities/standalone/starter -command list
```

```bash
go run ./activities/standalone/starter -command count
```

## List and count Standalone Activities 

Use [`client.ListActivities()`](https://pkg.go.dev/go.temporal.io/sdk/client#Client) and
[`client.CountActivities()`](https://pkg.go.dev/go.temporal.io/sdk/client#Client) to find and count the Standalone
Activity Executions that match a [List Filter](/list-filter) query.
These APIs return only Standalone Activity Executions. Activities running inside Workflows are not included.

Run the starter with `-command list` to list the Activities on the sample's Task Queue, and with `-command count` to
count them.
See [List Standalone Activities](/develop/go/activities/standalone-activities#list-activities) in the feature guide for
more about the query syntax.

## Run with Temporal Cloud

All code samples on this page use
[`envconfig.MustLoadDefaultClientOptions()`](https://pkg.go.dev/go.temporal.io/sdk/contrib/envconfig)
to configure the Temporal Client connection. It responds to [environment
variables](/references/client-environment-configuration) and [TOML configuration
files](/references/client-environment-configuration), so the same code works against a local dev
server and Temporal Cloud without changes. See [Run Standalone Activities with Temporal
Cloud](/develop/go/activities/standalone-activities#run-standalone-activities-temporal-cloud) in the feature guide
for mTLS and API key setup.

## Next steps

- **[Standalone Activities feature guide](/develop/go/activities/standalone-activities)**: Get results, Activity handles, list and count Activities, and connect to Temporal Cloud.
- **[Build a Job Queue with Standalone Activities](https://learn.temporal.io/tutorials/go/standalone-activities/)**: Tutorial that builds a durable job queue, with idempotency keys, server-side deduplication, throughput limits, [Priority and Fairness](/develop/task-queue-priority-fairness), and heartbeat checkpoints.
- **[Activity basics](/develop/go/activities/basics)**: Write and register Activities with the Go SDK.
