Core Development Concepts > Background Tasks
How to Define a Background Task
You will learn about Background Tasks, how to create new definitions, how to trigger them and how to handle the task run.
Use with caution!
This feature is experimental and is subject to change in future releases.
Can I use this?
This feature is available since Webiny v5.39.0.
What you’ll learn
- difference between public and private Background Tasks
- how to define your own Background Task
- how to register your Background Task
Overview
First, you need to know that there are two types of Background Tasks:
- public - can be called via GraphQL API or the programmatic API
- private - can be called only through the programmatic API
Definition of the task is the same for both types of tasks, with a difference of the method name used to define the task.
Basic Definition
To see all available properties, and information about the properties, for the task definition, check the ITaskDefinition
interface.
There are few properties, which should not be used:
fields
- not implemented yetisPrivate
- set automatically when a user defines a task viacreatePrivateTaskDefinition
Public Task
Private Task
Advanced Definition
Registering the Task
Of course, as all other Webiny plugins, users must register the task definition in the plugins
array of the createHandler
function.