Thank you Gregory for your response, i figured the same and able to get the desired results.
For Example:
{
"message": "Internal Server Error",
"code": "internal.server.error",
"status": 500,
"messageParams": {},
"contextId": "21178bd3-a207-43d1-a635-daa3c3cbfc35",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message: Invoked function failed. Response from function: Function execution failed with error Type: Unhandled; Message: errorType:BusinessError,errorMessage:status:400,success:false,code:BAD_REQUEST,message:Simulated failure via fail flag.,receivedParams:name:test,fail:true,trace:[BusinessError: status:400,success:false,code:BAD_REQUEST,message:Simulated failure via fail flag.,receivedParams:name:test,fail:true, at core (/var/task/index.js:121:15), at Runtime.main [as handler] (/var/task/index.js:200:20), at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1306:29)] [21178bd3-a207-43d1-a635-daa3c3cbfc35]",
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"messageParams": {},
"details": [],
"errors": []
}
]
}
------------------------------
Xavier Vincent
------------------------------
Original Message:
Sent: 12-12-2025 10:06
From: Gregory Cunningham
Subject: Passing HTTP return codes from Genesys Cloud Function
Hi Xavier,
When you run the Function DataAction in the Admin UI in TEST mode, what is the response?
From what you are describing for your return, you are just returning a body that has an error code it it. That is not considered and error. Only failing your function with an error via a throw is going to result in an error. Using test mode should be able to confirm this is what is happening.
Here is an example of what one of our test Functions returns when given a shouldThrow = true argument:
{
"message": "Internal Server Error",
"code": "internal.server.error",
"status": 500,
"messageParams": {},
"contextId": "7e09e985-f217-4076-9119-d3f6046a1129",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message: Invoked function failed. Response from function: Function execution failed with error Type: Unhandled; Message: errorType:Error,errorMessage:Error message,trace:[Error: Error message, at createResponse (/var/task/src/index.js:111:19), at Object.<anonymous> (/var/task/src/index.js:98:39), at step (/var/task/src/index.js:32:23), at Object.next (/var/task/src/index.js:13:53), at /var/task/src/index.js:7:71, at new Promise (<anonymous>), at __awaiter (/var/task/src/index.js:3:12), at exports.handler (/var/task/src/index.js:61:64), at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1306:29)] [7e09e985-f217-4076-9119-d3f6046a1129]",
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"messageParams": {},
"details": [],
"errors": []
}
]
If your are going to be returning a body that might have an error code in it, then you will have to handle that as branching in Architect based on the return value in the body of our response.
I hope this clarifies things. I'll monitor of your reply if you have further questions.
------------------------------
Gregory Cunningham
Software Architect
Original Message:
Sent: 12-11-2025 10:00
From: Xavier Vincent
Subject: Passing HTTP return codes from Genesys Cloud Function
Hi team,
We've implemented a Genesys Cloud Function to host custom business logic and return status information to a Data Action call from Architect. However, when the function returns non-2xx HTTP status codes (for example 401 or 403), the Data Action still takes the "success" route in the flow. I'm looking for the recommended approach to ensure Architect/Data Action follows the intended non-success path.
Problem summary
- We call a Genesys Cloud Function (deployed as a Lambda) from a Data Action / Architect flow.
- The function returns a structured payload with a statusCode (e.g., 400, 401, 403) in the response object.
- Despite the non-2xx statusCode in the payload, the Data Action execution always takes the success branch. It appears the Lambda invocation is considered successful even when the payload signals an error, so Architect doesn't branch as expected.
This is the response from cloud function ...
{
"statusCode": 400,
"headers": {
"Content-Type": "application/json",
"X-HTTP-Status": "400"
},
"body": {
"success": false,
"code": "BAD_REQUEST",
"message": "Simulated failure via fail flag.",
"receivedParams": {
"name": "fail",
"fail": "1"
}
}
}
What we need to know or ask ...?
- What is the recommended way to make Data Action / Architect treat HTTP 4xx/5xx responses as failure paths?
- Should the Cloud Function throw (uncaught) to force a runtime error so the Data Action sees a failure, or is there a supported way for Data Action to inspect the returned statusCode/body and treat certain codes as errors?
- If returning a structured payload is preferred, how should the Data Action be configured to evaluate statusCode or body.success and route appropriately?
- If an actual HTTP status code is required (so Data Action recognizes it automatically), is the recommended pattern to:
- put the Lambda behind API Gateway and call the HTTP endpoint in the Data Action (so the HTTP status line will reflect the statusCode), or
- use any specific Data Action settings to map payload.statusCode to an error?
- Any recommended best practices for:
- consistent response format for Architect mappings,
- headers to include (Retry-After, custom error code),
- whether to return body as JSON object vs. string for easier Architect mapping.
What we've tried so far
- Returning payloads with statusCode and body as an object (as shown above).
- Returning an X-HTTP-Status header alongside Content-Type.
- Simulating an uncaught exception to see if Data Action treats it as an invocation failure (this results in a runtime-level 500/Invocation failure, but we want to preserve detailed error codes such as 401/403).
Impact
- Architect workflows do not take error paths that should be triggered for authentication/authorization problems and other client errors. This affects routing, user prompts, and retry logic.
Thanks - looking forward to your guidance on the best pattern for carrying HTTP status semantics through to Architect/Data Actions.
Best regards, Xavier
#Integrations