Skip to main content
The TasksResource on the Figranium Swift SDK is the primary way to manage tasks. Use it to list, create, update, version, and run tasks. Every method is async throws and accepts an optional options parameter for per-request overrides such as custom headers or timeouts. The client-level convenience client.runTask(id:input:options:) proxies directly to client.tasks.run(id:input:options:).
TasksResource.swift
The SDK’s model type Task shadows Swift’s concurrency Task. Use Swift.Task { } or Figranium.Task to disambiguate when necessary.

Methods

Retrieve every task in the workspace.
  • HTTP endpoint: GET /api/tasks
  • Signature: func list(options: RequestOptions = .init()) async throws -> [Task]
list_tasks.swift
Returns an array of Task structs.
Fetch a lightweight summary of all tasks.
  • HTTP endpoint: GET /api/tasks/list
  • Signature: func listSummaries(options: RequestOptions = .init()) async throws -> [TaskSummary]
list_summaries.swift
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: func save(_ task: Task, createVersion: Bool = false, options: RequestOptions = .init()) async throws -> Task
save_task.swift
Returns the saved Task, including any server-generated id. For more about building actions, see Actions. For variable substitution, see Variables.
Refresh a task’s last_opened timestamp without changing its definition.
  • HTTP endpoint: POST /api/tasks/{id}/touch
  • Signature: func touch(_ id: String, options: RequestOptions = .init()) async throws -> Task
touch_task.swift
Apply a partial patch to an existing task.
  • HTTP endpoint: PATCH /api/tasks/{id}
  • Signature: func update(_ id: String, patch: JSONObject, options: RequestOptions = .init()) async throws -> JSONObject
update_task.swift
Remove a task by ID.
  • HTTP endpoint: DELETE /api/tasks/{id}
  • Signature: func delete(_ id: String, options: RequestOptions = .init()) async throws -> JSONObject
delete_task.swift
List all saved versions for a task.
  • HTTP endpoint: GET /api/tasks/{id}/versions
  • Signature: func versions(_ id: String, options: RequestOptions = .init()) async throws -> [TaskVersion]
list_versions.swift
Retrieve a specific version snapshot.
  • HTTP endpoint: GET /api/tasks/{id}/versions/{versionId}
  • Signature: func version(_ id: String, versionID: String, options: RequestOptions = .init()) async throws -> JSONObject
get_version.swift
Delete all stored versions for a task.
  • HTTP endpoint: POST /api/tasks/{id}/versions/clear
  • Signature: func clearVersions(_ id: String, options: RequestOptions = .init()) async throws -> JSONObject
clear_versions.swift
Restore a task to a previous version snapshot.
  • HTTP endpoint: POST /api/tasks/{id}/rollback
  • Signature: func rollback(_ id: String, versionID: String, options: RequestOptions = .init()) async throws -> Task
rollback_task.swift
Generate a CSS selector for a task action using an AI prompt.
  • HTTP endpoint: POST /api/tasks/generate-selector
  • Signature: func generateSelector(task: Task, actionIndex: Int, prompt: String, options: RequestOptions = .init()) async throws -> String
generate_selector.swift
Returns the generated CSS selector string.
Generate a JavaScript extraction script from a description.
  • HTTP endpoint: POST /api/tasks/generate-script
  • Signature: func generateScript(_ description: String, options: RequestOptions = .init()) async throws -> String
generate_script.swift
Returns the generated script string.
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: func run<Value: Codable & Sendable>(_ id: String, input: ExecuteTaskOptions = .init(), options: RequestOptions = .init()) async throws -> ExecutionResult<Value>
run_task.swift
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. For per-request overrides, see RequestOptions.