HTTP interface for tasks
The HTTP API for tasks lets you can manage the periodic or timed execution of server-side JavaScript code
List all tasks
get
/_api/tasks/
fetches all existing tasks on the server
Responses
200
The list of tasks
Response Bodymap[schema:map[description:a list of all tasks items:map[properties:map[command:map[description:The JavaScript function for this task. type:string] created:map[description:The timestamp when this task was created. type:number] database:map[description:The database this task belongs to. type:string] id:map[description:A string identifying the task. type:string] name:map[description:A user-friendly name for the task. type:string] offset:map[description:Time offset in seconds from the `created` timestamp. type:number] period:map[description:This task should run each `period` seconds. type:number] type:map[description:What type of task is this [ `periodic`, `timed`] - periodic are tasks that repeat periodically - timed are tasks that execute once at a specific time type:string]] required:[name id created type period offset command database] type:object] type:array]]
Examples
Fetching all tasks
curl --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks
Get a task
get
/_api/tasks/{id}
fetches one existing task on the server specified by
id
Query Parameters
Responses
Examples
Fetching a single task by its id
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/tasks
"{\"id\":\"testTask\",\"command\":\"console.log('Hello from task!');\",\"offset\":10000}"
curl --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/testTask
Trying to fetch a non-existing task
curl --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/non-existing-task
Create a task
post
/_api/tasks
creates a new task with a generated id
Request Body application/json
Responses
Examples
curl -X POST --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/tasks/
{
"name": "SampleTask",
"command": "(function(params) { require('@arangodb').print(params); })(params)",
"params": {
"foo": "bar",
"bar": "foo"
},
"period": 2
}
curl -X DELETE --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/69077
Create a task with ID
put
/_api/tasks/{id}
Registers a new task with the specified ID.
Not compatible with load balancers.
Query Parameters
Request Body application/json
Examples
curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/tasks/sampleTask
{
"id": "SampleTask",
"name": "SampleTask",
"command": "(function(params) { require('@arangodb').print(params); })(params)",
"params": {
"foo": "bar",
"bar": "foo"
},
"period": 2
}
Delete a task
delete
/_api/tasks/{id}
Deletes the task identified by
id
on the server.Query Parameters
Responses
Examples
Try to delete a non-existent task:
curl -X DELETE --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/NoTaskWithThatName
Remove existing task:
curl -X DELETE --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/SampleTask