Check an invoice against the leak allowance policy
LogsPOST /leak-allowances/assess
Checks whether an invoice of a linked account qualifies for a leak allowance without saving anything. The result says whether it is eligible, why not (for example the policy is disabled, the invoice is closed, the repair window or cooldown applies, or there is not enough history), and the historic average, excess consumption and proposed credit. invoice_id is required; an invoice outside the caller's scope returns 404.
Returns
200 OK
Show attributes
invoice_ideligiblereason_codeStable refusal code for an ineligible invoice; clients translate the value.
one of
policy_disabled,invoice_not_open,repair_window_expired,cooldown_active,insufficient_history,below_excess_threshold,no_credit_valueconsumption_m3historic_avg_m3excess_m3excess_value_centsproposed_credit_centscurrencyrequire_proof
Errors 400
curl -X POST "$CONSUMER_API/leak-allowances/assess" \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{}'
# No matching CLI command; use cURL or direct HTTP.
const res = await fetch("$CONSUMER_API/leak-allowances/assess", {
method: "POST",
headers: {
Authorization: "Bearer sk_test_...",
"Content-Type": "application/json"
},
body: JSON.stringify({})
});
const data = await res.json();
import requests
res = requests.post(
"$CONSUMER_API/leak-allowances/assess",
headers={
"Authorization": "Bearer sk_test_..."
},
json={}
)
data = res.json()
body := strings.NewReader(`{}`)
req, _ := http.NewRequest("POST", "$CONSUMER_API/leak-allowances/assess", body)
req.Header.Set("Authorization", "Bearer sk_test_...")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
{
"invoice_id": "inv_2jnourvAGxXMMd5IyFbwc1LqUX1",
"eligible": true,
"reason_code": "policy_disabled",
"consumption_m3": 13.42,
"historic_avg_m3": 1,
"excess_m3": 1,
"excess_value_cents": 1342,
"proposed_credit_cents": 1,
"currency": "MZN",
"require_proof": true
}