Skip to main content
The TasksResource class is the primary way to manage Figranium tasks through the JavaScript SDK. Use it to list, create, update, version, and run tasks, as well as to generate selectors and scripts with AI assistance. Every method is typed against the Figranium API and accepts an optional RequestOptions object as its final argument.
The client-level convenience figranium.runTask(id, input?) proxies directly to figranium.tasks.run(id, input?).

Methods

Retrieve every task in the workspace.
  • HTTP endpoint: GET /api/tasks
  • Signature: list(options?: RequestOptions): Promise<Task[]>
list-tasks.ts
Returns an array of Task objects.
Fetch a lightweight summary of all tasks.
  • HTTP endpoint: GET /api/tasks/list
  • Signature: listSummaries(options?: RequestOptions): Promise<{ tasks: TaskSummary[] }>
list-summaries.ts
Each TaskSummary contains id, name, and an optional description.
Create or update a task. Pass createVersion: true to snapshot the current version before saving.
  • HTTP endpoint: POST /api/tasks (with ?version=true when createVersion is set)
  • Signature: save(task: Task, options?: RequestOptions & { createVersion?: boolean }): Promise<Task>
save-task.ts
Returns the saved Task, including any server-generated id.
Refresh a task’s last_opened timestamp without changing its definition.
  • HTTP endpoint: POST /api/tasks/:id/touch
  • Signature: touch(id: string, options?: RequestOptions): Promise<Task>
touch-task.ts
Apply a partial patch to an existing task.
  • HTTP endpoint: PATCH /api/tasks/:id
  • Signature: update(id: string, patch: Partial<Task>, options?: RequestOptions): Promise<{ id: string; updatedAt: number; status: string; task: Task }>
update-task.ts
Remove a task by ID.
  • HTTP endpoint: DELETE /api/tasks/:id
  • Signature: delete(id: string, options?: RequestOptions): Promise<{ id: string; deleted: boolean; message?: string }>
delete-task.ts
List all saved versions for a task.
  • HTTP endpoint: GET /api/tasks/:id/versions
  • Signature: versions(id: string, options?: RequestOptions): Promise<{ versions: TaskVersion[] }>
list-versions.ts
Retrieve a specific version snapshot.
  • HTTP endpoint: GET /api/tasks/:id/versions/:versionId
  • Signature: version(id: string, versionId: string, options?: RequestOptions): Promise<{ snapshot: Task; metadata: { id: string; timestamp: number } }>
get-version.ts
Delete all stored versions for a task.
  • HTTP endpoint: POST /api/tasks/:id/versions/clear
  • Signature: clearVersions(id: string, options?: RequestOptions): Promise<{ success: boolean }>
clear-versions.ts
Restore a task to a previous version snapshot.
  • HTTP endpoint: POST /api/tasks/:id/rollback
  • Signature: rollback(id: string, versionId: string, options?: RequestOptions): Promise<Task>
rollback-task.ts
Use AI to generate a CSS selector for a specific action inside a task.
  • HTTP endpoint: POST /api/tasks/generate-selector
  • Signature: generateSelector(input: { task: Task; actionIndex: number; prompt: string }, options?: RequestOptions): Promise<{ selector: string }>
generate-selector.ts
Generate a JavaScript extraction script from a natural language description.
  • HTTP endpoint: POST /api/tasks/generate-script
  • Signature: generateScript(description: string, options?: RequestOptions): Promise<{ script: string }>
generate-script.ts
Execute a task and return its result. This is the public execution endpoint, reachable at /tasks/:id/api.
  • HTTP endpoint: POST /tasks/:id/api
  • Signature: run<T = unknown>(id: string, input?: ExecuteTaskOptions, options?: RequestOptions): Promise<ExecutionResult<T>>
run-task.ts
The generic T parameter types result.data. The input object accepts variables, taskVariables, webhookUrl, and runId. For more about execution results and streaming, see ExecutionsResource. To learn about task variables and runtime substitution, see Variables and Actions.