Create task

Select an existing file or directory from the connector and create an import task. Unstructured files are written to the data volume. Data rows for CSV, XLS, and XLSX are written to the target table.

HTTP
POST $CLOUDSIGMA_API_BASE/task

Before you call

Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare personal access token and target workspace ID that can access the target workspace. Also prepare a connector for import, the connector file URI, and the target data volume or data table.

To upload local files, use Local Upload and create import task. To read data from a database object, use Create Database Structured Import Task.

Request body

Replace the connector, target resource, and field values in $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, and examples with actual values.

Import files into data volumes

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/task" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "source_connector_id": "'"$CONNECTOR_ID"'",
    "name": "'"$TASK_NAME"'",
    "config_type": 1,
    "source_config": {
      "common_file_task_config": {
        "uris": ["'"$CONNECTOR_DIRECTORY_URI"'"],
        "load_mode_config": {
          "load_interval_type": 4
        },
        "file_filter_config": {
          "path_regex": ".*\\.(pdf|docx)$"
        },
        "unzip_keep_structure": false,
        "dedup": {
          "by": ["name", "md5"],
          "strategy": "skip"
        }
      }
    },
    "volume_id": "'"$VOLUME_ID"'"
  }'

Import CSV into existing data table

Structured files are written to data tables.

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/task" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "source_connector_id": "'"$CONNECTOR_ID"'",
    "name": "'"$TASK_NAME"'",
    "config_type": 1,
    "source_config": {
      "common_file_task_config": {
        "uris": ["'"$CONNECTOR_FILE_URI"'"],
        "load_mode_config": {
          "load_interval_type": 4
        },
        "table_config": {
          "new_table": false,
          "table_id": '"$TARGET_TABLE_ID"',
          "isColumnName": true,
          "columnNameRow": 1,
          "rowStart": 2,
          "csv": {
            "separator": ","
          },
          "existed_table": [
            {
              "tableColumn": "'"$TARGET_COLUMN"'",
              "column": "'"$FILE_COLUMN"'",
              "col_num_in_file": 1
            }
          ]
        }
      }
    },
    "volume_id": "'"$VOLUME_ID"'"
  }'

Import files into data volumes

Parameter

Type

Required

Description

source_connector_id

string

Yes

Source connector ID, must be submitted as a JSON string.

name

string

Yes

Task name.

config_type

integer

Yes

File import is fixed to 1.

source_config

object

Yes

File sources and processing settings. File source and target table settings.

source_config.common_file_task_config.uris

array of string

Yes

File or directory URI in the connector. CSV file URI in the connector.

source_config.common_file_task_config.load_mode_config.load_interval_type

integer

Yes

Execution frequency. 4 means one-time use.

source_config.common_file_task_config.file_filter_config.path_regex

string

No

Source path filter regular expression.

source_config.common_file_task_config.unzip_keep_structure

boolean

No

Whether to preserve the directory structure when decompressing.

source_config.common_file_task_config.dedup.by

array of string

No

Duplicate file judgment field.

source_config.common_file_task_config.dedup.strategy

string

No

Duplicate file handling policy.

volume_id

string

Yes

Real non-empty volume ID. Even importing into a table requires this value and write permissions for the volume.

source_config.common_file_task_config.table_config.new_table

boolean

Yes

false means using an existing table. Change it to true when creating a new single table. Use multi_table_config.tables for XLS or XLSX multi-sheet configuration instead, do not mix it with single-sheet configuration.

source_config.common_file_task_config.table_config.table_id

integer

Yes

Target table ID already exists.

source_config.common_file_task_config.table_config.isColumnName

boolean

Yes

Whether to use the specified row as a column name.

source_config.common_file_task_config.table_config.columnNameRow

integer

Yes

The row where the column name is located starts from 1.

source_config.common_file_task_config.table_config.rowStart

integer

Yes

The data starts from 1.

source_config.common_file_task_config.table_config.csv.separator

string

No

CSV column separator.

source_config.common_file_task_config.table_config.existed_table

array of object

Yes

Mapping of file columns to target columns.

source_config.common_file_task_config.table_config.existed_table[].tableColumn

string

No

Target table column name.

source_config.common_file_task_config.table_config.existed_table[].column

string

No

Column names in the file.

source_config.common_file_task_config.table_config.existed_table[].col_num_in_file

integer

No

Column number in the file.

$VOLUME_ID in the example uses the actual volume ID that is writable in the current workspace. Table target configuration is preserved and cannot be filled with empty strings or invalid 0.

Requests can accept a legacy database one-time import or sync configuration for config_type=2, but these tasks are currently unavailable. Please use the database structured import interface. Connector file import and CSV file write tables are not subject to this restriction.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "task_id": "task_01"
  }
}

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data.task_id

string

Create a new import task ID.

Error response

JSON
{
  "code": "ErrParamInvalid",
  "msg": "source_config is required",
  "data": null
}

Field

Type

Description

code

string

error code.

msg

string

Readable error message.

data

null

The error response is null.

Last updated on