Getting started

Getting started

Let’s walk through the steps to get up and running on Sperta.

Join a workspace

To join your team’s workspace, you’ll need an invite from the workspace admin. Accept the invite, create an account, and then you’re ready to collaborate with your team.

Create an environment

Each environment is isolated from the others to prevent unintended interference between development, testing, and production processes. Let’s create a Production environment where analysts will collaborate.

image

Create a workflow

Once the Production environment is created, let’s create the first workflow. By default, there are three decisions: Decline, Review, and Approve.

image

Create input features

Features passed into the workflow through API are called input features. Before you can write rules, you must create the workflow's input features. Let’s create 3 features: fraud_score, credit_score, and device_spoofed.

image

Create a rule stage

A rule stage can run multiple rules, and each rule runs independently. Let’s drag and drop the rule stage icon from the left panel and create a rule stage called Fraud Rules. Then remove the connection between start node and end node by selecting the connection and press delete / Backspace on the keyboard. Take a look at Workflow editorWorkflow editor to learn more.

image

After creating the stage, let’s add decisions to the stage. You can add any decisions available in the workflow. Take a look at DecisionsDecisions to learn more.

Once the decisions are added, you can rearrange decision priorities. Let’s set Decline to have a higher priority than Review, and set Review to have a higher priority than Approve to resolve rule decision conflicts. For example, if the stage has two rules, one outputs an Approve decision, and the other outputs a Decline decision, the final decision of the stage will be Decline.

image

Stages can depend on each other. Let’s create another stage Credit Rules that will only be run if the Fraud Rules stage approves the user. Similar to the Fraud Rules stage, we need to add decisions to Credit Rules stage and connect them with the end node since it’s the final stage.

image

Make sure you save the workflow before continuing to the next step.

Create a rule

Now we can create a rule in the Fraud Rules stage. Click Create rule after you open the side panel of the stage. We’ll use the fraud_score and device_spoofed features in the expressions. Each state has an expression and a decision, and the decision will be returned if the expression evaluates to true.

image

Similarly, let’s create a rule in the Credit Rules stage:

image

Create a rollout

After creating a rule, you also need to create a rollout so that the workflow actually runs it. Click on the View rollouts link to get to the rollouts page.

In this case, let’s create a rollout for both rules in Active mode with a 100% rollout percentage:

image

Deploy the workflow

A new workflow version will be generated each time you edit the workflow or create/delete rollouts. Once you are ready, head to the deployments page to deploy the latest workflow version.

image

Execute the workflow

Before executing the workflow, we first need to create an API key in the Production environment.

image

Now let’s call the workflow execution API. Please replace workspace_id and your-api-key with real values in the following request:

curl -X POST 'https://api.sperta.com/v1/workspaces/workspace_id/environments/production/workflows/card_application:execute' \
-u your-api-key: \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": {
        "fraud_score": 0.3, 
        "device_spoofed": false,
        "credit_score": 750.0
    }
}'

You’ll get an Approve decision:

{
    "output":{},
    "decision":"Approve",
    "ruleOutputs":[
        {
            "stepId":"high_risk_user",
            "revisionId":"8f251677",
            "mode":"ACTIVE",
            "nodeId":"fraud_rules",
            "decision":"Approve"
        },
        {
            "stepId":"creditworthy",
            "revisionId":"a35bc30f",
            "mode":"ACTIVE",
            "nodeId":"credit_rules",
            "decision":"Approve"
        }
    ],
    "workflowRevisionId":"73e2da73",
    "executionId": "208aa871-db45-4db5-9c82-312757de3675"
}