Skip to content
BOE Docs

Register and execute

Install the SDK, register a ruleset, and execute it. About five minutes.

Step 1: Install

terminal
npm i @boerules/sdk

The TypeScript package is @boerules/sdk on npm. Python is boerules on PyPI. Java is com.boerules:boerules-sdk on Maven Central.

Step 2: Get a Dev key

Create a key in the console under Keys. Set it as BOE_API_KEY in your shell. The SDK reads it on startup.

terminal
export BOE_API_KEY="[YOUR DEV KEY]"

Step 3: Register a ruleset

A ruleset has an id, an engine mode and a list of rules. This one scores income. Each thousand of income adds one point.

Step 4 runs it. Both steps share one file.

credit-score.ts
import { createBOE } from '@boerules/sdk';

const boe = createBOE(); // reads BOE_API_KEY

const ruleset = await boe.register({
  id: 'credit-score',
  mode: 'scoring',
  rules: [{
    id: 'income-score',
    inputs: [{ name: 'a', type: 'Applicant' }],
    then: { score: ['multiply', 0.001, '$a.income'] },
  }],
});

const decision = await boe.execute(
  ruleset.shortCode,
  { Applicant: [{ income: 82000 }] },
  { version: ruleset.version },
);

Step 4: Execute

Pass the short code, your facts, and the version. Facts are grouped by type, so Applicant holds a list of applicants. Pinning the version gives you the same answer every time.

What you get back

Execute returns one object. These are its fields.

Execute response fields
FieldMeaning
executionIdThe id of this decision. Look it up later in the decision log.
rulesetThe ruleset that ran.
resultThe decision itself. Its shape depends on the engine mode.
engineModeThe engine that produced it, such as scoring.
shortCodeThe short name you call the ruleset by.
versionThe version that answered.
executionTimeMsTime the engine spent on the rules.
totalTimeMsTime for the whole call, including routing.
lineage optionalWhich rules fired and why. Pass lineage: true to include it.

Register response

Register response fields
FieldMeaning
rulesetIdThe permanent id of the ruleset.
shortCodeThe short name to pass to execute.
engineModeThe engine the ruleset is locked to.
versionThe version this register call saved.
createdTrue when the call saved a new version. False when it matched the stored one.
executeUrlThe address on execute.boerules.com that serves this ruleset.

Python names the same fields in snake case, such as short_code. Java reads them through accessors, such as shortCode().

Next: batch and the decision log

Run many decisions at once, then read them back.

  • submitBatchSend many fact sets in one call.
  • pollBatchCheck progress and fetch results.
  • listExecutionsPage through past decisions.
  • getExecutionOpen one decision by its id.

The batch and decision log page is planned.

Errors you may meet

Common SDK errors
ErrorIn plain words
BOEFactValidationErrorThe facts you sent do not match what the ruleset expects. The error lists each field to fix.
BOERulesetNotLiveInEnvironmentErrorThe ruleset exists and has no live version in the environment your key belongs to. Promote a version there first.