Reference > API > Tasks
Tasks
Background task abstractions: TaskService, TaskDefinition
WHAT YOU'LL LEARN
- What is exported from
webiny/api/tasks? - How to import and use each exported item?
Overview
This page documents everything exported from webiny/api/tasks. Import any of the items below directly from this path in your Webiny extensions.
TaskDefinition
Abstraction — imported from webiny/api/tasks
Interface TaskDefinition.Interface:
Core TaskDefinition - minimal interface
| Method | Description |
|---|---|
id: string() | — |
title: string() | — |
description?: string() | — |
maxIterations?: number() | — |
databaseLogs?: boolean() | — |
isPrivate?: boolean() | — |
run() | Core run method - receives ONLY input params |
| All runtime dependencies (logging, state management, etc.) come from TaskController | |
onBeforeTrigger?() | Optional lifecycle hooks - receive task data, no context |
onDone?() | — |
onError?() | — |
onAbort?() | — |
onMaxIterations?() | — |
createInputValidation?() | Create a validation schema for the task input. |
| This will be used to validate the input before the task is triggered. |
Types:
TaskService
Abstraction — imported from webiny/api/tasks
Interface TaskService.Interface:
Types: