Local Task Execution
For locally testing tasks you can use the callTask CLI method, this can be done locally regardless of what types of triggers you have configured.Trigger Task locally with CLI
Chain Event Triggers
Tasks can be triggered with onchain events, the payload sent to the task will be the encoded event object. Compose provides useful tools for decoding the event in your task code, see Contracts for more details on decoding.Example event object sent as the payload to your task:
Example configuration for an onchain event trigger:
Onchain Trigger Properties
| Property | Type | Required | Description |
|---|---|---|---|
type | ”onchain” | Yes | Type discriminator |
network | string | Yes | The slug value of the network |
contract | string | Yes | The address of the contract |
events | array(string) | No | Specific event signatures (not encoded) to use for the trigger |
Cron Triggers
Tasks can be triggered by cron jobs, tasks triggered by cron will be called with an empty payload since each invocation is generic.Example
Cron Trigger Properties
| Property | Type | Required | Description |
|---|---|---|---|
type | ”cron” | Yes | Type discriminator |
expression | string | Yes | The interval to call the task in cron expression syntax |
HTTP Triggers
Tasks can be triggered by http requests, often this is useful for starting compose tasks from your application logic. HTTP triggers can be sent any payload you want for dynamic execution.Example
Http Trigger Properties
| Property | Type | Required | Description |
|---|---|---|---|
type | ”http” | Yes | Type discriminator |
authentication | ”auth_token” | “none” | Yes | Type of authentication to use on the endpoint |
role | ”Owner” | “Admin” | “Editor” | “Viewer” | No | The minimum RBAC role required if using “auth_token” authentication |
Base URL
Locally, Compose runs onhttp://localhost:4000. The base pattern for all endpoints is:
HTTP Request Format
Delayed Task Execution
You can schedule a task to execute after a delay by including adelay field in your request body. The delay is specified in milliseconds.
delay in its payload.
Execute HTTP trigger without parameters
Execute an HTTP trigger with parameters
Response Format
Tasks return JSON responses with the data returned by the task’smain function.
Calling this task: