I’m trying to trigger a specific Architect flow from an external Node.js service. The endpoint is POST /api/v2/flows/executions. I’ve verified the access token has the flow:execute scope, and the flow ID matches the one in the UI.
The request fails with a 400 Bad Request. The response body is pretty unhelpful:
{
"errors": [
{
"message": "The request body is invalid.",
"parameter": "body"
}
]
}
Here is the code snippet I’m using with the genesys-cloud-nodejs-client SDK:
const { PlatformClient } = require('@gencloudsdk/platform-client-v2');
const client = PlatformClient.init({
clientId: process.env.GENESYS_CLIENT_ID,
clientSecret: process.env.GENESYS_CLIENT_SECRET
});
async function triggerFlow() {
try {
const flowId = 'a1b2c3d4-5678-90ab-cdef-1234567890ab';
// Attempting to pass custom parameters
const payload = {
flowId: flowId,
parameters: {
"caseId": "12345",
"priority": "high"
}
};
const result = await client.flows.executeFlow(flowId, payload);
console.log('Flow executed:', result);
} catch (error) {
console.error('Error triggering flow:', error);
}
}
triggerFlow();
I’ve tried removing the parameters object entirely, just sending the flowId in the URL as required by the SDK, but it still returns 400. If I use Postman with the exact same token and endpoint, it works fine when I send an empty JSON body {}.
Is the SDK expecting a different structure for the body argument in executeFlow? Or is there a known issue with how the Node.js client serializes the request body for this specific endpoint?
I’ve checked the flow configuration in Architect. It’s set to allow external execution. No validation rules are failing on the flow side because the request never seems to reach the flow logic.
Any ideas on what I’m missing here?