> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spn.wtf/llms.txt
> Use this file to discover all available pages before exploring further.

# Karigars API

> Manage karigar (artisan) accounts and ledgers

Karigars are jewelry artisans. Their ledger tracks gold/silver given out (OUT) and received back as finished jewelry (IN).

***

## `GET /karigars`

Get all karigars.

**Response**

```json theme={null}
[
  {
    "id": 1,
    "name": "Ramesh Kumar",
    "cash_balance": 2000.0,
    "crystal_balance": 150.5
  }
]
```

***

## `POST /karigar`

Create a new karigar.

**Request Body**

```json theme={null}
{ "name": "Ramesh Kumar" }
```

***

## `PUT /karigar/{karigar_id}`

Update a karigar's name.

***

## `DELETE /karigar/{karigar_id}`

Delete a karigar and all associated ledger data.

***

## `GET /karigar-ledger/{karigar_id}`

Get the full ledger. Returns ordered rows with IN/OUT entries and running cash and crystal balances.

***

## `POST /karigar-ledger/{karigar_id}`

Add a ledger row.

**Request Body**

```json theme={null}
{
  "date": "2025-01-15",
  "in_entries": [
    {
      "item_name": "Ring",
      "pure_weight": 10.5,
      "fine_percent": 91.6,
      "fine_weight": 9.62,
      "wastage_percent": 2.0,
      "wastage_weight": 0.19,
      "other": 500
    }
  ],
  "out_entries": [
    {
      "item_name": "Gold",
      "weight": 12.0,
      "touch": 99.5,
      "fine_weight": 11.94
    }
  ]
}
```

***

## `PUT /karigar-ledger/{karigar_id}`

Update an existing karigar ledger row.

***

## `GET /karigar-ledger/{karigar_id}/pdf/{side}`

Download karigar ledger as PDF.

| Parameter    | Type    | Values      | Description              |
| ------------ | ------- | ----------- | ------------------------ |
| `karigar_id` | integer | —           | Karigar ID               |
| `side`       | string  | `in`, `out` | Which side of the ledger |

***

## `DELETE /karigar-ledger-row/{row_id}`

Delete an entire karigar ledger row.

## `DELETE /karigar-ledger-row/{row_id}/in`

Delete only the IN section entry of a row.

## `DELETE /karigar-ledger-row/{row_id}/out`

Delete only the OUT section entry of a row.
