Check whether an item can be returned based on the return window and item condition.
A **return** is eligible
if the __purchase_date__ of the **return** is within 30 days
and the __item_condition__ of the **return** is in ["unopened", "like_new", "defective"]
and the __has_receipt__ of the **return** is equal to true.
{
"properties": {
"return": {
"properties": {
"purchase_date": {
"type": "string",
"format": "date-time"
},
"item_condition": {
"type": "string"
},
"has_receipt": {
"type": "boolean"
}
},
"required": [
"purchase_date",
"item_condition",
"has_receipt"
],
"type": "object"
}
},
"required": [
"return"
],
"title": "Return Model",
"type": "object"
}Recent unopened item
Expect pass{
"return": {
"purchase_date": "2026-03-23T11:17:29.137Z",
"item_condition": "unopened",
"has_receipt": true
}
}Used item without receipt
Expect fail{
"return": {
"purchase_date": "2026-03-23T11:17:29.137Z",
"item_condition": "used",
"has_receipt": false
}
}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: {
"return": {
"purchase_date": "2026-03-23T11:17:29.137Z",
"item_condition": "unopened",
"has_receipt": true
}
},
});
if (result.result) {
console.log("policy matched");
} else {
console.log("policy did not match");
}Ready to try this policy?
Open in editor