BookmarkSubscribeRSS Feed

SAS Intelligent Decisioning: REST API Definition Node

Started yesterday by
Modified yesterday by
Views 27

In Stable 2026.06, a new node – REST API definition – was added for use in decisions in SAS Intelligent Decisioning.  A REST API definition node enables a decision to send requests to and receive responses from an external API. Using a REST API definition node, you can integrate external services such as large language models (LLMs), credit bureaus, open banking services, email, and other services directly into your decision logic.  Currently, decisions that call a REST API definition node can only be published to the destinations of SAS Microanalytic Service (MAS) or SAS Cloud Analytic Services (CAS).

 

In this post, I will walk you through an example of using the REST API definition to call an API to perform a currency conversion as part of a decision flow in SAS Intelligent Decisioning.

 

 

REST API Example Information

 

In this post I am going to use the BanksRates · Free JSON exchange-rate API.  This is an example request using cURL to find out the exchange rate and resulting amount for converting 100 US Dollars (USD) to Polish Zloty (PLN) using the rate from the National Bank of Poland (NBP) on April 20, 2026.

 

curl -s https://api.banks-rates.com/v1/rate?bank=NBP&date=2026-04-20&from=USD&to=PLN&amount=100 

 

This is the response received from that request:

 

{"direction":"foreign_to_national","requested":{"bank":"NBP","date":"2026-04-20","amount":100,"from":"USD","to":"PLN"},"primary":{"actualDate":"2026-04-20","rate":3.6005,"unit":1,"resultAmount":360.04999999999995,"status":"published"},"previous":{"actualDate":"2025-12-31","rate":3.6016,"unit":1,"resultAmount":360.15999999999997}}

 

Here is a test using the BanksRates API reference page.

 

01_MKQ_APINode1.png

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

Note: A response code of 200 is a successful response.

 

 

Create REST API Definition

 

To create a new REST API definition, select APINode_icon1.png to go to the REST API Definitions page in SAS Intelligent Decisioning and select New REST API Definition.

 

I enter a name for the new REST API definition, select the method type of the API call, and enter its request path.

 

02_MKQ_APINode2.png

 

First, I select the Variables tab.  SAS Intelligent Decisioning automatically records the response body and response status codes in variables named responseBody and responseStatusCode. These variables are required and cannot be deleted or renamed. To capture additional output from other HTTP response headers, map the additional HTTP response headers to output variables in the REST API definition.  I also add variables that I will then map to the REST API query parameters.

 

03_MKQ_APINode6-1024x424.png

 

On the Definition tab, I first enter the information for the Request. In the General section for the request, the Method type for my REST API call is GET, but you also have the option to select POST or HEAD. You can select the Format type for your Request body, the options are: JSON, XML or Plain Text.  In my case, I won’t be using the Request body section; instead, I will use the Query parameters section to send my request details.

 

04_MKQ_APINode3-1024x332.png

 

Next, is the Authorization section where you provide the authorization information for the REST API call.  In my case the Authorization type is None, but the other options are: SAS OAuth, Bearer, API Key Header, API Key Query.  Most REST APIs would need some sort of authorization. For the Bearer, API Key Header, and API Key Query authentication types, consult the documentation for the API that you are accessing for information about generating an authentication key. In SAS Environment Manager, create a credential domain that specifies that authentication key, and specify that domain in the Credential domain name field for the new REST API definition. For more information, see Define the Authentication Domain for External REST API Requests in SAS Intelligent Decisioning: Administrator’s Guide and Define the REST API Request.

 

05_MKQ_APINode4.png

 

Finally, there is the Input section for the request.  I have entered the Request path for my REST API call.  The URL must start with either http:// or https:// . Include any needed HTTP request headers for your REST API call.

 

06_MKQ_APINode5.png

 

Then, I need to enter the Query parameters for my REST API call.  I hardcode the value of FED for the bank from which to get the currency rate. For the other required query parameters of my REST API call, I map them to the variables I created earlier.

 

07_MKQ_APINode7.png

 

Here is all the Request information for my REST API call.

 

08_MKQ_APINode8-1024x785.png

 

Next, I select the Response section.  Here you can enter HTTP response headers.  I don’t have any that are needed for my REST API call.

 

09_MKQ_APINode9-1024x377.png

 

 

Add REST API Definition to Decision Flow

 

Now that the REST API definition has been defined to test it you need to create a decision to call it.  I add a REST API definition node and reference the REST API definition I created called currency_conversion.

 

10_MKQ_APINode10-1024x681.png

 

I have a small test table that I use to run a test of the decision with my REST API node and confirm that the variables responseBody and responseStatusCode returned by the REST API call are populated.

 

11_MKQ_APINode11-1024x214.png

 

Now that I have tested the REST API definition, I build out my decision to parse the responseBody.  I add a Branch node based on the responseStatusCode returned from the REST API call.  In my case 200 is a successful response; anything else is unsuccessful.

 

12_MKQ_APINode12-1024x487.png

 

On the Yes branch, I add Python code file to parse the JSON of a successful response from my REST API.

 

13_MKQ_APINode13-1024x502.png

 

This is the Python code I used for the Yes branch:

 

''' List all output parameters as comma-separated values in the "Output:" docString. Do not specify "None" if there is no output parameter.'''

''' List all Python packages that are not built-in packages in the "DependentPackages:" docString. Separate the package names with commas on a single line. '''

''' DependentPackages: '''

import json

 

def execute (responseBody):

'Output:direction,primary_rate,primary_amount,primary_date,previous_rate,previous_amount,previous_date,diff'

# Parse JSON response

data = json.loads(responseBody)

print("data parsed to json")

diff = 0

 

# Access values

direction = data["direction"]

primary_rate = data["primary"]["rate"]

primary_amount = data["primary"]["resultAmount"]

primary_date = data["primary"]["actualDate"]

previous_rate = data["previous"]["rate"]

previous_amount = data["previous"]["resultAmount"]

previous_date = data["previous"]["actualDate"]

 

# Calculate difference between amounts

diff = primary_amount - previous_amount

 

return direction,primary_rate,primary_amount,primary_date,previous_rate,previous_amount,previous_date,diff

 

On the No branch, I add Python code file to parse the JSON for an unsuccessful response from my REST API.

 

14_MKQ_APINode14-1024x506.png

 

This is the Python code I used for the No branch:

 

''' List all output parameters as comma-separated values in the "Output:" docString. Do not specify "None" if there is no output parameter.'''

''' List all Python packages that are not built-in packages in the "DependentPackages:" docString. Separate the package names with commas on a single line. '''

''' DependentPackages: '''

import json

 

def execute (responseBody):

'Output:error_msg'

# Parse JSON response

data = json.loads(responseBody)

print("data parsed to json")

 

# Access values

error_msg = data["error"]

 

return error_msg

 

Now, that I have added the nodes to parse the response from my REST API, I then re-run the test of my decision and have my responseBody parsed into my decision output variables.

 

15_MKQ_APINode15-1024x140.png

 

 

Summary

 

The REST API definition node allows you to send requests to and receive responses from an external API directly within your decision flow.  For more information, see Working with REST API Definitions in SAS Intelligent Decisioning: User’s Guide.

 

You can easily create this example REST API definition yourself from this post; however, keep in mind that there is a limit to how many free requests that you can send per hour and per day.

 

Thanks to Sebine Jacobson for her help in writing this post on the REST API definition node.

 

 

Find more articles from SAS Global Enablement and Learning here.

Contributors
Version history
Last update:
yesterday
Updated by:

Viya Copilot Motion Graphic.gifViya Copilot Motion Graphic

Ready to see what SAS Viya Copilot can do?

Visit the Tips & Tricks page for setup guidance, demos, and practical examples that show how Copilot supports your workflows.

Get Started →

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags