REST API - submitting a job with dependencies in the current plan

Use REST APIs to submit a job with a single dependency in the plan.

About this task

This process involves retrieving the unique IDs of two jobs (a successor and a predecessor) and then creating a dependency between them using a POST REST API.

Procedure

  1. First, get the unique ID of the successor job. Use the GET/twsd/api/v2/model/jobdefinition endpoint to find its definition in the database.

    You can query for the job definition using either model filters or OQL. The following substeps show how to retrieve a job definition named TESTJOB.

    1. To query with model filters: use a syntax analogous to the composer syntax, for example: /@/@#/@/TESTJOB.
    2. To query with OQL: from the dropdown menu, select Filter by exact name and matching folder and sort results in name descending order in the OQL string parameter field. Enter the name of the job in the name field to obtain the following query: name = 'TESTJOB' AND folder LIKE '/TEST/' ORDER BY name DESC.
    3. After selecting a query method, click Execute.
    4. From the API response, copy and save the job definition id.

      Example of a response payload:

      {
        "count": 1,
        "results": [
          {
            "kind": "JobDefinition",
            "key": "/RMMYCLDTL15094_1#/TEST/TESTJOB",
            "def": {
              "id": "e7ca3702-2411-32c0-bef7-e425f0a2f815",
              "folderId": "1f3fbed7-7c1f-3eb0-95c1-80f1ff2815b0",
              "folder": "/TEST/",
              "name": "TESTJOB",
              ...
            }
          }
        ]
      }
  2. Next, get the data for the predecessor job. Use the GET/twsd/api/v2/plan/job endpoint to find the job currently in the plan.
    1. Use the query filters or OQL to locate the job you want to use as a predecessor.
    2. Click Execute and, from the response, copy and save the predecessor job data, including its id.

      Example of a response payload for a predecessor job:

      {
        "count": 1,
        "results": [
          {
            "flowNodeType": "JOB",
            "id": "a8ca4deb-b23d-33f3-af22-bf9b53802da4",
            "planId": "718ccf91-7ee5-3a8a-8431-e4e3252cac93",
            "folderId": "742ba6a6-31aa-3051-b810-3ced4fc624b4",
            "folder": "/",
            "name": "LS1548259130",
            "workstationId": "4ffdee00-5e6d-3463-9bad-1ab7edac6d90",
            "workstation": "/RMMYCLDTL15094_1",
            "cpuFolderId": "742ba6a6-31aa-3051-b810-3ced4fc624b4",
            "jobStreamId": "f2616f78-924a-36d8-aa2f-f65299a0ed54",
            "jobStreamName": "JOBS",
            "jobStreamWorkstationId": "4ffdee00-5e6d-3463-9bad-1ab7edac6d90",
            "jobStreamWorkstation": "/RMMYCLDTL15094_1",
            "position": 2,
            "key": "RMMYCLDTL15094_1;JOBS;LS1548259130",
            "jobDefinitionFlags": {},
            "jobStatusFlags": {},
            "jobOptions": {
              "every": false
            },
            "jobDefinition": {
              "name": "LS1548259130",
              "workstationId": "4ffdee00-5e6d-3463-9bad-1ab7edac6d90",
              "workstation": "/RMMYCLDTL15094_1",
              "cpuFolderId": "742ba6a6-31aa-3051-b810-3ced4fc624b4",
              "taskType": "UNIX",
              "task": {
                "UNIX": {
                  "taskString": "ls",
                  "userName": "twsuser",
                  "isCommand": true
                }
                   ...
                  }
                  ]
                  }
  3. Now, use the data you retrieved to add the dependency with the POST/twsd/api/v2/plan/job/{job_id}/action/add-dependencies endpoint.
    1. In the Swagger UI, expand the endpoint and paste the ID of the successor job (from the first step) into the ID parameter field in the path.
    2. In the Request body field, paste the following content, using the IDs you copied from the previous steps. The first id belongs to the successor job, and the jobId belongs to the predecessor job.
      {
                                      "dependencies": [
                                      {
                                      "dependencyType": "INTERNAL",
                                      "id": "e7ca3702-2411-32c0-bef7-e425f0a2f815",
                                      "dependencyStatus": "SATISFIED",
                                      "mandatory": true,
                                      "conditional": true,
                                      "critical": true,
                                      "statusConditions": [
                                      "STARTED"
                                      ],
                                      "outputConditions": [
                                      "string"
                                      ],
                                      "jobStreamName": "JOBS",
                                      "jobStreamWorkstation": "RMMYCLDTL15094_1",
                                      "jobStreamSchedTime": "2025-09-30T10:20:43.212Z",
                                      "jobStreamFolder": "/",
                                      "jobId": "a8ca4deb-b23d-33f3-af22-bf9b53802da4",
                                      "jobName": "LS1548259130",
                                      ...
                                      }
                                      ]
                                      }
    3. Click Execute.
    The API returns a success message, and the dependency is now active in the current plan.
  4. To verify the dependency was added, run the GET/twsd/api/v2/plan/job/{job_id} API endpoint, using the ID of the successor job. Examine the dependencies object in the response body to confirm it is correct.