Hatchet TypeScript SDK Reference
This is the TypeScript SDK reference, documenting methods available for interacting with Hatchet resources. Check out the user guide for an introduction to getting your first tasks running.
HatchetClient
HatchetV1 implements the main client interface for interacting with the Hatchet workflow engine. It provides methods for creating and executing workflows, as well as managing workers.
Implements
IHatchetClient
Properties
| Property | Type | Description |
|---|---|---|
tenantId | string | The tenant ID for the Hatchet client |
Accessors
api
Get Signature
Get the API client for making HTTP requests to the Hatchet API Note: This is not recommended for general use, but is available for advanced scenarios
Returns
Api<unknown>
A API client instance
crons
Get Signature
Get the cron client for creating and managing cron workflow runs
Returns
A cron client instance
Implementation of
IHatchetClient.crons;events
Get Signature
Get the event client for creating and managing event workflow runs
Returns
EventClient
A event client instance
Implementation of
IHatchetClient.events;filters
Get Signature
Get the filters client for creating and managing filters
Returns
A filters client instance
Implementation of
IHatchetClient.filters;logs
Get Signature
Get the logs client for creating and managing logs
Returns
A logs client instance
Implementation of
IHatchetClient.logs;metrics
Get Signature
Get the metrics client for creating and managing metrics
Returns
A metrics client instance
Implementation of
IHatchetClient.metrics;ratelimits
Get Signature
Get the rate limits client for creating and managing rate limits
Returns
A rate limits client instance
Implementation of
IHatchetClient.ratelimits;runs
Get Signature
Get the runs client for creating and managing runs
Returns
A runs client instance
Implementation of
IHatchetClient.runs;scheduled
Get Signature
Get the schedules client for creating and managing scheduled workflow runs
Returns
A schedules client instance
Implementation of
IHatchetClient.scheduled;schedules
Get Signature
Alias
scheduled
Returns
tasks
Get Signature
Get the tasks client for creating and managing tasks
Returns
A tasks client instance
tenant
Get Signature
Get the tenant client for managing tenants
Returns
TenantClient
A tenant client instance
Implementation of
IHatchetClient.tenant;webhooks
Get Signature
Get the webhooks client for creating and managing webhooks
Returns
A webhooks client instance
Implementation of
IHatchetClient.webhooks;workers
Get Signature
Get the workers client for creating and managing workers
Returns
A workers client instance
Implementation of
IHatchetClient.workers;workflows
Get Signature
Get the workflows client for creating and managing workflows
Returns
A workflows client instance
Implementation of
IHatchetClient.workflows;Methods
durableTask()
Implementation of the durableTask method.
Creates a new durable task workflow. Types can be explicitly specified as generics or inferred from the function signature.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | CreateDurableTaskWorkflowOpts<I & Resolved<GlobalInput, MiddlewareBefore>, MergeIfNonEmpty<O, GlobalOutput>> | Durable task configuration options |
Returns
TaskWorkflowDeclaration<I, O, GlobalInput, GlobalOutput, MiddlewareBefore, MiddlewareAfter>
A TaskWorkflowDeclaration instance for a durable task
Creates a new durable task workflow with types inferred from the function parameter.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | object & Omit<CreateDurableTaskWorkflowOpts<I, O>, "fn"> | Durable task configuration options with function that defines types |
Returns
TaskWorkflowDeclaration<I, O, GlobalInput, GlobalOutput, MiddlewareBefore, MiddlewareAfter>
A TaskWorkflowDeclaration instance with inferred types
run()
Triggers a workflow run and waits for the result.
Parameters
| Parameter | Type | Description |
|---|---|---|
workflow | string | Workflow | BaseWorkflowDeclaration<I, O> | The workflow to run, either as a Workflow instance or workflow name |
input | I | The input data for the workflow |
options | RunOpts | Configuration options for the workflow run |
Returns
Promise<O>
A promise that resolves with the workflow result
runAndWait()
Triggers a workflow run and waits for the result.
Parameters
| Parameter | Type | Description |
|---|---|---|
workflow | string | Workflow | BaseWorkflowDeclaration<I, O> | The workflow to run, either as a Workflow instance or workflow name |
input | I | The input data for the workflow |
options | RunOpts | Configuration options for the workflow run |
Returns
Promise<O>
A promise that resolves with the workflow result
Alias
run
runNoWait()
Triggers a workflow run without waiting for completion.
Parameters
| Parameter | Type | Description |
|---|---|---|
workflow | string | Workflow | BaseWorkflowDeclaration<I, O> | The workflow to run, either as a Workflow instance or workflow name |
input | I | The input data for the workflow |
options | RunOpts | Configuration options for the workflow run |
Returns
Promise<WorkflowRunRef<O>>
A WorkflowRunRef containing the run ID and methods to interact with the run
task()
Implementation of the task method.
Creates a new task workflow. Types can be explicitly specified as generics or inferred from the function signature.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | CreateTaskWorkflowOpts<I & Resolved<GlobalInput, MiddlewareBefore>, MergeIfNonEmpty<O, GlobalOutput>> | Task configuration options |
Returns
TaskWorkflowDeclaration<I, O, GlobalInput, GlobalOutput, MiddlewareBefore, MiddlewareAfter>
A TaskWorkflowDeclaration instance
Creates a new task workflow with types inferred from the function parameter.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | object & Omit<CreateTaskWorkflowOpts<I, O>, "fn"> | Task configuration options with function that defines types |
Returns
TaskWorkflowDeclaration<I, O, GlobalInput, GlobalOutput, MiddlewareBefore, MiddlewareAfter>
A TaskWorkflowDeclaration instance with inferred types
worker()
Creates a new worker instance for processing workflow tasks.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | - |
options? | number | CreateWorkerOpts | Configuration options for creating the worker |
Returns
Promise<Worker>
A promise that resolves with a new HatchetWorker instance
workflow()
Creates a new workflow definition.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | CreateWorkflowOpts | Configuration options for creating the workflow |
Returns
WorkflowDeclaration<I, O, Resolved<GlobalInput, MiddlewareBefore>>
A new Workflow instance
Note
It is possible to create an orphaned workflow if no client is available using @hatchet/client CreateWorkflow