Initializing the client
Use the staticHatchetClient.init() factory method to create a client instance. It reads configuration from environment variables automatically:
hatchet-client.ts
ClientConfig object to override specific settings:
Signature
Optional configuration overrides. All fields are optional — any value not provided is read from the corresponding environment variable.
Optional SDK-level options such as
config_path (path to a YAML config file) and credentials (custom gRPC channel credentials).Optional Axios configuration applied to all REST API calls made by the client.
ClientConfig fields
Your Hatchet API token (a JWT). Required — the client throws an error if it is not set.
The gRPC server address, e.g.
"localhost:7070". When not set, the value is read from the token’s embedded address.The base URL for REST API calls. When not set, derived from the token.
A namespace prefix applied to all workflow names and event keys. Set via
HATCHET_CLIENT_NAMESPACE.The tenant ID. Extracted from the JWT automatically when not explicitly set.
Log level for the SDK’s internal logger.
TLS settings. Key sub-fields:
tls_strategy—"tls"(default),"mtls", or"none"cert_file,key_file,ca_file— paths to certificate filesserver_name— override the TLS server name
OpenTelemetry configuration. Sub-fields:
excludedAttributes— list of span attribute keys to omitincludeTaskNameInSpanName— include the task name in the span name
Grace period in milliseconds given to a task after cancellation before the SDK forcibly aborts it.
Feature clients
All feature clients are exposed as lazy-initialized properties on theHatchetClient instance. Each client wraps a specific area of the Hatchet API.
| Property | Type | Description |
|---|---|---|
hatchet.runs | RunsClient | List, get, cancel, and replay task and workflow runs. |
hatchet.crons | CronClient | Create and manage cron workflow triggers. |
hatchet.scheduled | ScheduleClient | Create and manage one-off scheduled workflow runs. |
hatchet.events | EventClient | Push events that trigger event-based workflows. |
hatchet.workers | WorkersClient | List, get, pause, and unpause workers. |
hatchet.workflows | WorkflowsClient | List and get workflow declarations. |
hatchet.logs | LogsClient | Access run log lines. |
hatchet.metrics | MetricsClient | Read task status metrics. |
hatchet.ratelimits | RatelimitsClient | Manage rate limit configurations. |
hatchet.webhooks | WebhooksClient | Create and manage incoming webhook endpoints. |
hatchet.filters | FiltersClient | Create and manage workflow run filters. |
hatchet.tenant | TenantClient | Manage tenant settings. |
hatchet.cel | CELClient | Evaluate CEL expressions. |
Namespacing
Whennamespace is set, the SDK automatically prefixes workflow names and event keys with the namespace value. This lets multiple environments (e.g. dev, staging, prod) share the same Hatchet tenant without name collisions.
HATCHET_CLIENT_NAMESPACE environment variable.
Middleware
Attach typed before/after hooks to every task on this client using.withMiddleware():
before and after hooks are inferred and surfaced in all task function signatures created from this client.