Job Management API

Version 26.1.9516


Job Management API


The CData Sync REST API V2 supports the following job management actions:

The following sections describe each of these actions.

List All Jobs in a Specified Workspace

The following command returns a list of all jobs within a workspace in CData Sync:

GET http://<SyncHost>/api.rsc/v2/workspaces/{workspace_id}/jobs

Path Parameter

Name Description
workspace_id (required) Identifies the workspace from which to retrieve the list of jobs.

Create a Job in a Specified Workspace

The following command creates a new job in a specified workspace:

POST http://<SyncHost>/api.rsc/v2/workspaces/{workspace_id}/jobs

Path Parameter

Name Description
workspace_id (required) Identifies the workspace in which to create the job.

Body Parameters

Name Description
Name Specifies the name of the job.
Type Specifies the type of job. Values are Standard, SyncAll, LoadFolder, ChangeDataCapture, and ReverseETL.
Source-Connection Specifies the identifier (Id) and name of the source connection.
Destination-Connection Specifies the identifier (Id) and name of the destination connection.
Schedule Specifies whether to execute a job according to a specific scheduler. Set the Enabled subparameter to True to execute the job per a specific scheduler.
Cron Specifies the scheduler cron string.
Send_Email Specifies whether to send email alerts after job completion. Set this parameter to True to send the email alerts.
Email_To Specifies the email address to which alerts should be sent.
EmailErrorOnly Specifies to send an email only when an error occurs.
Enable_Parallel_Processing Specifies to enable parallel processing when this parameter is set to True.
Worker_Pool Specifies the number of worker pools.
Verbosity Specifies the log verbosity level of the job.
Destination_Schema Specifies the destination schema string.
Table_Name_Prefix Specifies a prefix for all tables that are replicated.
Use_GMT_DateTime Specifies whether to synchronize times in Greenwich Mean Time (rather than local time). Set this parameter to True to synchronize times in the GMT time zone.
History_Mode Species whether to enable history mode.
Truncate_Table_Data Specifies whether to delete all rows before each update. Set this parameter to True to delete all rows before an update.
Drop_Table Specifies whether to drop a table before each update. Set this parameter to True to drop a table before an update.
Auto_Truncate_Strings Specifies whether to truncate strings automatically that are too large for the column size. Set this parameter to True to truncate strings automatically if they are too large for the column.
Continue_On_Error Specifies whether a job should continue to the next query when it encounters an error. Set this parameter to True for the job to continue to the next table when previous table generates an error.
Deletion_Behavior Specifies the type of deletion (for example, HardDelete).
Alter_Schema Specifies whether to add columns and alter data types when the source table metadata and the destination table metadata do not match. Set this parameter to True to add columns and alter data types if a mismatch does occur.
Replicate_Interval Paired with ReplicateIntervalUnit, this parameter controls the time frames in which to split the data during replication.
Replicate_Interval_Unit Paired with ReplicateInterval, this parameter controls the time frames in which to split the data during replication. Values are minutes, hours, days, weeks, months, years.
Replicate_Start_Date Sets the minimum date (in the form yyyy-MM-dd) from which to begin replicating data.
Batch_Size Sets the size of the batch.
Pre_Job_Event Specifies the code of pre-job event.
Post_Job_Event Specifies the code of post-job event.
CDC_Engine_Settings Specifies settings like Name and Schema for the CDC engine.
Labels Specifies job labels.
Pipeline Id Specifies the Id of the pipeline in which the job is used.
Queries Specifies the queries to use in the job.

Example Request

{
  "name": "ReverseETLJob",
  "type": "ReverseETL",
  "source_connection_id": "550e8400-e29b-41d4-a716-446655440000",
  "destination_connection_id": "550e8400-e29b-41d4-a716-446655440220"
}

Update a Job

The following command updates an existing job.

PUT http://<SyncHost>/api.rsc/v2/jobs{job_id}

Note: You cannot update a job that is running.

Query Parameter

Name Description
job_id (required) Identifies the job that you want to update.

Body Parameters

Name Description
Name Specifies the name of your job.
Schedule Specifies whether to execute a job according to a specific scheduler. Set the Enabled subparameter to True to execute the job per a specific scheduler.
Cron Specifies the scheduler cron string.
Send_Email Specifies whether to send email alerts after job completion. Set this parameter to True to send the email alerts.
Email_To Specifies the email address to which alerts should be sent.
Email_Subject Specifies the email subject for alerts.
Email_Error_Only Specifies to send an email only when an error occurs.
Verbosity Specifies the log verbosity level of the job. Values are 1, 2, 3, and 5.
Table_Name_Prefix Specifies a prefix for all tables that are replicated.
Use_GMT_DateTime Specifies whether to synchronize times in Greenwich Mean Time (rather than local time). Set this parameter to True to synchronize times in the GMT time zone.
Truncate_Table_Data Specifies whether to delete all rows before each update. Set this parameter to True to delete all rows before an update.
Drop_Table Specifies whether to drop a table before each update. Set this parameter to True to drop a table before an update.
Auto_Truncate_Strings Specifies whether to truncate strings automatically that are too large for the column size. Set this parameter to True to truncate strings automatically if they are too large for the column.
Continue_On_Error Specifies whether a job should continue to the next query when it encounters an error. Set this parameter to True for the job to continue to the next table when previous table generates an error.
Alter_Schema Specifies whether to add columns and alter data types when the source table metadata and the destination table metadata do not match. Set this parameter to True to add columns and alter data types if a mismatch does occur.
Replicate_Interval Paired with ReplicateIntervalUnit, this parameter controls the time frames in which to split the data during replication.
Replicate_Interval_Unit Paired with ReplicateInterval, this parameter controls the time frames in which to split the data during replication. Values are minutes, hours, days, weeks, months, years.
Replicate_Start_Date Sets the minimum date (in the form yyyy-MM-dd) from which to begin replicating data.
Batch_Size Sets the size of the batch.
Pre_Job_Event Specifies the code of pre-job event.
Post_Job_Event Specifies the code of post-job event.
Labels Specifies job labels.
Pipeline Id Specifies the Id of the pipeline in which the job is used.

Example Request

{
  "name": "reverseETLJob",
  "schedule": {
    "enabled": false,
    "cron": ""
  }

Delete a Job

The following command removes a job from the Sync application:

DELETE http://<SyncHost>/api.rsc/v2/jobs{job_id}

Note: You cannot delete a job that is running.

Path Parameter

Name Description
job_id (required) Identifies the job that you want to delete.

Execute a Job

The following command executes a job:

POST http://<SyncHost>/api.rsc/v2/jobs/{job_id}/execute

Path Parameter

Name Description
job_id (required) Identifies the job that you want to execute.

Body Parameters

Name Description
Tasks Specifies a list of job task Ids to execute.

Example Request

{
  tasks:[
    "870237973789151200",
    "870875808946851841",
    "870875808946851842"    
  ]
}

Cancel a Running Job

The following command cancels a running job:

POST http://<SyncHost>/api.rsc/v2/jobs/{job_id}/cancel

Path Parameter

Name Description
job_id (required) Identifies the job that you want to cancel.

List the Job History

The following command retrieves all histories for a job:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/history

Path Parameter

Name Description
job_id (required) Identifies the job for which you want to retrieve the history.

Retrieve a Specified Job History

The following command retrieves a specified history for a job:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/history/{history_id}

Path Parameters

Name Description
job_id (required) Identifies the job for which you want to retrieve the history.
history_Id Identifies the specific history instance to retrieve.

Retrieve the Job Status

The following command retrieves the status for a job run:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/status

Path Parameter

Name Description
job_id (required) Identifies the job for which you want to retrieve the status.

List All Job Tasks

The following command retrieves a list of tasks that are associated with a job or transformation:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks

Path Parameter

Name Description
job_id (required) Identifies the job for which you want to list all tasks.

Retrieve a Task

The following command retrieves a specific task from within a job:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks/{task_id}

Path Parameters

Name Description
job_id (required) Identifies the job for which you want to retrieve the status.
task_id (required) Specifies the Id of the task that you want to retrieve.

Add a Task

The following command adds a task to a job:

POST http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks

Path Parameter

Name Description
job_id (required) Identifies the job in which you want to add a task.

Body Parameters

Name Description
Query Specifies the SQL statement that defines the operation performed by the task.
Is_Active Specifies whether the task is enabled and will be executed when the job runs.

Example Request

{
  "query": "REPLICATE [Accounts] SELECT * FROM [Accounts]",
  "is_active": true
}

Update a Task

The following command updates a job task:

PUT http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks/{task_id}

Path Parameters

Name Description
job_id (required) Identifies the job that contains the task that you want to update.
task_id (required) Specifies the Id of the task that you want to update.

Body Parameters

Name Description
Query Specifies the SQL statement that defines the operation performed by the task.
Is_Active Specifies whether the task is enabled and will be executed when the job runs.

Example Request

{
  "query": "REPLICATE [Accounts] SELECT * FROM [Accounts]",
  "is_active": true,
  "index": 1
}

Delete a Task

The following command deletes a job task:

DELETE http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks/{task_id}

Note: You cannot delete a task that is running.

Path Parameters

Name Description
job_id (required) Identifies the job that contains the task that you want to delete.
task_id (required) Specifies the Id of the task that you want to delete.

Move a Task

The following command moves the position of a task within a job:

POST http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks/{task_id}/move

Path Parameters

Name Description
job_id (required) Identifies the job that contains the task that you want to move.
task_id (required) Specifies the Id of the task that you want to move.

Body Parameters

Name Description
From_Index Specifies the original index number for the task.
To_Index Specifies the index number to which you are moving the task.

Example Request

{
  "from_index": 0,
  "to_index": 1
}

Retrieve the Last Run of All Tasks

The following command retrieves the last run of all tasks in a job:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks/last-run

Path Parameter

Name Description
job_id (required) Identifies the job for which you want to retrieve the status of the last run of all tasks.

Retrieve the Task History

The following command retrieves the history for a specified task:

GET http://<SyncHost>/api.rsc/v2/jobs/{job_id}/tasks/{task_id}/history

Path Parameters

Name Description
job_id (required) Identifies the job that contains the task history that you want to retrieve.
task_id (required) Specifies the Id of the task for which you want to retrieve the history.