Using the Decision Service REST API

The Decision Service REST API provides the ability to assess cases against a decision service.

A distinguishing feature of decision services is that the REST API is authored as part of the definition of the decision service.

Single requests

The Decision Service REST API can be used to assess a single case of data through the decision service of either an Intelligent Advisor project that is currently under development or a deployed Intelligent Advisor project, and returns the results.

The request URL that you use will depend on whether you are using an in-development project or a deployed project.

For deployed projects use:

https://{your_site_interface}/determinations-server/v2/{deployment-name}

For project versions in development use:

https://{your_site_interface}/determinations-server/project/v2/{project-name}/{project-version}

For example, a simple shipping rate decision service that has been authored with an input contract of:

Field Name Type
zipcode String
weight Number

and an output contract of:

Field Name Type
rate Number

would have a POST like:

{
    "zipcode": "90210",
    "weight": 25
}

and have a POST response like

{
    "rate": 22.25
}

A more complicated example involving arrays would be:

Field Name Type
age Number
visitedCountries Array
countryCode String
dateVisited Date

with an example POST request like:

{
    "age": 27,
    "visitedCountries": [{
        "countryCode": "UK",
        "dateVisited": "2019-04-06"
    }, {
        "countryCode": "FR",
        "dateVisited": "2019-05-01"
    }]
}

Batch requests

The Decision Service REST API also supports batch submission of requests to the /batch endpoint under the regular Decision Service Rest API.

The request URL that you use will depend on whether you are using an in-development project or a deployed project.

For deployed projects use:

https://{your_site_interface}/determinations-server/v2/{deployment-name}/batch

For project versions in development use:

https://{your_site_interface}/determinations-server/project/v2/{project-name}/{project-version}/batch

The format of POST requests to this endpoint is to pass an array of cases in the format that has been defined by the input contract of the decision service, and the resulting POST response is an array of objects as defined by the output contract of the decision service.

For example, using the shipping rate decision service described above, a valid POST request would be:

[{
    "zipcode": "90210",
    "weight": 25
}, {
    "zipcode": "60613",
    "weight": 15
}]

which would respond with a POST response of the form:

[{
    "rate": 22.25
}, {
    "rate": 14.75
}]