// Server-side JavaScript (Node 20+ or Bun). Set DECISIONS_API_KEY.
const response = await fetch("https://decisions-api.dev/v1/systemone", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.DECISIONS_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "nace-ai/drex-max-finance",
"state": {
"document": "invoice",
"invoice_number": "INV-2048",
"supplier": "Example Office Supplies",
"total_usd": 1280,
"payment_status": "unpaid",
"duplicate_check": {
"same_supplier_and_invoice_number": true,
"existing_record_status": "paid"
},
"review_policy": "Hold invoices for accounts-payable review when a paid record has the same supplier and invoice number."
},
"questions": {
"route": {
"type": "choice",
"instructions": "Which review queue fits this document?",
"criteria": {
"accounts_payable": "Invoices, payment status and duplicate-payment checks",
"expense_review": "Employee expense reimbursements",
"other": "Other financial documents"
}
},
"review_priority": {
"type": "score",
"instructions": "How urgently does the supplied policy require a review?",
"criteria": [
"No review needed",
"Routine review",
"Hold for review before payment"
]
},
"hold_payment": {
"type": "noul",
"instructions": "Does the supplied review policy require holding this invoice for review?"
}
}
}),
});
const body = await response.json();
if (!response.ok || body.code !== 0) throw new Error(body.message);
console.log(body.data.result.answers);
console.log(body.data.creditsUsed);