# API

## Introduction

The Flow Management **API** tab allows you to interact with your workflows programmatically, enabling automation and integration with external systems. Through a set of RESTful API endpoints, you can run tasks, check the status of workflows, and interrupt tasks, if needed. This powerful feature is designed to help you automate processes, integrate workflows with other applications, and provide more flexibility for managing your tasks outside of the DBSync platform.

The **API** tab provides essential tools to control and monitor workflows in real-time. Whether you're triggering specific tasks, checking task statuses, or halting tasks that are running longer than expected, the API endpoints allow seamless communication between your systems and DBSync Cloud Workflow.

By leveraging the available API endpoints, create custom solutions that cater to your specific needs, automate critical business processes, and improve operational efficiency.

In this tab, you'll find:

* **Base URL**: The URL to access the API for interacting with workflows.
* **POST and GET Endpoints**: To run tasks, retrieve task statuses, and interrupt tasks as necessary.
* **Actions**: Options to test, edit, or remove API configurations.

Here is a description for each of the fields in the API section of the screenshot you provided:

### **1. Base URL**

* **Description**: This field displays the base URL for the API, which is the endpoint you will use to interact with the API for managing tasks.
* **Example**: <https://api-platform3.dbsync.io/cw/api/v2> is the URL you will use for sending API requests to DBSync Cloud Workflow.
* **Functionality**: You append specific paths to this URL to interact with different API endpoints. For example, appending /project/{projectId}/task/{taskId}/run would allow you to run a specific task.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2F6XkPvnBETjATPTdHxlsz%2Fimage.png?alt=media&#x26;token=325313a7-575a-4c37-b1a5-fce51a82b5a4" alt=""><figcaption></figcaption></figure>

### **2. POST - /project/{projectId}/task/{taskId}/run**

The POST Action API in DBSync Cloud Workflow allows users to trigger a specific task within a project by passing a valid JSON body. This is useful for scenarios such as initiating a DB sync or executing an external task from tools like Postman or custom scripts. This feature supports API-based triggering with authentication, project ID, task ID, and flexible JSON payloads, which can be mapped within the workflow.

#### API Endpoint

**POST**

*https\://\<your-dbsync-instance>/api/v2/projects/{projectId}/tasks/{taskId}/run?trigger=API*

* **projectId** – The unique ID of the project (for example, 569).
* **taskId** – The unique ID of the task within the project (for example, 12).
* **trigger=API** – Required query parameter to indicate that the trigger is API-based.

#### Authentication

The API requires Basic Authentication using a valid DBSync username and password.

**Header Example:**

* Authorization: Basic \<base64encoded(username:password)>
* Content-Type: application/json

**Request Body**

* The body must contain valid JSON.
* Any JSON structure is allowed, and its values can be accessed inside the workflow.

**Example:**

{

&#x20;"customerId": 1001,

&#x20;"name": "John Doe",

&#x20;"address": {

&#x20;  "lineOne": "123 Main Street",

&#x20;  "city": "San Jose"

&#x20;}

}

#### Accessing JSON Values in Workflow

JSON fields can be accessed in the workflow using parameter mapping.

Nested JSON values are accessed using / notation.

**Examples:**

* Accessing name: VALUE
* Accessing nested field address.lineOne: address/lineOne
* If the JSON structure is unknown, use a placeholder like: value of \<fieldName>

**Example Using Postman**

1. Open Postman and create a new POST request.
2. Set the endpoint: *https\://\<your-dbsync-instance>/api/v2/projects/569/tasks/12/run?trigger=API*
3. Under **Authorization**, select **Basic Auth** and provide your DBSync credentials.
4. Go to the **Body** tab, select *raw* → *JSON*, and enter your payload:

*{*

&#x20;*"customerId": 1001,*

&#x20;*"name": "John Doe",*

&#x20;*"address": {*

&#x20;  *"lineOne": "123 Main Street",*

&#x20;  *"city": "San Jose"*

&#x20;*}*

*}*

5. Click **Send**.
6. Verify that the task is triggered and the values are accessible inside your workflow.

**Example curl Command**

curl -X POST \\

&#x20;"https\://\<your-dbsync-instance>/api/v2/projects/569/tasks/12/run?trigger=API" \\

&#x20;-H "Authorization: Basic \<base64encoded(username:password)>" \\

&#x20;-H "Content-Type: application/json" \\

&#x20;-d '{

&#x20;  "customerId": 1001,

&#x20;  "name": "John Doe",

&#x20;  "address": {

&#x20;    "lineOne": "123 Main Street",

&#x20;    "city": "San Jose"

&#x20;  }

&#x20;}'

## **Key Notes**

* Trigger must always include trigger=API.
* Any JSON payload can be passed and mapped within the flow.
* Nested values are accessed using / notation.
* Supports external triggers from Postman, curl, or third-party tools.
* Authentication is required for all requests.

### 3. GET - /status/{pid}

* **Description**: This API endpoint allows you to check the status of a task.
* **Method**: GET
* **Example**: GET /status/{pid} will return the current status of the task with the specified pid (process ID).
* **Functionality**: This is useful for monitoring the state of a task, such as whether it is running, completed, or encountered an error. The status could be vital for automated systems that need to track the progress of workflows.

### 4. GET - /interrupt/{pid}

* **Description**: This API endpoint allows you to interrupt or stop a running task.
* **Method**: GET
* **Example**: GET /interrupt/{pid} will stop the task identified by the process ID (pid).
* **Functionality**: This is useful when you need to terminate a task that is running longer than expected or if an error requires you to manually stop the task from continuing. It can help manage long-running tasks or handle unexpected situations.

## Additional Information

Functionality: The API section allows users to manage tasks and their execution programmatically. Using the provided endpoints, developers can integrate workflow management into their own systems or automate processes using API calls.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mydbsync.com/cloud-workflow/2026_create-your-workflow/flow-management/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
