DevelopersDocsGuides

Draft a petition

Build a drafting flow. Work out limitation and court fee in code, find authorities with citations, then draft with the API for an advocate to review.

A first draft of a petition or a notice takes an advocate hours of typing. The API can produce that draft in minutes, for the advocate to review, correct and sign. This guide builds the flow in the right order: facts and rules in code first, authorities next, AI prose last.

Nothing here files anything in a court. A draft is a proposal. The advocate decides.

#The order that works

  1. Collect the facts from a form: parties, dates, amounts, the story in a few lines.
  2. Work out limitation in code. A deadline is never decided by AI.
  3. Work out court fee in code.
  4. Find authorities that you can cite, each with a paragraph.
  5. Draft with POST /drafts.
  6. Show the advocate what is blank or unverified before anything is exported.

#1. Collect the facts

Take structured facts, not free text where you can. Dates as yyyy-MM-dd, amounts in rupees as numbers. A vakalatnama (the client's written authority for the advocate) is not a fact you collect here; the advocate attaches it when filing.

Ask GET /drafts/blueprints for the document you want and the facts it needs, each with a name, a label and whether it is required. For a legal_notice they are subject, facts, demand and days.

{
  "subject": "Recovery of ₹5,00,000 due on a dishonoured cheque",
  "facts": "Cheque no. 004512 dated 2026-09-20, issued towards supply of goods, was returned unpaid on 2026-10-02 for insufficient funds.",
  "demand": "Pay ₹5,00,000 within the time below.",
  "days": 15
}

#2. Work out limitation

For a cheque-bounce notice the time runs from the day the drawer's bank returns the cheque.

curl -X POST https://adv.heliosynctech.com/api/v1/limitation \
  -H "Authorization: Bearer $AOS_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "rule": "ni138_notice", "start": "2026-10-02" }'
{
  "object": "limitation",
  "rule": "ni138_notice",
  "basis": "Negotiable Instruments Act, s.138(b)",
  "start": "2026-10-02",
  "raw_due": "2026-11-01",
  "due": "2026-11-02",
  "steps": ["…", "Sun 01.11.2026 the court is closed (Sunday); under s.4 the filing is in time on the next day it sits.", "Last day: Mon 02.11.2026."]
}

Show due to the advocate at the top of the draft screen, in plain sight, with the steps one click away. If it has passed, say so before they read a word. Get the list of rules from GET /limitation/rules. It costs ₹1.

#3. Work out court fee

curl -X POST https://adv.heliosynctech.com/api/v1/court-fee \
  -H "Authorization: Bearer $AOS_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "state": "Karnataka", "value": 500000 }'

It costs ₹0.50. The response gives the fee, the Act and article it comes from and the working. We work it for Karnataka, Rajasthan, Kerala, Telangana, Maharashtra and Gujarat; any other State returns state_not_supported, so ask the advocate to enter the fee by hand.

#4. Find authorities

Search for the judgments you may want to cite and read them by paragraph, as in RAG over judgments. Or ask one question:

curl -X POST https://adv.heliosynctech.com/api/v1/research/answers \
  -H "Authorization: Bearer $AOS_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "question": "Is a legal notice under s.138 NI Act valid if it demands more than the cheque amount?" }'

Keep the sources (judgment id and paragraph label) with each point. They become the footnotes the advocate checks.

#5. Draft

curl -X POST https://adv.heliosynctech.com/api/v1/drafts \
  -H "Authorization: Bearer $AOS_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "blueprint": "legal_notice",
    "facts": {
      "subject": "Recovery of ₹5,00,000 due on a dishonoured cheque",
      "facts": "Cheque no. 004512 dated 2026-09-20 was returned unpaid on 2026-10-02 for insufficient funds.",
      "demand": "Pay ₹5,00,000 within the time below.",
      "days": 15
    }
  }'
const res = await fetch(`${process.env.AOS_API_BASE}/drafts`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AOS_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({ blueprint: "legal_notice", facts }),
});
const draft = await res.json();
import os, uuid, requests

draft = requests.post(
    f"{os.environ['AOS_API_BASE']}/drafts",
    headers={"Authorization": f"Bearer {os.environ['AOS_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={"blueprint": "legal_notice", "facts": facts},
    timeout=60,
).json()

A draft costs ₹10. With a test key you get a fixed sample marked "sandbox": true, which is enough to build your screens. An unknown blueprint returns unknown_blueprint, and a required fact you left out returns missing_fact naming it. The draft also opens in the firm's Drafting Studio.

#6. Show what is open

The response has the draft as html, and warnings. Anything the facts did not supply is left as a blank, or marked [VERIFY], instead of being invented.

{
  "object": "draft",
  "id": 311,
  "blueprint": "legal_notice",
  "title": "Legal notice",
  "language": "en",
  "status": "ready",
  "html": "<p><strong>Legal notice</strong></p><p>1. My client, …</p><p>[VERIFY] …</p>",
  "warnings": []
}

Find the [VERIFY] marks and blanks in html and list them yourself, as the open items.

Build your screen so that:

  • Open items (blanks and [VERIFY] marks) are listed first, and the draft cannot be exported while any remain. This is how Advocate OS itself works: a draft with open blanks or [VERIFY] marks is blocked from export.
  • Every authority has its paragraph one click away.
  • The limitation date and the court fee are shown beside the draft, as numbers from code.
  • The advocate's name is on it, not yours. An AI draft is not legal advice.

#Cost of a first draft

Limitation ₹1, court fee ₹0.50, one research answer ₹25 and the draft ₹10. Reuse authorities across drafts of the same kind; they do not change.