Workflows SDK for TypeScript
Usage and symbol reference
Render Workflows is in public beta.
During the beta, bugs or changes in API/SDK behavior are possible as we continue refining the product. We welcome any and all feedback at workflows-feedback@render.com.
The Render SDK for TypeScript provides support for:
- Defining workflow tasks
- Triggering runs of those tasks from your other TypeScript code
Install
From your TypeScript project directory:
(Or pnpm install, bun add, etc.)
If you already have the SDK installed, make sure you're using version ^0.5.0 or later:
After installing, make sure @renderinc/sdk is listed as a dependency in your package.json file at version ^0.5.0 or later.
Defining tasks
The following symbols pertain to creating and registering tasks in your workflow service. For guidance on how to use them, see Defining Workflow Tasks.
The task() function
task(options, func)
Use task() to register a provided function (func) as a workflow task with the specified options.
On success: Returns a wrapped function with the same signature as func. Calling this function from another task's execution context triggers a chained run and returns a Promise for the chained run's result.
| Argument | Description |
|---|---|
|
Function parameters | |
|
Required. An object containing configuration details for the task. Only |
|
Required. The function to register as a task. |
|
Supported | |
|
Required. The task's name. This affects the task's slug, which you use to reference the task when triggering runs. This value is not required to match the name of the function you provide as |
|
An object containing retry settings for the task. See all supported settings below. |
|
The timeout for the task's runs, in seconds. Must be between 30 seconds ( The default value is 2 hours. |
|
The default instance type to use for the task's runs. Supported values:
You can request access to the following larger instance types for your workspace:
The default value is |
|
Retry settings | |
|
The maximum number of retries to attempt for a given run of the task. The total number of attempts is up to |
|
The base delay before attempting the first retry, in milliseconds. |
|
The exponential backoff factor. After each retry, the previous delay is multiplied by this factor. For example, a factor of
|
Triggering runs
Use the Render class to trigger and manage task runs from other TypeScript services, apps, or scripts. For end-to-end usage guidance, see Triggering Task Runs.
The Render class
Constructor
Render(options)
Initializes a Render SDK client.
| Option | Description |
|---|---|
|
The API key to use for authentication. If omitted, the client automatically detects and uses the value of the |
Task methods
These methods are available on the workflows attribute of a Render object.
startTask(taskIdentifier, inputData, signal)
Kicks off a run of the registered task with the specified identifier, passing the specified arguments.
To instead run a task and wait for it to complete, use workflows.runTask.
On success: Returns a TaskRunResult object representing the started run. You can await the run's result by calling .get() on this object.
Throws: ClientError, ServerError, AbortError
| Argument | Description |
|---|---|
|
Required. The slug indicating the task to run, available from your task's page in the Render Dashboard:
Always has the format |
|
Required. An array containing the task's input arguments.. Elements are positional based on the task's function signature. For a task that takes zero arguments, provide an empty array, |
|
An optional For details, see Canceling operations with |
runTask(taskIdentifier, inputData, signal)
Starts the registered task with the specified identifier, waits for it to complete, and returns the result.
To instead kick off a run without waiting for it to complete, use workflows.startTask.
On success: Returns a TaskRunDetails object for the completed task run.
Throws: ClientError, ServerError, AbortError
| Argument | Description |
|---|---|
|
Required. The slug indicating the task to run, available from your task's page in the Render Dashboard:
Always has the format |
|
Required. An array containing the task's input arguments.. Elements are positional based on the task's function signature. For a task that takes zero arguments, provide an empty array, |
|
An optional For details, see Canceling operations with |
listTaskRuns(params)
Lists task runs that match optional filters.
On success: Returns an array of TaskRun objects.
Throws: ClientError, ServerError
Supported fields on params include:
| Parameter | Description |
|---|---|
|
An integer specifying the maximum number of task runs to return. |
|
A cursor string for pagination. Use this to retrieve the next page of results. |
|
A list of task identifiers to filter results by. Only task runs for these tasks will be returned. |
|
A list of root task run IDs to filter results by. Only runs in these execution chains will be returned. |
|
A list of workspace IDs to filter results by. Only task runs from these workspaces will be returned. |
|
A list of workflow version IDs to filter results by. |
|
A list of workflow IDs to filter results by. |
getTaskRun(taskRunId)
Retrieves the details of the task run with the specified ID.
On success: Returns a TaskRunDetails object.
Throws: ClientError, ServerError
| Argument | Description |
|---|---|
|
Required. The ID of the task run to retrieve. Has the format |
cancelTaskRun(taskRunId)
Cancels the task run with the specified ID. This raises a ClientError if the task run is not found, or if it is not currently running.
On success: Returns void.
Throws: ClientError, ServerError
| Argument | Description |
|---|---|
|
Required. The ID of the task run to cancel. Has the format |
taskRunEvents(taskRunIds, signal)
Streams completion events for one or more task runs via Server-Sent Events (SSE). Returns an async iterator that yields a TaskRunDetails object each time a specified task run reaches a terminal status.
The connection stays open until all events are received, you break out of the loop, or the stream is aborted.
Throws: ClientError, ServerError, AbortError
| Argument | Description |
|---|---|
|
Required. A list of task run IDs to stream events for. Each ID has the format |
|
Optional For details, see Canceling operations with |
The TaskRunResult class
Represents a started task run before completion.
You typically obtain a TaskRunResult from workflows.startTask.
Properties and methods
| Member | Description |
|---|---|
|
The started task run's ID, available immediately. |
|
Waits for completion and returns a The first call starts waiting; subsequent calls return the same Promise. |
Canceling operations with AbortSignal
The startTask, runTask, and taskRunEvents methods each accept an optional AbortSignal parameter. You can use this to terminate the corresponding method call if it's no longer needed (for example, to enforce a frontend timeout or respond to a user-initiated cancellation).
When a signal is passed to startTask, it applies to both the initial HTTP request and any subsequent wait via TaskRunResult.get(). This means a single AbortController can cancel the full lifecycle of starting a task and waiting for its result.
Terminating a client-side method call does not cancel any corresponding task runs. Runs continue executing on Render until they complete, time out, or are canceled with workflows.cancelTaskRun.
Additional types
The TaskRun type
Summarizes the state of a task run. Obtained in one of the following ways:
- From the
workflows.listTaskRunsmethod
To get a run's full details including results, call workflows.getTaskRun with the run's ID to obtain a TaskRunDetails object.
Properties
| Property | Description |
|---|---|
|
The ID of the task run. Has the format |
|
The ID of the run's associated task. Has the format |
|
The current status of the task run (e.g., |
|
The timestamp when the task run started executing. Not present if |
|
The timestamp when the task run finished (successfully or otherwise). Present only if |
|
The ID of this run's parent run, if this run was chained. For a root-level run, this value is the root run's ID or empty. |
|
The ID of the root task run in this run's execution chain. For a root-level run, this value matches |
|
The number of times the task run has retried so far. For a newly started run, this is typically |
|
An array of |
The TaskRunDetails type
Provides the full details of a task run. Obtained in one of the following ways:
-
Calling the
workflows.runTaskmethod: -
Calling
.get()on aTaskRunResultreturned byworkflows.startTask: -
Calling the
workflows.getTaskRunmethod: -
Iterating over events from the
workflows.taskRunEventsmethod:
Properties
A TaskRunDetails object includes all of the same properties as a TaskRun object, plus:
| Property | Description |
|---|---|
|
An array containing the task's return value(s). This value is always an empty array if |
|
The argument values that were passed to the task run, as an array matching the positional arguments of the task's function signature. |
|
The error message if the task run failed. Present only if |
|
An array of |
The ListTaskRunsParams type
Represents the query object passed to workflows.listTaskRuns. See the listTaskRuns reference for descriptions of each supported field.
Fields include limit, cursor, taskId, rootTaskRunId, ownerId, workflowVersionId, and workflowId.
Error types
Errors raised by the SDK have one of the types listed below. RenderError is the parent class for ClientError and ServerError. AbortError is a separate error type.
| Error | Description |
|---|---|
|
The base class for all errors raised by the SDK. |
|
Raised when a request to the Render API returns a 400-level error code. Common causes include:
|
|
Raised when a request to the Render API returns a 500-level error code. |
|
Raised when an SDK operation is canceled with an |
