We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

ReferenceTypescript SDKClient

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

PropertyTypeDescription
tenantIdstringThe 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

CronClient

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

FiltersClient

A filters client instance

Implementation of

IHatchetClient.filters;
logs

Get Signature

Get the logs client for creating and managing logs

Returns

LogsClient

A logs client instance

Implementation of

IHatchetClient.logs;
metrics

Get Signature

Get the metrics client for creating and managing metrics

Returns

MetricsClient

A metrics client instance

Implementation of

IHatchetClient.metrics;
ratelimits

Get Signature

Get the rate limits client for creating and managing rate limits

Returns

RatelimitsClient

A rate limits client instance

Implementation of

IHatchetClient.ratelimits;
runs

Get Signature

Get the runs client for creating and managing runs

Returns

RunsClient

A runs client instance

Implementation of

IHatchetClient.runs;
scheduled

Get Signature

Get the schedules client for creating and managing scheduled workflow runs

Returns

ScheduleClient

A schedules client instance

Implementation of

IHatchetClient.scheduled;
schedules

Get Signature

Alias

scheduled

Returns

ScheduleClient

tasks

Get Signature

Get the tasks client for creating and managing tasks

Returns

WorkflowsClient

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

WebhooksClient

A webhooks client instance

Implementation of

IHatchetClient.webhooks;
workers

Get Signature

Get the workers client for creating and managing workers

Returns

WorkersClient

A workers client instance

Implementation of

IHatchetClient.workers;
workflows

Get Signature

Get the workflows client for creating and managing workflows

Returns

WorkflowsClient

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

ParameterTypeDescription
optionsCreateDurableTaskWorkflowOpts<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

ParameterTypeDescription
optionsobject & 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

ParameterTypeDescription
workflowstring | Workflow | BaseWorkflowDeclaration<I, O>The workflow to run, either as a Workflow instance or workflow name
inputIThe input data for the workflow
optionsRunOptsConfiguration 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

ParameterTypeDescription
workflowstring | Workflow | BaseWorkflowDeclaration<I, O>The workflow to run, either as a Workflow instance or workflow name
inputIThe input data for the workflow
optionsRunOptsConfiguration 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

ParameterTypeDescription
workflowstring | Workflow | BaseWorkflowDeclaration<I, O>The workflow to run, either as a Workflow instance or workflow name
inputIThe input data for the workflow
optionsRunOptsConfiguration 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

ParameterTypeDescription
optionsCreateTaskWorkflowOpts<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

ParameterTypeDescription
optionsobject & 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

ParameterTypeDescription
namestring-
options?number | CreateWorkerOptsConfiguration options for creating the worker

Returns

Promise<Worker>

A promise that resolves with a new HatchetWorker instance

workflow()

Creates a new workflow definition.

Parameters

ParameterTypeDescription
optionsCreateWorkflowOptsConfiguration 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