I’m trying to trigger an Architect flow from an external Node.js service using the REST API. The goal is to kick off a specific flow execution with a set of input attributes, essentially mimicking what happens when a user clicks a button in a custom agent desktop app, but done server-side via a webhook handler.
Here’s the code snippet I’m using to make the request:
const axios = require('axios');
const token = await getOAuthToken(); // Returns valid Bearer token
const payload = {
flowId: '8a2b3c4d-5e6f-7890-abcd-ef1234567890',
attributes: {
externalId: 'ext-12345',
userContext: { name: 'John Doe' }
}
};
try {
const response = await axios.post(
'https://api.mypurecloud.com/api/v2/flows/executions',
payload,
{
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
);
console.log('Flow started:', response.data);
} catch (error) {
console.error('Error:', error.response.status, error.response.data);
}
The response I get back is consistently a 400 Bad Request. The error body is pretty unhelpful:
{
"errors": [
{
"code": "invalid_request",
"message": "The request body could not be parsed correctly."
}
]
}
I’ve double-checked the flowId and it definitely exists in our Genesys Cloud instance. The token has the flow:read and flow:write scopes. I’ve also tried passing the attributes as a flat object instead of nested, but same result. It feels like the API is rejecting the structure of the JSON payload entirely, but the documentation for this endpoint is sparse on exact schema requirements for the attributes field.
Am I missing a specific wrapper object in the payload? Or is there a known issue with how the API parses complex nested objects in the attributes map? I’ve verified the token is valid by hitting /api/v2/users/me successfully right before this call.
Any ideas on what might be causing the parser to choke? I’m stuck on this one.