Skip to main content

Create a Task

Create a task

Contents

Overview

  • Endpoint URL: https://{Services API hostname}/tasks
  • Request method: HTTP POST
  • Request Content-Type: application/json
  • Response Content-Type: application/json
  • Auth required: yes

Create a new task on the Services API. The task will be scheduled to run at the time specified in trigger.once.

Version-specific information

The following version-specific changes apply to this endpoint:

VersionChange details
N/AN/A

Permissions and Authentication

This endpoint requires chain-scoped authentication on the Services API. See the authentication page for more details on authentication methods. The following authentication types are permitted:

  • Privileged authentication: the use of privileged authentication is permitted for this endpoint.
  • Admin authentication: the use of admin authentication is permitted. The performing user needs to have the appropriate access level for the chain.

Headers

The following headers can/must be passed to the API call:

ParameterDescription
N/AN/A

JSON body parameters

The following JSON parameters can be passed in the request body:

ParameterTypeRequiredDescription
chainintegerrequiredThe chain ID for which the task should run.
descstringrequiredA description of the task (for reference purposes).
targetobjectrequiredDefines what the task does. See Target parameters in the Tasks overview.
triggerobjectrequiredDefines when the task runs and optional filtering. See Scheduling and triggers in the Tasks overview.
debugstringoptionalDebug string for diagnostic purposes.

Sample request

curl -X POST 'https://{Services API hostname}/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET' \
-d '{
"chain": 1764,
"desc": "Wallet ledger export for analytics warehouse",
"target": {
"action": "export",
"export_index": "wallet-ledger",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z"
}
}'

Sample response

Returns the created task object with HTTP status 201 Created. The response includes a Location header with the task URL. See Task object structure for a description of all fields.

{
"id": 12345,
"chain": 1764,
"desc": "Wallet ledger export for analytics warehouse",
"state": {
"code": "READY",
"last_run_date": "0001-01-01T00:00:00Z",
"last_modified": "2026-05-26T11:59:00Z",
"created_date": "2026-05-26T11:59:00Z"
},
"trigger": {
"once": "2026-05-26T12:00:00Z"
},
"target": {
"action": "export",
"export_index": "wallet-ledger",
"export_format": "csv"
},
"logs": null,
"debug": "",
"version": 2,
"result": ""
}

Sample request with segment filter

curl -X POST 'https://{Services API hostname}/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN_ID:ACCESS_TOKEN_SECRET' \
-d '{
"chain": 1764,
"desc": "Users created in the last 24 hours",
"target": {
"action": "export",
"export_index": "users",
"export_format": "csv"
},
"trigger": {
"once": "2026-05-26T12:00:00Z",
"segment": {
"entity": "people",
"index": "users",
"join": "all",
"chain_id": 1764,
"rules": [
{
"field_name": "created_date",
"field_type": "date",
"operator": "relative_less_than",
"time_factor": "day",
"time_amount": 1
}
]
}
}
}'

Possible error responses

The following represents a list of possible error responses for this endpoint:

ConditionDescription
Missing required fieldschain, target, or trigger is missing from the request body.
Invalid chainThe specified chain ID is not valid or the user has no access.
Invalid export indexThe target.export_index value is not a supported index.
Invalid segment rulesA segment rule contains an unsupported operator or invalid field.
Authentication failureNo valid authentication provided or insufficient permissions.