Skip to main content

Common Structure

All task types in Compozy share a common base structure with the following fields:
Each task type extends this common structure with its specific fields and configurations. Tasks provide access to state information through event handlers:

Basic

This is the default if you don’t specify a type.
Best Used For:
  • Single operations
  • API calls
  • Data transformations
  • Simple processing steps
JSON Schema
https://compozy.dev/schemas/task-basic.json

Parallel

Executes multiple operations simultaneously to improve performance
Best Used For:
  • Independent operations
  • Performance optimization
  • Batch processing
  • Multiple API calls
JSON Schema
https://compozy.dev/schemas/task-parallel.json

Decision

Routes execution based on conditions or data values.
Best Used For:
  • Business logic implementation
  • Content-based routing
  • Error handling flows
  • Multi-path processing
JSON Schema
https://compozy.dev/schemas/task-decision.json

Collection

Processes arrays of items efficiently, with support for batching and parallel execution.
Best Used For:
  • Processing arrays of items
  • Batch processing
  • Parallel data processing
  • Rate-limited operations
JSON Schema
https://compozy.dev/schemas/task-collection.json

Wait

Pauses execution until specific conditions are met or a timeout occurs.
Best Used For:
  • Human approval flows
  • External service integration
  • Time-based operations
  • Rate limiting
JSON Schema
https://compozy.dev/schemas/task-wait.json

Map

Transforms data between tasks while maintaining type safety.
Best Used For:
  • Data transformation
  • Schema validation
  • Field mapping
  • Response formatting
JSON Schema
https://compozy.dev/schemas/task-map.json

Composite

Groups multiple operations into a single, reusable unit.
Best Used For:
  • Reusable task sequences
  • Complex workflows
  • Modular task design
  • Process encapsulation
JSON Schema
https://compozy.dev/schemas/task-composite.json

Best Practices

Choose the Right Type

Select task types based on your specific needs:
  • Use Basic for simple operations
  • Use Parallel for independent concurrent operations
  • Use Decision for conditional flows
  • Use Collection/Foreach for iterative processing
  • Use Wait for external dependencies
  • Use Map for data transformations
  • Use Composite for reusable workflows

Event Handling

Implement appropriate event handlers:
  • Use on_start for initialization
  • Use on_success/on_error for outcomes
  • Use on_complete for cleanup
  • Implement type-specific handlers
  • Log important state changes

Error Management

Implement proper error handling:
  • Configure retry policies
  • Use conditional error routing
  • Handle partial failures
  • Implement fallback mechanisms
  • Log error details

State Management

Monitor and manage task state:
  • Track execution progress
  • Monitor performance metrics
  • Log state transitions
  • Handle state persistence
  • Implement recovery mechanisms

Next Steps

Types

Learn about different task types and their use cases

Usage

Understand how to use tasks in your workflows

API reference

Review the task configuration API reference

Registry

Learn about publishing tasks to the registry