Expense check against your rules
Every submitted expense is checked against the limits you set. Clean ones are recorded as within policy; only the ones that trip a rule stop and ask you, with the reason attached.
- expenseId
- EXP-0001
- employee
- Sample Person
- amountCents
- 124000
- currency
- USD
- merchant
- Sample Airline
- category
- Flights
- receiptAttached
- true
Sample result: Flagged: amount is over your review threshold. Approved by the reviewer with a note. Decision recorded.
What each step does
Step 1 · Rule check
Your written rules are checked against what arrived. A tripped rule is named, with its reason in plain words.
Step 2 · Sort by the check
The run takes one of two paths, decided by the check before it — never by guessing.
Step 3 · A person decides
The run stops and asks the person named in your settings. The decision window is 72 hours; if it lapses, the run carries on without a decision, and the lapse is on the record. Rejecting always takes a comment. Runs when the check before it matched.
Step 4 · Write it back
The outcome is posted back through the connection you name. The secret stays sealed; the step carries the name only. Runs when the check before it matched.
Step 5 · Shape the note
The wording of the note is shaped from the fields picked below. Runs when the check before it did not match.
Step 6 · Paths join
The two paths join here, and the run continues as one.
Step 7 · The result
This is what the run hands back, written into the run's record where you can read it.
What you'll fill in
These are the only things the template asks of you. Examples teach the shape — they are never values your flow runs on; what you type (or the stated starting value) is what gets used.
| Field | What to put in it | Example |
|---|---|---|
| Review amounts over | Expenses above this amount (in cents) stop for your review. | 10000 |
| Who reviews flagged expenses | The role or person the approval card is addressed to. | Finance approver |
| Send decisions to | The connection, by name, that decisions are posted back through. Optional — leave unset and decisions stay in your runs record only. | A connection you name — never a key pasted here |
Set it up
- Fill in the fields below.
- Name the connections it needs — by name only.
- Look at the trigger preview: what would start a run, counted before anything is armed.
- Review the steps, the rules, and every place a person is asked.
- Create it — then run it once yourself, and read the run's record.
Use this template
The definition
The whole mechanism, before you take it. Package checksums: sha256:b3aab48bc2d0… · sha256:3d180b8d1422… · sha256:38e93c8c8aad…. A flow made from this template carries this template's name and version in its record, and exports in the standard bundle with that provenance.
Advanced · the three files, as written
{
"trigger.json": {
"template": {
"slug": "expense-check-against-your-rules",
"version": 1,
"name": "Expense check against your rules",
"category": "money-expenses",
"outcome": "Every submitted expense is checked against the limits you set. Clean ones are recorded as within policy; only the ones that trip a rule stop and ask you, with the reason attached.",
"outputName": "Decision recorded",
"fits_when": [
"expenses"
],
"needs": []
},
"trigger": {
"type": "webhook.received",
"source": "webhook",
"manifestFields": {
"expenseId": "string!",
"employee": "string!",
"amountCents": "int!",
"currency": "string!",
"merchant": "string!",
"category": "string",
"receiptAttached": "bool!"
}
},
"inputConvention": "envelope",
"variables": [
{
"name": "reviewThreshold",
"kind": "int",
"label": "Review amounts over",
"instruction": "Expenses above this amount (in cents) stop for your review.",
"example": 10000,
"default": 10000
},
{
"name": "approverRole",
"kind": "string",
"label": "Who reviews flagged expenses",
"instruction": "The role or person the approval card is addressed to.",
"example": "Finance approver",
"default": "Approver"
},
{
"name": "resultConnection",
"kind": "connection",
"label": "Send decisions to",
"instruction": "The connection, by name, that decisions are posted back through. Optional — leave unset and decisions stay in your runs record only.",
"optional": true
}
],
"sample": {
"input": {
"expenseId": "EXP-0001",
"employee": "Sample Person",
"amountCents": 124000,
"currency": "USD",
"merchant": "Sample Airline",
"category": "Flights",
"receiptAttached": true
},
"output": "Flagged: amount is over your review threshold. Approved by the reviewer with a note. Decision recorded."
}
},
"flow.json": {
"name": "Expense check against your rules",
"inputConvention": "envelope",
"clefIn": [
{
"ruleset": "expense-policy-starter",
"ids": [
"expense-has-amount"
]
}
],
"steps": [
{
"type": "rulecheck",
"rules": [
{
"ruleset": "expense-policy-starter",
"ids": [
"amount-over-review-threshold",
"receipt-missing"
]
}
]
},
{
"type": "branch",
"conditions": [
{
"path": "steps.0.tripped",
"op": "contains",
"value": "amount-over-review-threshold"
},
{
"path": "steps.0.tripped",
"op": "contains",
"value": "receipt-missing"
}
],
"join": "any"
},
{
"type": "human",
"kind": "approval",
"when": "matched",
"prompt": {
"segments": [
{
"text": "Review this flagged expense: "
},
{
"field": {
"source": "trigger",
"name": "merchant",
"label": "Expense · Merchant"
}
},
{
"text": " — "
},
{
"field": {
"source": "trigger",
"name": "amountCents",
"label": "Expense · Amount"
}
},
{
"text": ". It tripped: "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"tripped"
],
"label": "Policy check · Rules tripped"
}
}
]
},
"due": 259200,
"onExpire": "continue"
},
{
"type": "http",
"method": "POST",
"url": "https://example.com/decisions",
"when": "matched",
"connectionFromVariable": "resultConnection",
"body": {
"segments": [
{
"text": "Decision for "
},
{
"field": {
"source": "trigger",
"name": "expenseId",
"label": "Expense · ID"
}
},
{
"text": ": "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"tripped"
],
"label": "Policy check · Rules tripped"
}
}
]
}
},
{
"type": "transform",
"when": "not-matched",
"template": {
"segments": [
{
"text": "Within policy: "
},
{
"field": {
"source": "trigger",
"name": "expenseId",
"label": "Expense · ID"
}
},
{
"text": " recorded without review."
}
]
}
},
{
"type": "end"
},
{
"type": "output",
"value": {
"segments": [
{
"text": "Decision recorded for "
},
{
"field": {
"source": "trigger",
"name": "expenseId",
"label": "Expense · ID"
}
}
]
}
}
]
},
"rules.json": {
"rulesets": [
{
"name": "expense-policy-starter",
"version": 1,
"rules": [
{
"id": "expense-has-amount",
"on": "step.payload.amountCents",
"op": "missing",
"action": "block",
"msg": "An expense event without an amount is not consumable."
},
{
"id": "amount-over-review-threshold",
"on": "step.payload.amountCents",
"op": "gt",
"valueFromVariable": "reviewThreshold",
"action": "flag",
"msg": "Amount is over your review threshold."
},
{
"id": "receipt-missing",
"on": "step.payload.receiptAttached",
"op": "ne",
"value": true,
"action": "flag",
"msg": "No receipt was attached."
}
]
}
],
"permissions": {
"approvals": {
"approveBeforeSteps": [
2
],
"rejectRequiresComment": true,
"dueSeconds": 259200,
"onExpire": "continue"
},
"connections": {
"required": [],
"optional": [
{
"nameFromVariable": "resultConnection",
"usedBySteps": [
3
]
}
]
}
}
}
}