# NOMAZRA API Endpoints — Legal Tools (AI-Powered)
Base URL: `https://nomazra.kelthos.com/api/nomazra/`

All endpoints require `Authorization: Bearer <access_token>`

---

## POST /tools/statute-check/
Check which Cambodian laws/statutes apply to a described situation.

**Request Body:**
```json
{
  "description": "My landlord wants to evict me without notice from my rented apartment in Phnom Penh"
}
```

**What happens:**
1. Validates description (1-5000 chars)
2. Calls GPT-4o-mini with the `law_search` tool prompt
3. AI identifies applicable laws, articles, and legal principles
4. Stats updated

**Response 200:**
```json
{
  "applicable_laws": "Based on Cambodian Civil Code and rental regulations...",
  "tokens_used": 456,
  "disclaimer": "This is AI-generated legal information, not legal advice."
}
```

**Errors:**
- 400: `{"error": "description is required"}` / `{"error": "Description too long (max 5000 chars)"}`

---

## POST /tools/cost-estimate/
Estimate legal costs for a described case.

**Request Body:**
```json
{
  "case_type": "property_dispute",
  "description": "Land boundary dispute with neighbor, the land is 500 sqm in Siem Reap province"
}
```

**What happens:**
1. Validates inputs
2. Calls GPT-4o-mini with cost estimation prompt
3. AI provides fee ranges for: lawyer fees, court fees, administrative costs, timeline estimate
4. Stats updated

**Response 200:**
```json
{
  "estimate": {
    "summary": "For a land boundary dispute in Siem Reap...",
    "lawyer_fees": "$500-$2,000 USD",
    "court_fees": "$50-$200 USD", 
    "other_costs": "Survey fees: $100-$300 USD",
    "total_range": "$650-$2,500 USD",
    "timeline": "6-18 months",
    "notes": "Costs vary based on complexity..."
  },
  "tokens_used": 389,
  "disclaimer": "This is an AI-generated estimate. Actual costs may vary."
}
```

**Errors:**
- 400: `{"error": "description is required"}` / `{"error": "Description too long (max 5000 chars)"}`

---

## POST /tools/contract-draft/
**[EXISTS IN AI_SERVICE]** Draft a simple legal document/contract.

**Request Body:**
```json
{
  "contract_type": "rental_agreement",
  "details": "Monthly rent $300, 1 year term, apartment in BKK1, Phnom Penh. Landlord: Mr. Sokha, Tenant: Mr. Veasna"
}
```

**Response 200:**
```json
{
  "draft": "RENTAL AGREEMENT\n\nThis agreement is entered into...",
  "tokens_used": 1245,
  "disclaimer": "This AI-generated draft should be reviewed by a qualified lawyer."
}
```
