API reference
Read one factory's production, stock and costs from another program, and make the entries the app makes.
Tokens
The factory owner creates a token in the app under More, Connections. Kamna shows it once. It starts with kmn_ and works on that factory only.
The owner chooses what it may do when creating it: Read, or Read and write. Every token reads everything, costs included. A read and write token also makes entries, as the owner who created it, and the factory's Audit trail marks each one as made through the API.
Send it on every request:
Authorization: Bearer kmn_your_token
A missing, wrong or revoked token answers 401. A revoked token stops working at once. The owner can hold up to 10 tokens and sees when each was last used.
Base address
https://api.kamna.app
Responses are JSON. The version is in the path; /v1 does not change shape underneath you.
Reads
| Request | Returns |
|---|---|
GET /v1/lots | Garment lots, newest first: style, sizes planned, status, delivery date and, for a closed lot, its output. Filter ?status=. |
GET /v1/lots/{id} | One garment lot whole: sizes, colours, cutting and every stage. |
GET /v1/stages | Making stages across lots: vendor, sent and received quantities and dates, bill basis and bill. Filter ?status=, ?lot=, ?from=, ?to=. |
GET /v1/batches | Each send and back of a stage in batches, lots and fabric runs alike: vendor, date, quantity in its own unit, colours, rejects, challan. Quantities only. |
GET /v1/closed-output | Closed lots: pieces out by quality, size and colour; cost per piece for the owner. |
GET /v1/plans | Garment plans, planned or started: style, buyer, sizes, colours, materials; target price and cost for the owner. |
GET /v1/fabric-plans | Fabric plans, planned or started: the fabric, what it makes in kilos or metres, its colours and stages; target cost for the owner. |
GET /v1/lots/{id}/stages/{stageId}/book | One stage of a lot, its book: what reached its door, each vendor with his terms and his dated sends and backs, colours, rejects, due dates and challans, what is still with him, what waits. Bills for the owner. |
GET /v1/fabric-runs/{id}/stages/{stageId}/book | One stage of a fabric run, its book: as a lot's, in kilos or metres. |
GET /v1/purchase-requests | Purchase request lines: material, supplier, quantity asked, received and still open. Quantities only. |
GET /v1/slips | Every slip, newest first: the delivery slips sends printed and the inward slips stock receipts made, each with its number, date, party, what it carried and its file. Filter ?q=, ?from=, ?to=. No money. |
GET /v1/fabric-runs | Fabric runs (knitting, weaving, dyeing, finishing), newest first. |
GET /v1/fabric-runs/{id} | One fabric run: every issue, and every stage in sequence with its colour returns, each in its own unit. |
GET /v1/samples | Samples, garment and fabric, newest first: each with its kind, vendor, lot or fabric plan and run, and sampling cost; material value and total for the owner. |
GET /v1/stock/yarn | Yarn stock: each yarn number with its count, composition, shades and balance in kilos; value for the owner. |
GET /v1/stock/fabric | Fabric stock: each fabric number, knit or woven, its colours and balance in its own unit (kg or m); value for the owner. Filter ?status=. |
GET /v1/stock/trims | Trims stock: each trim number, its type, colours and balance in its own unit; value for the owner. Filter ?status=. |
GET /v1/vendors | Vendors: the job workers stages are sent to, with their job types. |
GET /v1/suppliers | Suppliers: who yarn, fabric and trims are bought from. |
GET /v1/buyers | Buyers named on plans. |
GET /v1/styles | Styles: the templates lots are made from; target price for the owner. |
GET /v1/findings | The owner's open findings, as Home lists them: what Kamna found to check, with its rupee impact. |
Writes
A write needs a read and write token. Send a JSON body with Content-Type: application/json. Each write runs the app's own entry, with the app's own checks, and answers what the app answers: the saved row, 201 for a new entry and 200 for an edit. Ids come from the reads. Fields in bold are required; a field in brackets holds a list of rows with those fields.
| Request | Does |
|---|---|
POST /v1/styles | Add a style.name, category, garment_type, age_group, size_chart, hsn_code, piece_requirement, piece_requirement_unit, target_sp, construction_notes |
PUT /v1/styles/{id} | Edit a style.name, category, garment_type, age_group, size_chart, hsn_code, piece_requirement, piece_requirement_unit, target_sp, construction_notes |
POST /v1/styles/{id}/capture/{lotId} | Save a lot's stages as its style's template.piece_requirement |
POST /v1/vendors | Add a vendor.name, job_types, gstin, address, contact_notes |
PUT /v1/vendors/{id} | Edit a vendor.name, job_types, gstin, address, contact_notes |
POST /v1/stock/yarn | Receive yarn.lot_ref, date, yarn_count, mill, supplier_name, invoice_number, is_dyed, colour, weight_kg, rate_per_kg, valuation, is_opening_balance, comments, spinning_system, ply, fibres (fibre, percent, cotton_combing, cotton_variety), lines (colour, weight_kg, rate_per_kg) |
PUT /v1/stock/yarn/{id} | Edit a yarn receipt.lot_ref, date, yarn_count, mill, supplier_name, invoice_number, is_dyed, colour, weight_kg, rate_per_kg, valuation, is_opening_balance, comments, spinning_system, ply, fibres (fibre, percent, cotton_combing, cotton_variety) |
PUT /v1/stock/yarn/{id}/lines | Split a yarn receipt by shade.lines (id, colour, weight_kg, rate_per_kg) |
POST /v1/stock/yarn/{id}/count | Record a yarn stock check.counted, taken_out, book_seen, note, save_anyway, dead, yarn_lot_line_id |
POST /v1/stock/yarn/{id}/holds/{holdId}/release | Release a plan's or a lot's hold on yarn: it becomes free; the plan reads short again. |
POST /v1/stock/fabric | Receive fabric.lot_ref, date, fabric_class, weight_kg, rate_per_kg, valuation, construction_type, description, gsm, rolls, colour, dia_inches, width_inches, knitting_gauge, loop_length, yarn_count, reed, pick_count, warp_count, weft_count, finish, finishes, supplier, supplier_id, invoice_number, composition, fibres (fibre, percent, cotton_combing, cotton_variety), comments, lines (colour, dia, weight_kg, rate_per_kg, rolls, gsm), request_line_id |
PUT /v1/stock/fabric/{id} | Edit a fabric receipt.lot_ref, date, fabric_class, weight_kg, rate_per_kg, valuation, construction_type, description, gsm, rolls, colour, dia_inches, width_inches, knitting_gauge, loop_length, yarn_count, reed, pick_count, warp_count, weft_count, finish, finishes, supplier, supplier_id, invoice_number, composition, fibres (fibre, percent, cotton_combing, cotton_variety), comments |
PUT /v1/stock/fabric/{id}/lines | Split a fabric receipt by colour and dia or width.lines (id, colour, dia, weight_kg, rate_per_kg, rolls, gsm) |
POST /v1/stock/fabric/{id}/count | Record a fabric stock check.counted, taken_out, book_seen, note, save_anyway, dead, fabric_lot_line_id |
POST /v1/stock/fabric/{id}/holds/{holdId}/release | Release a hold on fabric, as on yarn. |
POST /v1/stock/trims | Receive trims.lot_ref, ta_type, unit_of_measure, quantity, cost_per_pc, value, date, description, supplier, invoice_number, colour, brand, remarks, lines (colour, quantity), request_line_id |
PUT /v1/stock/trims/{id} | Edit a trims receipt.lot_ref, ta_type, unit_of_measure, quantity, cost_per_pc, value, date, description, supplier, invoice_number, colour, brand |
PUT /v1/stock/trims/{id}/lines | Split a trims receipt by colour.lines (id, colour, quantity) |
POST /v1/stock/trims/{id}/count | Record a trims stock check.counted, taken_out, book_seen, note, save_anyway, dead, ta_lot_line_id |
POST /v1/stock/trims/{id}/holds/{holdId}/release | Release a hold on trims, as on yarn. |
POST /v1/plans | Save a garment plan.lot_number, style_id, style_name, buyer_id, buyer_name, order_ref, season, order_qty, piece_weight_g, pieces_per_m, cutting_week, delivery_date, target_sp, target_cost, sizes (label, qty), colours (colour, qty), stages (stage_type, stage_name, vendor_id, planned_rate, back_by), materials (material, name, per_piece, stage_type, stock_lot_id), costs (cost_type, amount) |
PUT /v1/plans/{id} | Edit a plan not yet started.lot_number, style_id, style_name, buyer_id, buyer_name, order_ref, season, order_qty, piece_weight_g, pieces_per_m, cutting_week, delivery_date, target_sp, target_cost, sizes (label, qty), colours (colour, qty), stages (stage_type, stage_name, vendor_id, planned_rate, back_by), materials (material, name, per_piece, stage_type, stock_lot_id), costs (cost_type, amount) |
POST /v1/plans/{id}/start | Start production from a plan: mints the lot.started_on |
POST /v1/fabric-plans | Save a fabric plan.run_number, fabric_style_id, fabric_style_name, fabric_class, construction_type, fibres, gsm, finishes, purpose, needed_by, buyer_name, order_ref, season, dias, first_door_week, target_cost, yarn, yarn_kg, yarn_count, dia_inches, machine_dia, gauge, loop_length_mm, feeders, woven_m, warp_count, weft_count, width_inches, reed, pick_count, colours, stages |
PUT /v1/fabric-plans/{id} | Edit a fabric plan not yet started.run_number, fabric_style_id, fabric_style_name, fabric_class, construction_type, fibres, gsm, finishes, purpose, needed_by, buyer_name, order_ref, season, dias, first_door_week, target_cost, yarn, yarn_kg, yarn_count, dia_inches, machine_dia, gauge, loop_length_mm, feeders, woven_m, warp_count, weft_count, width_inches, reed, pick_count, colours, stages |
POST /v1/fabric-plans/{id}/materials/{mid}/blocks | Hold stock for a fabric plan's yarn or fabric.stock_lot_id, line_id, quantity |
POST /v1/fabric-plans/{id}/requests | Raise a purchase request from a fabric plan.number, supplier_id, supplier, wanted_by, remarks, lines |
POST /v1/fabric-plans/{id}/start | Start production from a fabric plan: mints the run.started_on |
POST /v1/plans/{id}/requests | Raise a purchase request from a plan.number, supplier_id, supplier, wanted_by, remarks, lines (plan_material_id, quantity) |
POST /v1/plans/{id}/materials/{mid}/blocks | Hold stock for a plan's material.stock_lot_id, line_id, quantity |
PUT /v1/purchase-requests/{id}/lines/{lid} | Change a request line's quantity.quantity |
POST /v1/purchase-requests/{id}/close | Close a purchase request short. No body. |
POST /v1/lots | Add a lot (style and pieces).lot_number, started_on, style_id, planned_size, size_run, order_ref, delivery_date, season, target_sp, notes |
PUT /v1/lots/{id} | Edit a lot.lot_number, style_id, planned_size, order_ref, delivery_date, season, target_sp, notes, style_name, ref_jump_ok |
PUT /v1/lots/{id}/sizes | Set a lot's sizes.sizes (id, label, planned_qty) |
PUT /v1/lots/{id}/pricing | Set a lot's selling prices, to shops and online.offline_sp, shopify_sp |
POST /v1/lots/{id}/duplicate | Repeat a lot.lot_number, planned_size |
POST /v1/lots/{id}/cutting | Record a cutting entry.fabrics (fabric_lot_id, fabric_lot_line_id, weight_kg, end_bits_kg), pieces_cut, cut_date, lot_size_id, rate_per_pc, payout, notes, allow_negative_stock |
PUT /v1/lots/{id}/cutting/{entryId} | Edit a cutting entry.fabrics (fabric_lot_id, fabric_lot_line_id, weight_kg, end_bits_kg), pieces_cut, cut_date, lot_size_id, rate_per_pc, payout, notes, allow_negative_stock |
POST /v1/lots/{id}/stages | Add a stage, or add it already sent to a vendor.stage_type, stage_name, sequence_order, vendor_id, vendor_name_override, pieces_out, log_out_date, pieces_in, log_in_date, rate_per_piece, bill_value, bill_basis, due_date, dc_number, rejection_reason, notes |
PUT /v1/lots/{id}/stages/{stageId} | Send a stage, receive it back, or edit it.vendor_id, vendor_name_override, pieces_out, log_out_date, pieces_in, log_in_date, rate_per_piece, bill_value, bill_basis, due_date, dc_number, rejection_reason, notes, materials (material, stock_lot_id, line_id, quantity), allow_negative_stock |
POST /v1/lots/{id}/stages/{stageId}/movements | Send a batch, or receive one: one dated movement of a stage, with its colours. Answers the stage's book.kind, vendor_id, vendor_name, date, qty, lines, rejected, challan, due, last, rate, basis, materials, allow_negative_stock |
PUT /v1/lots/{id}/stages/{stageId}/movements/{moveId} | Correct a batch.kind, vendor_id, vendor_name, date, qty, lines, rejected, challan, due, last, rate, basis |
POST /v1/lots/{id}/stages/{stageId}/items | Add a size or colour line to a stage.label, pieces_in, rate_per_piece, bill_value |
PUT /v1/lots/{id}/stages/{stageId}/items/{itemId} | Edit a stage line.label, pieces_in, rate_per_piece, bill_value |
POST /v1/lots/{id}/stages/{stageId}/trims | Send trims with a stage.ta_lot_id, quantity_used, ta_lot_line_id, allow_negative_stock |
POST /v1/lots/{id}/stages/{stageId}/fabric | Send fabric with a stage.fabric_lot_id, fabric_lot_line_id, stage_id, weight_kg, allow_negative_stock |
POST /v1/lots/{id}/costs | Add another cost to a lot.cost_type, description, amount |
POST /v1/samples | Start a sample by its kind; a lab dip or a knit-down is a fabric sample.type |
PUT /v1/samples/{id} | Edit a sample: name, start date, sampling cost, a fabric sample's vendor.name, started_on, sampling_cost, vendor_id |
PUT /v1/samples/{id}/run | Link a fabric sample to its fabric plan or run, or unlink it. Its cost reaches the run.run_id, fabric_plan_id |
POST /v1/samples/{id}/materials | Call material in to a sample from stock.material, stock_lot_id, line_id, quantity, called_on |
POST /v1/fabric-runs | Start a fabric run.lot_number, date, fabric_style_id, fabric_style_name, fabric_class, construction_type, gsm, yarn_count, dia_inches, description, buyer_id, buyer_name, order_ref, season, needed_by, ref_jump_ok |
PUT /v1/fabric-runs/{id} | Edit a fabric run.lot_number, date, fabric_style_id, fabric_style_name, fabric_class, construction_type, gsm, yarn_count, dia_inches, description, buyer_id, buyer_name, order_ref, season, needed_by, ref_jump_ok, comments |
POST /v1/fabric-runs/{id}/costs | Add another cost to a fabric run.cost_type, description, amount |
POST /v1/fabric-runs/{id}/inputs | Issue yarn or fabric to a run.yarn_lot_id, yarn_lot_line_id, fabric_lot_id, fabric_lot_line_id, weight_kg, issued_on, notes, allow_negative_stock |
PUT /v1/fabric-runs/{id}/inputs/{inputId} | Correct an issue: its quantity or its date. Stock moves by the difference.weight_kg, issued_on, allow_negative_stock |
POST /v1/fabric-runs/{id}/stages | Add a run stage, or add it already sent.stage_type, stage_name, vendor_id, vendor_name_override, in_kg, in_date, out_kg, rejected_kg, out_date, rate_per_kg, bill_value, bill_basis, colour, gauge, loop_length_mm, machine_diameter_in, achieved_gsm, due_date, dc_number, notes |
PUT /v1/fabric-runs/{id}/stages/{stageId} | Send a run stage, receive it back, or edit it.stage_name, sequence_order, vendor_id, vendor_name_override, in_kg, in_date, out_kg, rejected_kg, out_date, rate_per_kg, bill_value, bill_basis, colour, gauge, loop_length_mm, machine_diameter_in, achieved_gsm, due_date, dc_number, notes |
POST /v1/fabric-runs/{id}/stages/{stageId}/movements | Send a batch, or receive one: one dated movement of a run stage, with its colours. Answers the stage's book.kind, vendor_id, vendor_name, date, qty, dias, lines, rejected, challan, due, last, rate, basis |
PUT /v1/fabric-runs/{id}/stages/{stageId}/movements/{moveId} | Correct a batch.kind, vendor_id, vendor_name, date, qty, dias, lines, rejected, challan, due, last, rate, basis |
POST /v1/fabric-runs/{id}/stages/{stageId}/returns | Record a colour coming back from a run stage.colour, out_kg, rejected_kg, rate_per_kg, bill_value, achieved_gsm, out_date |
PUT /v1/fabric-runs/{id}/stages/{stageId}/returns/{returnId} | Edit a run stage return.colour, out_kg, rejected_kg, rate_per_kg, bill_value, achieved_gsm, out_date |
PUT /v1/fabric-styles/{id} | Edit a fabric style.name, construction_type, gsm, yarn_count, dia_inches, width_inches, reed, pick_count, warp_count, weft_count |
POST /v1/fabric-styles/{id}/capture/{runId} | Save a run's stages as its fabric style's template. No body. |
A refused write says why in error: 400 for a field the app cannot take, 404 for an id this factory does not hold, 409 for an entry the app refuses as it stands, such as a name that nearly matches an existing vendor, or more taken out than Kamna shows in stock (send "allow_negative_stock": true once the person has confirmed it). A read-only token's write answers 403 with "code": "read_only_token".
Deleting, closing or reopening a lot or a fabric run, reprinting a challan and uploading documents stay in the app. DELETE answers 405.
Sending a write twice
Send Idempotency-Key with any write: 8 to 64 letters, digits or hyphens, new for each entry. A write repeated with the same key lands once, and the repeat answers the first answer with the header X-Replay: hit. The same key on a different write answers 409.
Access date
Past the factory's access date a write that starts something new (a stock receipt, a purchase request, a plan, a lot, a fabric run, a style, a sample) answers 402 with "code": "access_ended" and the date in access_until. Writes on lots and runs already open carry on to their close, and reads continue.
Pages
A list answers { "data": [...], "next": 123 }. Pass next back as ?after=123 for the following page. next is null on the last page. ?limit= takes 1 to 500 and defaults to 100.
Units and money
Every fabric quantity carries unit: kg for knit, m for woven. A write sends a fabric quantity in weight_kg in the fabric's own unit, kilos for knit and metres for woven, and a new receipt names its fabric_class. A fabric run stage names sent_unit and received_unit, because a woven run goes into the loom as yarn by weight and comes out as fabric by length.
Every stage carries bill_basis: sent when the job was billed on the quantity sent, received when billed on the quantity received. A fabric run stage gives its rate as rate_per_sent_unit or rate_per_received_unit, whichever the basis names; the other is null.
Costs are included. Money figures are plain numbers in the factory's currency. An empty field is null, never an empty string.
Rate limit
120 requests per minute per token, reads and writes together. Past it, the answer is 429 with Retry-After: 60.
Example
curl -H "Authorization: Bearer kmn_your_token" \
"https://api.kamna.app/v1/lots?status=closed&limit=2"
{
"data": [
{ "id": 41, "lot_number": "1041", "style_name": "Romper A",
"status": "closed", "first_quality_pieces": 480,
"raw_cost_per_pc": 62.4, "closed_at": "2026-09-12" },
{ "id": 44, "lot_number": "1044", "style_name": "Vest B",
"status": "closed", "first_quality_pieces": 950,
"raw_cost_per_pc": 38.1, "closed_at": "2026-09-18" }
],
"next": 44
}
A fabric receipt, sent once even if the network drops and the program retries:
curl -X POST "https://api.kamna.app/v1/stock/fabric" -H "Authorization: Bearer kmn_your_token" -H "Content-Type: application/json" -H "Idempotency-Key: tally-inv-4471" -d '{ "date": "2026-10-27", "fabric_class": "knit",
"construction_type": "Single Jersey", "weight_kg": 512.4,
"rate_per_kg": 312.5, "supplier": "Kumar Knits",
"invoice_number": "KK-4471" }'