Skip to main content

What is a Temporal Client?

A Temporal Client allows you to communicate with the Temporal Service. Communication with a Temporal Service lets you perform actions such as starting Workflow Executions, sending Signals to Workflow Executions, sending Queries to Workflow Executions, getting the results of a Workflow Execution, and providing Activity Task Tokens. When Standalone Activities are supported and enabled, a Temporal Client can also start and manage Standalone Activities directly, without involving a Workflow.

Code examples

The following examples show how to connect a Temporal Client to a local development Temporal Service.

Use the envconfig package to set connection options for the Temporal Client using environment variables. For a list of all available environment variables and their default values, refer to Environment Configuration.

For example, the following code snippet loads all environment variables and creates a Temporal Client with the options specified in those variables. If you have defined a configuration file at either the default location (~/.config/temporalio/temporal.toml) or a custom location specified by the TEMPORAL_CONFIG_FILE environment variable, this will also load the default profile in the configuration file. However, any options set via environment variables will take precedence.

package main

import (
"fmt"
"log"

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

func main() {
// Loads the "default" profile from the standard location and environment variables.
c, err := client.Dial(envconfig.MustLoadDefaultClientOptions())
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
defer c.Close()

fmt.Printf("✅ Connected to Temporal namespace %q on %s\n", c.Options().Namespace, c.Options().HostPort)
}

SDK guides