Loading TOC...

POST /manage/v2/tasks


This resource address is used to create a new scheduled task for the specified group. For an example, see Creating a Push Replication Scheduled Task in the Scripting Administrative Tasks Guide.

URL Parameters
group-id The id or name of the group to which the tasks belong. The group must be specified by this parameter or by the group-name property in the request payload. If it is specified in both places, the values must be the same.
format The format of the posted data. Can be either html, json, or xml (default). This value overrides the Accept header if both are present.
Request Headers
Accept The expected MIME type of the request body. If the format? parameter is present, it takes precedence over the Accept header.
Content-type The MIME type of the data in the request body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.
Response Headers
Content-type The MIME type of the data in the response body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.
Location If the request causes a restart, a Location header is included in the reponse. The header contains a path with which to construct a URL to usable to test when the restart has completed.


Upon success, MarkLogic Server returns status code 201 (Created). If the task exists or if the payload is malformed, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.

Required Privileges

This operation requires one of the following:

The security role is required to set the task-user property.

Usage Notes

If your task is in the filesystem, rather than a database, do not include the task-database property. The task-start-time property must be in xs:time format ("24:00"). The task-type property is (minutely|hourly |daily|weekly|monthly|once). If not supplied, the default value is once. The task-days property is an array containing (sunday, monday, tuesday, wednesday, thursday, friday, saturday). The task-priority property is (normal|higher), if not supplied, default value is normal.

Note: The properties described here are for XML payloads. In general they are the same for JSON, with the exception that, in JSON, task-days is expressed in singular form. For example, in JSON, task-days is instead task-day and the format is as shown in the following example.


The task ID.


Whether or not a task is enabled


The module to invoke.


The path to the module directory root.


What type of scheduled task is this.


How often this task should run (every n months, weeks, days, hours or minutes).


The day of the month that this task runs on.


The days that this task runs on.

This is a complex structure with the following children:


A day that this task runs on.


The starting date (in MM/DD/YYYY notation) for this task.


The starting time (in 24:00 notation) for this task.


The date and time this task was created.


The database name.


The database that contains application modules.


The user to run this task as.


The host to run this task on.


The priority of this task.


cat myTask.json

curl -X POST --digest -u admin:admin -H "Content-type: application/json" \
-d @myTask.json http://localhost:8002/manage/v2/tasks?group-id=Default

==>  Creates a task in the Default group to run "/path/to/query.xqy" on Tuesday
     every other week at 12:00. 

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.