← All examples

Trial Expiration

SaaS

Check whether a trial account is still within its trial period.

Policy rule

A **account** is active_trial
  if the __trial_start_date__ of the **account** is within 14 days
  and the __has_converted__ of the **account** is equal to false.

Input schema

{
"properties": {
"account": {
"properties": {
"trial_start_date": {
"type": "string",
"format": "date-time"
},
"has_converted": {
"type": "boolean"
}
},
"required": [
"trial_start_date",
"has_converted"
],
"type": "object"
}
},
"required": [
"account"
],
"title": "Account Model",
"type": "object"
}

Test cases

Active trial

Expect pass
{
"account": {
"trial_start_date": "2026-03-25T11:17:29.137Z",
"has_converted": false
}
}

Expired trial

Expect fail
{
"account": {
"trial_start_date": "2026-02-26T11:17:29.137Z",
"has_converted": 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: {
		"account": {
			"trial_start_date": "2026-03-25T11:17:29.137Z",
			"has_converted": false
		}
	},
});

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

Ready to try this policy?

Open in editor