ArangoDB v3.10 reached End of Life (EOL) and is no longer supported.
This documentation is outdated. Please see the most recent stable version.
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
Examples
Fetching all tasks
curl --header 'accept: application/json' --dump - http://localhost:8529/_api/tasksShow output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 2
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
[ ]Get a task
GET
/_api/tasks/{id}
fetches one existing task on the server specified by
idQuery Parameters
HTTP Headers
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/testTaskShow output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 206
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"id" : "testTask",
"name" : "user-defined task",
"created" : 1712247110.3512406,
"type" : "timed",
"offset" : 10000,
"command" : "(function (params) { console.log('Hello from task!'); } )(params);",
"database" : "_system"
}Trying to fetch a non-existing task
curl --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/non-existing-taskShow output
HTTP/1.1 404 Not Found
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 73
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"code" : 404,
"error" : true,
"errorMessage" : "task not found",
"errorNum" : 1852
}Create a task
POST
/_api/tasks
creates a new task with a generated id
Request Body application/json object
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/69073Show output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 240
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"id" : "69073",
"name" : "SampleTask",
"created" : 1712247110.3803697,
"type" : "periodic",
"period" : 2,
"offset" : 0,
"command" : "(function (params) { (function(params) { require('@arangodb').print(params); })(params) } )(params);",
"database" : "_system"
}Create a task with ID
PUT
/_api/tasks/{id}
Registers a new task with the specified ID.
Not compatible with load balancers.
Query Parameters
HTTP Headers
Request Body application/json object
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
}Show output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 241
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"id" : "sampleTask",
"name" : "SampleTask",
"created" : 1712247110.394075,
"type" : "periodic",
"period" : 2,
"offset" : 0,
"command" : "(function (params) { (function(params) { require('@arangodb').print(params); })(params) } )(params);",
"database" : "_system"
}Delete a task
DELETE
/_api/tasks/{id}
Deletes the task identified by
id on the server.Query Parameters
HTTP Headers
Responses
Examples
Try to delete a non-existent task:
curl -X DELETE --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/NoTaskWithThatNameShow output
HTTP/1.1 404 Not Found
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 73
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"code" : 404,
"error" : true,
"errorMessage" : "task not found",
"errorNum" : 1852
}Remove existing task:
curl -X DELETE --header 'accept: application/json' --dump - http://localhost:8529/_api/tasks/SampleTaskShow output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 26
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 200
}