Tasks

Provides API interfaces for managing the creation and modification of automation tasks. Tasks are used in workflows for automation.

Get All Tasks

curl "https://api.gomorpheus.com/api/tasks"
  -H "Authorization: BEARER access_token"
The above command returns JSON structured like this:
{
  "tasks": [
     {
      "id": 5,
      "accountId": 1,
      "name": "aptitude upgrade",
      "taskType": {
        "id": 1,
        "code": "script",
        "name": "Shell Script"
      },
      "taskOptions": {
        "script": "apt-get upgrade -y"
      }
    },
  ],
  "meta": {
    "offset": 0,
    "max": 25,
    "size": 1,
    "total": 1
  }
}

This endpoint retrieves all tasks.

HTTP Request

GET https://api.gomorpheus.com/api/tasks

Query Parameters

Parameter Default Description
max 25 Max number of results to return
offset 0 Offset of records you want to load
sort name Sort order
direction asc Sort direction, use 'desc' to reverse sort
phrase Filter by matching name
name Filter by name
taskTypeCodes Filter by task type code(s).

Get a Specific Task

curl "https://api.gomorpheus.com/api/tasks/1" \
  -H "Authorization: BEARER access_token"
The above command returns JSON structured like this:
{
  "task": {
      "id": 5,
      "accountId": 1,
      "name": "aptitude upgrade",
      "taskType": {
        "id": 1,
        "code": "script",
        "name": "Shell Script"
      },
      "taskOptions": {
        "script": "apt-get upgrade -y"
      }
    }
}

This endpoint will retrieve a specific task by id

HTTP Request

GET https://api.gomorpheus.com/api/tasks/:id

URL Parameters

Parameter Description
ID The ID of the task

Create a Task

curl -XPOST "https://api.gomorpheus.com/api/tasks" \
  -H "Authorization: BEARER access_token" \
  -H "Content-Type: application/json" \
  -d '{"task": {
    "name": "cleanup tmp files",
    "taskType": {
      "code": "script"
    },
    "taskOptions": {
      "script": "rm -rf /var/www/app1/tmp/*\nrm -rf /var/www/app2/tmp/*"
    }
  }}'
The above command returns JSON structured like getting a single task:

HTTP Request

POST https://api.gomorpheus.com/api/tasks

JSON Parameters

Parameter Default Description
name null A unique name for the task
taskType.code null The type of task
taskOptions {} Map of options specific to each type. eg. script

Updating a Task

curl -XPUT "https://api.gomorpheus.com/api/tasks/5" \
  -H "Authorization: BEARER access_token" \
  -H "Content-Type: application/json" \
  -d '{"task":{
    "name": "my task",
  }}'
The above command returns JSON structured like getting a single task:

HTTP Request

PUT https://api.gomorpheus.com/api/tasks/:id

URL Parameters

Parameter Description
ID The ID of the task

JSON Parameters

Parameter Default Description
name null A unique name for the task
taskOptions {} Map of options taht vary by task type. eg. script

Delete a Task

curl -XDELETE "https://api.gomorpheus.com/api/tasks/1" \
  -H "Authorization: BEARER access_token"
The above command returns JSON Structured like this:
{
  "success": true
}

HTTP Request

DELETE https://api.gomorpheus.com/api/tasks/:id

URL Parameters

Parameter Description
ID The ID of the task

If a task is still tied to workflows, the delete will fail.