WHAT YOU'LL LEARN
  • What methods are available on sdk.tasks?
  • What parameters each method accepts?
  • What each method returns?
BACKGROUND TASKS

See Background Tasks for a guide on creating and managing background tasks.

Overview
anchor

The TasksSdk is accessed via sdk.tasks on a Webiny instance. It provides methods for triggering and managing background task executions over GraphQL. All methods return a Result type — use result.isOk() and result.isFail() to handle success and error cases. See the SDK overview for initialization and error handling details.

Types
anchor

TaskStatus
anchor

TaskDefinition
anchor

Represents a registered background task definition.

FieldTypeDescription
idstringThe unique task definition ID
titlestringHuman-readable title of the task
descriptionstringOptional description of what the task does

TaskRun
anchor

Represents a single background task execution.

FieldTypeDescription
idstringThe task run ID
definitionIdstringID of the task definition that was triggered
taskStatusTaskStatusCurrent status of the task run
startedOnstringISO timestamp when the task started
finishedOnstringISO timestamp when the task finished
namestringOptional display name for the task run
iterationsnumberNumber of execution iterations completed
parentIdstringID of the parent task, if this is a child task
executionNamestringInternal execution name used by the system
eventResponseunknownRaw response from the trigger event
inputunknownInput data passed when the task was triggered
outputunknownOutput data produced by the task

TaskLog
anchor

Represents a log group for a single task execution iteration.

FieldTypeDescription
idstringThe log ID
createdOnstringISO timestamp when the log was created
executionNamestringExecution name associated with the log
iterationnumberIteration number this log belongs to
itemsTaskLogItem[]Individual log entries within this log group

TaskLogItem
anchor

FieldTypeDescription
messagestringThe log message
createdOnstringISO timestamp of the log entry
typestringLog level or category
dataunknownOptional structured data
errorunknownOptional error details

Methods
anchor

listDefinitions
anchor

Lists all registered background task definitions in the system.

Signature:

Parameters: None.


listTasks
anchor

Lists all background task runs.

Signature:

Parameters: None.


listLogs
anchor

Lists execution logs for background tasks. Optionally filter by task ID.

Signature:

Parameters:

ParameterTypeRequiredDescription
whereobjectNoOptional filter conditions
where.taskstringNoFilter logs to a specific task run ID

triggerTask
anchor

Triggers a background task run.

Signature:

Parameters:

ParameterTypeRequiredDescription
definitionstringYesThe task definition ID to trigger
inputRecord<string, unknown>NoInput data to pass to the task

abortTask
anchor

Aborts a running background task.

Signature:

Parameters:

ParameterTypeRequiredDescription
idstringYesThe task run ID to abort
messagestringNoOptional reason for aborting the task