API ReferenceRules

Turn a sentence into rules and read them back

POST
/console/api/rules/propose

Parses a plain sentence into the refund rules and returns them in words with a before and after table. Nothing changes until confirmRules is called with the returned rules_hash. The hard ceiling of $100.00 per refund cannot be raised by any sentence.

Authorization

consoleSession csrfToken
clearwake_console<token>

Set by GET /console/api/session. HttpOnly, SameSite=Strict, 8 hours.

In: cookie

X-Clearwake-CSRF<token>

The csrf value from GET /console/api/session, an HMAC of the session id. Required on every POST.

In: header

Request Body

application/json

The sentence and whose rules they are.

A sentence that states refund rules.

text*string

The rules in plain words.

Length1 <= length <= 500
role?string

Whose rules these are.

Default"merchant"

Value in

  • "merchant"
  • "buyer"

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/console/api/rules/propose" \  -H "Content-Type: application/json" \  -d '{    "text": "Refund up to 5 dollars when the parcel is lost",    "role": "merchant"  }'
{  "role": "merchant",  "status": "rule_parser",  "label": "rule parser, not AI",  "question": "",  "changes": [    "no day count in the sentence: kept 10 days"  ],  "rejected": [],  "latency_ms": -1,  "attempts": 0,  "sentence_sha256": "ee3f044b33e961e086bbd54e5f2a17ff052f0a7e705ce5f917d5d09608c3d53c",  "model": "rule parser",  "backend": "rule_parser",  "ok": true,  "readback": [    "Refunds up to $5.00 are made without asking you.",    "Anything above $5.00 is not refunded by the agent: it comes to you with the evidence ready.",    "An order counts as not arrived after 10 days without delivery.",    "The same order is never refunded twice. This is always on in code.",    "Disputes fought with evidence: item not received. Every other kind comes to you.",    "US dollars only. Hard ceiling in code: $100.00 per refund. No sentence can raise it."  ],  "diff": [    {      "field": "Most the agent may refund",      "before": "$5.00",      "after": "$5.00",      "changed": false    },    {      "field": "Approval needed above",      "before": "$2.00",      "after": "$5.00",      "changed": true    },    {      "field": "Days until not arrived",      "before": "10",      "after": "10",      "changed": false    },    {      "field": "Fought with evidence",      "before": "item not received",      "after": "item not received",      "changed": false    }  ],  "rules_hash": "60904ab97652ddc3692a557879844ae9cd949010d18372baa83ec7bcda755d7d"}