How to Access API Rule Response in Script Node for Validation in Reels Workflow

Hi everyone,

I’m working on a Reels workflow with the following steps:

  1. Input: The workflow takes quote_id as input.
  2. API Rule Node: Calls a deployed SSD API that returns all member details for the given quote_id.
  3. Script Node: In the same workflow, I need to perform age calculation using the API response.
  4. Output: Based on the calculation, the workflow should respond with:OP_valid = true;

Issue I’m facing:
I’m unable to access the API response in the Script Node.
I tried using OP_ and IP_ prefixes, but I can’t get the data returned from the API node inside the script node. How do I correctly access the API response from the API rule in the next Script Node?

@Rocky @Muhammed_Sinan please help

Hi @Rocky , @Muhammed_Sinan

Thanks for checking my post. :folded_hands: This is a bit urgent for my workflow as I’m blocked at the Script Node step.

Hi Athul, could you please share the correct cURL command for the API? I’m not getting any response when I trigger it.

Hello @Athul,

It seems like your API is not working as expected.
Could you please:

  • Verify whether the API is up and functioning correctly?
  • Ensure that any required headers are configured appropriately?

In the meantime, here’s a quick reference on how to consume an API response in the Reels Platform using an API Rule:


:white_check_mark: Steps to Consume API Response in an API Rule

1. Create an API Rule

  • Navigate to the Rules section from the left navigation panel.
  • Click the Add button → Choose Rule.
  • Enter:
    • Rule Name
    • Description
    • Select API Rule as the Rule Type.
  • Click Create.

2. Configure the Rule

  • You’ll be directed to the Rule Details page.
  • Go to the Rule Designer tab.
  • Double-click the rule name to open the editor.
  • You will see three tabs: Rule, Model Editor, and Constants.

3. Define Input and Output Keys

  • Go to the Model Editor tab.
  • Use Add Root in both Input and Output editors to define your structure:
    • Example:
      • Input: inputTitle (string)
      • Output: id (number), outputTitle (string)

4. Configure API Request

  • In the Rule tab:
    • Select the appropriate HTTP method (e.g., POST).
    • Enter the API URL.
    • Configure:
      • Headers (if needed)
      • Request Body – Map input keys
      • After Response – This is critical for consuming the response.

5. Consume the API Response

  • In the After Response section:
    • Click Add Field.
    • Provide the key from the response (e.g., id, title).
    • Map it to your defined output key in the Model Editor.

For example, if the API responds with:

{
  "id": 195,
  "title": "BMW"
}

Then map as:

  • id → Output Target: id
  • title → Output Target: outputTitle

How to consume API response in Script Node:

If you’re getting a response from an API rule, you can access and process it in the Script Node using the IP_ prefix.

:white_check_mark: Step-by-step example:

Let’s say your Api rule returns the following response:

{
  "productId": "1234",
  "productName": "Smart Watch",
  "rating": 4.5
}

To consume this response in your Script Node:

:one: Access the input using the IP_ prefix:

let product = IP_response; // API response 

:two: Write your logic based on the API data:

if (product && product.rating >= 4) {
    OP_valid = true;
} else {
    OP_valid = false;
}

:white_check_mark: Expected Output:

If the rating is 4.5, this script will return:

OP_valid = true;

And Add vaild as output in model Editor

@Rocky , @Sam Thanks a lot for sharing the necessary details! Everything worked perfectly now.