How to import a workflow via API using cURL command

Importing Workflows via API Using cURL

Managing workflows across projects often requires a quick and reliable way to import multiple workflow definitions. This guide walks you through using a simple API endpoint with cURL to import workflow JSON files efficiently on both Linux and Windows systems.


Overview

The Workflow Import API allows you to upload one or more workflow JSON files into a specified project. It also provides flexibility in handling workflow UUIDs, which is crucial when dealing with duplicates or migrations.


Input Parameters

To successfully call the API, you’ll need to provide the following parameters:

Parameter Type Required Description
projectId Query Parameter Yes The target project ID where workflows will be imported.
uuidOption Query Parameter Yes Defines how UUID conflicts are handled during import.
token Header Yes Authentication token included in the request header.
file[] Multipart File Yes One or more workflow JSON files to upload.

UUID Handling Options

When importing workflows, UUID conflicts can occur. The API provides multiple strategies to handle them:

Option Description uuidOption Value
Overwrite existing workflow if UUID already exists overwriteWorkflowIfUUIDExistInProject
Create a new UUID if a duplicate exists createNewUUIDIfExist
Always generate a new UUID createNewUUID

Choose the option that best fits your use case depending on whether you want to preserve, overwrite, or duplicate workflows.


cURL Command for Linux

Use the following command in a Linux environment:

curl -X POST "http://localhost:8080/api/v1/workflows/import?projectId=2414&uuidOption=createNewUUID" \
  -H "token: token_value" \
  -F "file[]=@complete_path_to_wf_json_file_1;type=application/json" \
  -F "file[]=@complete_path_to_wf_json_file_2;type=application/json"


cURL Command for Windows

For Windows Command Prompt, use ^ for line continuation:

curl -X POST "http://localhost:8080/api/v1/workflows/import?projectId=2414&uuidOption=createNewUUID" ^
  -H "token: token_value" ^
  -F "file[]=@complete_path_to_wf_json_file_1;type=application/json" ^
  -F "file[]=@complete_path_to_wf_json_file_2;type=application/json"


Tips & Best Practices

  • Validate JSON files before uploading to avoid import failures.

  • Use meaningful UUID options depending on whether you’re syncing or duplicating workflows.

  • Secure your token and avoid exposing it in shared scripts or repositories.

  • For bulk imports, ensure your server can handle multiple file uploads efficiently.