Fetching & Recreating
Starting Tasks covers the handle you get back when you start a task. This page covers the two things you do with a task you did not just start — read it, or run it again.
Fetching a task by ID
Section titled “Fetching a task by ID”import { getTask } from '@requence/task'
const task = await getTask('some-task-id')// or: getTask({ taskId: 'some-task-id', accessToken: '...' })
task.status // 'SUCCESSFUL' | 'FAILED' | 'IDLE' | 'PENDING' | 'RUNNING' // | 'STOPPED' | 'AWAITING_DELIVERY'task.statusText // Human-readable status description, if anytask.taskTemplate // The task template nametask.name // Human-readable task nametask.branch // 'live' or a branch name
task.context.input // The task's inputtask.context.result // The task's result (if finished)task.context.getNodeData(alias) // Output from a specific nodetask.context.getNodeError(alias) // Error from a specific nodeget_task returns a (status, context) tuple, and its statuses are lower-case:
from requence.task import get_task
status, context = get_task("some-task-id")# or: get_task("some-task-id", access_token="...")
# status: 'successful' | 'failed' | 'idle' | 'pending' | 'running' | 'stopped'print(status)print(context["input"])print(context["result"])print(context["node_data"].get("my_alias"))print(context["node_error"].get("my_alias"))This is a one-shot read, not a subscription. To follow a task as it runs, use Streaming Updates or Watching Tasks.
Recreating a task
Section titled “Recreating a task”Re-run an existing task with the same template and input. Name and priority may be overridden; everything else is taken from the original.
import { recreateTask } from '@requence/task'
const task = await recreateTask({ taskId: 'some-task-id', name: 'My Retry', // Optional — overrides the original name priority: 3, // Optional — overrides the original priority})
const result = await taskYou get back a task handle, exactly as createTask returns one, so it streams and awaits
the same way.