# 4. Audit an Adverse Order & Generate Grounds of Appeal
> Run B2 7-Station Judicial Reasoning Auditor (202 async + SSE) and optionally neutralize opposing citations with B3 Counter-Precedent.
Source URL: /docs/recipes/audit-adverse-order

**Problem:** After receiving an adverse judgment or arbitral award, counsel needs structured grounds of appeal mapped to the order's reasoning nodes, statutory limitation clocks, and counter-precedents against authorities relied upon below.

| Step | Endpoint | Scope | Credits |
|---|---|---|---|
| 1. Submit 7-Station order audit (`B2`, async `202`) | `POST /api/v1/in/audit/order` | `ai:run` | 25 |
| 2. Stream SSE progress or poll job | `GET /api/v1/in/jobs/{job_id}/events` | Any | 0 |
| 3. Optional opponent precedent breaker (`B3`) | `POST /api/v1/in/audit/counter-precedent` | `ai:run` | 15 |

<LegalBoundaryNote title="Input Guardrails & Automatic Refund" tone="amber">
<code>order_text</code> is truncated cleanly at 90,000 UTF-8 bytes. Inputs shorter than 120 characters return <code>422 validation_error</code>, and advocate-client privilege enclaves trigger <code>422 privilege_enclave_blocked</code> — both automatically refund the 25 reserved credits.
</LegalBoundaryNote>

## Implementation [#implementation]

<Tabs items={["cURL","Python (vidhi)","TypeScript (@vidhi/sdk)","Go CLI (vidhi)"]}>
<Tab value="cURL">
```bash
# 1. Start async audit job (HTTP 202 Accepted)
JOB_JSON=$(curl -sS -X POST https://api.vidhi.shamik.app/api/v1/in/audit/order \
  -H "Authorization: Bearer $VIDHI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "order_text": "'"$(cat impugned_order.txt | tr '\n' ' ')"'",
    "posture": "first_appeal",
    "decision_date": "2026-10-18",
    "court_name": "High Court of Bombay",
    "appellant_side": "Respondent-Defendant"
  }')
JOB_ID=$(echo "$JOB_JSON" | python3 -c 'import sys,json; print(json.load(sys.stdin)["job_id"])')

# 2. Stream SSE progress (15s keepalives) or poll GET /jobs/{job_id}
curl -N https://api.vidhi.shamik.app/api/v1/in/jobs/$JOB_ID/events \
  -H "Authorization: Bearer $VIDHI_API_KEY"
```
</Tab>

<Tab value="Python (vidhi)">
```python
from vidhi import Vidhi

client = Vidhi()
job = client.audit.order(
    order_text=open("impugned_order.txt").read(),
    posture="first_appeal",
    decision_date="2026-10-18",
    court_name="High Court of Bombay",
    appellant_side="Respondent-Defendant",
)
completed = job.wait()
print(completed.result["appeal_door"])
print(completed.result["audit"]["advocate_weapon"]["grounds_of_appeal"])
```
</Tab>

<Tab value="TypeScript (@vidhi/sdk)">
```ts
import { VidhiClient } from "@vidhi/sdk";

const client = new VidhiClient({ apiKey: process.env.VIDHI_API_KEY! });
const job = await client.audit.order({
  order_text: impugnedOrderText,
  posture: "first_appeal",
  decision_date: "2026-10-18",
  court_name: "High Court of Bombay",
  appellant_side: "Respondent-Defendant",
});

const completed = await job.wait();
console.log(completed.result);
```
</Tab>

<Tab value="Go CLI (vidhi)">
```bash
vidhi audit --file impugned_order.txt --posture first_appeal \
  --decision-date 2026-10-18 --court-name "High Court of Bombay" --wait --json
```
</Tab>
</Tabs>

## Verified Completed `AsyncJobResponse` Excerpt [#verified-completed-asyncjobresponse-excerpt]

```json
{
  "job_id": "2c8d3f22-91a4-4f2d-a6d1-77a98c101234",
  "engine": "audit_order",
  "status": "completed",
  "progress_pct": 100,
  "result": {
    "audit": {
      "reasoning_nodes": [
        { "node_id": "N1", "finding": "Ignored statutory notice bar under s.80 CPC", "severity": "critical" }
      ],
      "advocate_weapon": {
        "grounds_of_appeal": [
          "Ground 1: The learned Single Judge erred in dispensing with mandatory notice scrutiny..."
        ]
      },
      "clocks": [{ "statute": "Limitation Act, 1963 Art. 116", "days_remaining": 14 }],
      "ghost_dissent": { "summary": "Alternative reading of evidentiary burden not addressed." }
    },
    "appeal_door": { "maintainable": true, "forum": "Division Bench" },
    "appeal_caution": null,
    "drafting_markdown": "## Memorandum of Appeal\n...",
    "rehearse_brief": { "opening_submissions": ["..."] }
  },
  "credits_reserved": 25,
  "credits_charged": 25,
  "credits_refunded": 0
}
```