Skip to content

External Synchronous Tasks

Most workflows are asynchronous and are run based on a 'triggerKey'; this applies to both internal and external events. But there are some cases where an external request needs to be run synchronously. This section describes how to setup a workflow for that and how to call it.

Workflow Setup

The workflow will be setup the same as an asynchronous workflow; with the main difference being the tasks on the workflow. Specifically when the workflow is run, only the 1st action will be run. Other than that, the workflow will be the same as any other workflow.

Recommendation - Ensure external synchronous tasks are small and fast

In order to get a succesful response from the synchronous task, it must complete within 30 seconds, the limit of our HTTP requests. If a task takes a long time to run, you may find that it often timesout with a 504 error. If you run into this issue, try using one of the other External Event approaches.

Request call

To execute the synchronous call make a POST request to https://api.vibeiq.com/prod/api/event-workflow-requests/synchronous/ with a JSON payload containing the following properties:

  • triggerKey (string): The 'triggerKey' of the event workflow.
  • event (object): The data needed to run the request.

Sample payload:

const axios = require('axios')
const response = axios.post(
  'https://api.vibeiq.com/prod/api/event-workflow-requests/synchronous/',
  {
    "triggerKey": "item|getValidationInfo",
    "event": {
      "season": {
        "seasonName": "Fall 2024"
      },
      "product": {
        "vibeIQIdentifier": 1641
      }
    },
  },
  {
    headers: {
      {
        "Content-Type": "application/json",
        "Authorization": "bearer AUTH_TOKEN"
      }
    }
  }
)
curl --request PUT \
  --url https://api.vibeiq.com/prod/api/event-workflow-requests/synchronous \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: API_KEY' \
  --header 'X-Api-Org: ORG_KEY' \
  --data '{
    "triggerKey": "item|getValidationInfo",
    "event": {
      "season": {
        "seasonName": "Fall 2024"
      },
      "product": {
        "vibeIQIdentifier": 1641
      }
    },
  }'
import org.json.JSONObject;
import com.vibeiq.sdk.config.Config;
import com.vibeiq.sdk.core.request.ApiKeyRequestModule;
import com.vibeiq.sdk.synchronousevents.SynchronousEvents;

Map<String, String> config = new HashMap<String, String>();
config.put(Config.API_USER_TOKEN, "xApiKey");
config.put(Config.ORG_SLUG, "xApiOrg");
config.put(Config.API_GATEWAY, "apiGateway");

Config.setConfig(config);
JSONObject payload = new JSONObject();
payload.put("triggerKey", "item|getValidationInfo");
JSONObject event = new JSONObject();
JSONObject season = new JSONObject();
season.put("seasonName",  "Fall 2024");
event.put("season", season);
JSONObject product = new JSONObject();
product.put("vibeIQIdentifier",  "1641");
event.put("product", product);

payload.put("event", event);
SynchronousEvents se = new SynchronousEvents(new ApiKeyRequestModule());

JSONObject results = se.sendRequest(payload, false);