Skip to main content

Task Registration

To register tasks in the system, define them in your worker configuration file located at:

src/config/application.yaml

Basic Example

kafkaTopics:
- topic: backend.exampleWorker.tasks
consumerGroup: example-pluggable-worker

worker:
name: example-pluggable-worker
owner: example-pluggable-worker-owner

tasks:
- name: example-task # Task name
description: description # Task description
publish: true # Whether the task should be exposed via the public gateway.
tags:
- platform-task # Refer to the naming conventions guideline for information on tags

Enable Preflight

tasks:
- name: example-task # Task name
enablePreflight: true # If true, calls to resolve task-options before actual task submission.

Monetization Configs

tasks:
- name: example-task
monetization:
toolId: myToolId # ID used for credit tracking; contact the Monetization team to obtain one

History Configs

tasks:
- name: example-task
history:
persist: true # Whether to persist task history
ttlInHours: 720 # Optional; time-to-live in hours. If not set, data will not expire

Notification Configs

tasks:
- name: example-task
notification:
enabled: true # Optional default; the client's notification.enabled overrides it. true = notify everyone (client can opt out). false/omitted = opt-in (sent only if the client passes notification.enabled:true). See Notifications Overview.
platforms: [ "WEBSITE" ] # Optional; list of platforms to enable notifications from, defaults to all (`APPLE`, `ANDROID`, `WEBSITE`)
data:
title: "Generation Successful" # Optional; notification title for successful task
description: "Your results are ready to view." # Notification description for successful task
cta_label: "View" # Optional; notification CTA button title for successful task
error_title: "Generation Unsuccessful" # Optional; notification title for failed task
error_description: "An error occurred during generation. Please try again later." # Optional; notification description for failed task
error_cta_label: "Try again" # Optional; notification CTA button title for failed task
avatar_url: "https://cdn.picsart.com/icon.png" # Optional; avatar image shown in the push notification (shared by success and failure)

Socket Gateway Config

tasks:
- name: example-task
socketGateway:
enabled: true # Push progress, partial results, events, and the terminal result over the socket gateway in real time

Published only for tasks with a userId, and only for the root task. See Progress → Real-time delivery over the Socket Gateway.

ForceUpdate Config

tasks:
- name: example-task
forceUpdate: true

Each task must have a unique name across all workers.

The forceUpdate property is optional. When set to true, it allows a task with the same name to be reassigned to a different worker. If the task already exists on another worker, that instance will be removed automatically, and the task will be re-registered under the current worker.

info

Use this to migrate a task from one worker to another without needing manual deregistration.

warning

use forceUpdate with caution, as it overrides existing task registrations and may interrupt ongoing work.

Unregister Tasks

To unregister a task from the system, you may remove it from the tasks array. Leaving the array empty will delete all tasks.