← All examples

Cover Eligibility

Insurance

Decide whether an applicant can be offered cover based on age, risk score, and claims history.

Policy rule

A **applicant** is eligible for cover
  if §applicant.age is valid
  and §applicant.risk is valid
  and §applicant.history is valid.

applicant.age. A **applicant** passes age_check
  if the __age__ of the **applicant** is greater than or equal to 18
  and the __age__ of the **applicant** is less than or equal to 70.

applicant.risk. A **applicant** passes risk_check
  if the __risk_score__ of the **applicant** is less than 72
  and the __occupation_class__ of the **applicant** is in ["A", "B", "C"].

applicant.history. A **applicant** passes history_check
  if the __claims_last_3_years__ of the **applicant** is less than 3
  and the __cancelled_for_fraud__ of the **applicant** is equal to false.

Run it

Change the policy or the input and evaluate it here — no account needed.

Policy

Input

{ "applicant": { "age": 34, "risk_score": 41, "occupation_class": "B", "claims_last_3_years": 1, "cancelled_for_fraud": false } }
Try:

Input schema

{
"properties": {
"applicant": {
"properties": {
"age": {
"type": "number"
},
"risk_score": {
"type": "number"
},
"occupation_class": {
"type": "string"
},
"claims_last_3_years": {
"type": "number"
},
"cancelled_for_fraud": {
"type": "boolean"
}
},
"required": [
"age",
"risk_score",
"occupation_class",
"claims_last_3_years",
"cancelled_for_fraud"
],
"type": "object"
}
},
"required": [
"applicant"
],
"title": "Applicant Model",
"type": "object"
}

Test cases

Standard applicant

Expect pass
{
"applicant": {
"age": 34,
"risk_score": 41,
"occupation_class": "B",
"claims_last_3_years": 1,
"cancelled_for_fraud": false
}
}

Risk score too high

Expect fail
{
"applicant": {
"age": 34,
"risk_score": 84,
"occupation_class": "B",
"claims_last_3_years": 1,
"cancelled_for_fraud": false
}
}

Integration

Execute this policy from your app using one of the official SDKs.

import { ExecutionClient } from "@policies2/sdk";

const client = new ExecutionClient({
	apiKey: process.env.POLICY_API_KEY!,
	transport: { kind: "rest", baseUrl: "https://api.policy2.net" },
});

const result = await client.executePolicy({
	id: "your-policy-id", // replace with your published policy ID
	reference: "base",
	data: {
		"applicant": {
			"age": 34,
			"risk_score": 41,
			"occupation_class": "B",
			"claims_last_3_years": 1,
			"cancelled_for_fraud": false
		}
	},
});

if (result.result) {
	console.log("policy matched");
} else {
	console.log("policy did not match");
}

Ready to version this policy and wire it into a flow?

Open in editor