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

RequestReturns
GET /v1/lotsGarment 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. A cutting row is one fabric an entry drew: entry_id names the entry, and its pieces and bill stand on its first row only.
GET /v1/stagesMaking stages across lots: vendor, sent and received quantities and dates, bill basis and bill. Filter ?status=, ?lot=, ?from=, ?to=.
GET /v1/batchesEach 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-outputClosed lots: pieces out by quality, size and colour; cost per piece for the owner.
GET /v1/plansGarment plans, planned or started: style, buyer, sizes, colours, materials; target price and cost for the owner.
GET /v1/plans/{id}/prepA prepared lot whole, as lot prep holds it: parts, sizes and colours with ratios, typed counts, jobs with days, vendors and materials, own brand, category, knit or woven, and what is still to tell.
GET /v1/fabric-plansFabric 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}/bookOne 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}/bookOne stage of a fabric run, its book: as a lot's, in kilos or metres.
GET /v1/purchase-requestsPurchase request lines: material, supplier, quantity asked, received and still open. Quantities only. A row's id is its line; request_id is the request that closing or a line edit names.
GET /v1/slipsEvery 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-runsFabric 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/samplesSamples, 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/yarnYarn stock: each yarn number with its count, composition, shades and balance in its unit; value for the owner. Each line carries its id, the line a cut, an issue or a count names.
GET /v1/stock/fabricFabric stock: each fabric number, knit or woven, its colours and balance in its own unit (kg or m); value for the owner. Each line carries its id, the line a cut, an issue or a count names. Filter ?status=.
GET /v1/stock/trimsTrims stock: each trim number, its type, colours and balance in its own unit; value for the owner. Each line carries its id, the line a use or a count names. Filter ?status=.
GET /v1/vendorsVendors: the job workers stages are sent to, with their job types.
GET /v1/suppliersSuppliers: who yarn, fabric and trims are bought from.
GET /v1/buyersBuyers named on plans.
GET /v1/stylesStyles: the templates lots are made from; target price for the owner.
GET /v1/findingsThe 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.

RequestDoes
POST /v1/stylesAdd a style.
name, category, garment_type, age_group, size_chart, stage_chain (stage_type, sequence_order), piece_requirement, piece_requirement_unit, construction_notes, fibres, fabric_class
PUT /v1/styles/{id}Edit a style.
name, category, garment_type, age_group, size_chart, stage_chain (stage_type, sequence_order), piece_requirement, piece_requirement_unit, construction_notes, fibres, fabric_class, photo_url
POST /v1/styles/{id}/capture/{lotId}Save a lot's stages as its style's template.
piece_requirement, piece_requirement_unit
POST /v1/vendorsAdd a vendor.
name, phone
PUT /v1/vendors/{id}Edit a vendor.
name, phone
POST /v1/stock/yarnReceive yarn.
lot_ref, number_once, ref_jump_ok, slip_number, request_line_id, allow_negative_stock, status, is_opening_balance, date, yarn_count, mill, supplier_name, po_number, invoice_number, is_dyed, colour, weight_kg, rate_per_kg, valuation, comments, unit, spinning_system, ply, is_core_spun, is_siro, is_compact, is_gassed, is_mercerised, filaments, effect, certifications, origin, fibres (fibre, percent, cotton_combing, cotton_variety, cotton_grade, id, sort_order), material_change, is_sample, material_id, lines (id, colour, weight_kg, rate_per_kg)
PUT /v1/stock/yarn/{id}Edit a yarn receipt.
lot_ref, number_once, ref_jump_ok, slip_number, allow_negative_stock, status, is_opening_balance, bill_items, reopen, date, yarn_count, mill, supplier_name, po_number, invoice_number, is_dyed, colour, weight_kg, rate_per_kg, valuation, comments, unit, spinning_system, ply, is_core_spun, is_siro, is_compact, is_gassed, is_mercerised, filaments, effect, certifications, origin, fibres (fibre, percent, cotton_combing, cotton_variety, cotton_grade, id, sort_order), material_change
PUT /v1/stock/yarn/{id}/linesSplit a yarn receipt by shade.
lines (id, colour, weight_kg, rate_per_kg), reopen
POST /v1/stock/yarn/{id}/countRecord a yarn stock check.
counted, taken_out, note, save_anyway, reason, dead, yarn_lot_line_id
POST /v1/stock/yarn/{id}/returnReturn yarn to the supplier: a quantity, the day it went back and why, off the receipt or the colour named. Stock drops that day; a quantity only.
quantity, date, reason, yarn_lot_line_id
POST /v1/stock/yarn/{id}/undo-deadBring dead yarn stock back: the shade named, or the one marked dead. Owner only.
yarn_lot_line_id
POST /v1/stock/yarn/{id}/holds/{holdId}/releaseRelease a plan's or a lot's hold on yarn: it becomes free; the plan reads short again.
POST /v1/stock/fabricReceive fabric.
lot_ref, number_once, ref_jump_ok, slip_number, request_line_id, allow_negative_stock, status, is_opening_balance, 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, cotton_grade, id, sort_order), comments, lines (id, colour, dia, weight_kg, rate_per_kg, rolls, gsm)
PUT /v1/stock/fabric/{id}Edit a fabric receipt.
lot_ref, number_once, ref_jump_ok, slip_number, allow_negative_stock, status, is_opening_balance, bill_items, reopen, 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, cotton_grade, id, sort_order), comments
PUT /v1/stock/fabric/{id}/linesSplit a fabric receipt by colour and dia or width.
lines (id, colour, dia, weight_kg, rate_per_kg, rolls, gsm), reopen
POST /v1/stock/fabric/{id}/countRecord a fabric stock check.
counted, taken_out, note, save_anyway, reason, dead, fabric_lot_line_id
POST /v1/stock/fabric/{id}/returnReturn fabric to the supplier: a quantity, the day it went back and why, off the receipt or the colour named. Stock drops that day; a quantity only.
quantity, date, reason, fabric_lot_line_id
POST /v1/stock/fabric/{id}/undo-deadBring dead fabric stock back: the colour named, or the one marked dead. Owner only.
fabric_lot_line_id
POST /v1/stock/fabric/{id}/holds/{holdId}/releaseRelease a hold on fabric, as on yarn.
POST /v1/stock/trimsReceive trims.
lot_ref, number_once, ref_jump_ok, slip_number, request_line_id, status, is_opening_balance, ta_type, subtype, unit_of_measure, quantity, cost_per_pc, value, date, purchase_date, description, supplier, supplier_id, invoice_number, material, colour, brand, finish, width_mm, size_mm, depth, remarks, lines (id, colour, quantity, size, cost_per_pc)
PUT /v1/stock/trims/{id}Edit a trims receipt.
lot_ref, number_once, ref_jump_ok, slip_number, allow_negative_stock, status, is_opening_balance, bill_items, reopen, ta_type, subtype, unit_of_measure, quantity, cost_per_pc, value, date, purchase_date, description, supplier, supplier_id, invoice_number, material, colour, brand, finish, width_mm, size_mm, depth, remarks
PUT /v1/stock/trims/{id}/linesSplit a trims receipt by colour.
lines (id, colour, quantity, size, cost_per_pc), reopen
POST /v1/stock/trims/{id}/countRecord a trims stock check.
counted, taken_out, note, save_anyway, reason, dead, ta_lot_line_id
POST /v1/stock/trims/{id}/returnReturn trims to the supplier: a quantity, the day it went back and why, off the receipt or the colour named. Stock drops that day; a quantity only.
quantity, date, reason, ta_lot_line_id
POST /v1/stock/trims/{id}/undo-deadBring dead trims stock back: the colour named, or the one marked dead. Owner only.
ta_lot_line_id
POST /v1/stock/trims/{id}/holds/{holdId}/releaseRelease a hold on trims, as on yarn.
POST /v1/plansSave a garment plan. A field it does not keep is refused by name; lot prep's fields go to Prepare a lot.
lot_number, number_once, ref_jump_ok, style_id, style_name, buyer_id, buyer_name, order_ref, order_qty, piece_weight_g, m_per_piece, pieces_per_m, cutting_week, delivery_date, target_sp, target_cost, sizes (label, qty), colours (colour, qty), stages (stage_type, stage_name, vendor_id, vendor_name, planned_rate, back_by), materials (id, material, name, unit, per_piece, stage_type, stock_lot_id, line_id, more_lots), costs (cost_type, amount)
POST /v1/plans/prepPrepare a lot whole: its parts, sizes and colours with their ratios, typed counts, jobs with days, vendors and materials, own brand, category and knit or woven.
lot_number, number_once, style_id, style_name, own_brand, buyer_id, buyer_name, order_ref, delivery_date, category, fabric_class, order_qty, target_sp, target_cost, parts (name, per_set), sizes (label, ratio), colours (colour), ratios (part, colour, ratio), cells (part, size, colour, qty), jobs (stage_type, stage_name, part, days, vendors, materials)
PUT /v1/plans/{id}/prepChange a prepared lot, whole: every field as on Prepare a lot; what is left out is removed.
lot_number, number_once, style_id, style_name, own_brand, buyer_id, buyer_name, order_ref, delivery_date, category, fabric_class, order_qty, target_sp, target_cost, parts (name, per_set), sizes (label, ratio), colours (colour), ratios (part, colour, ratio), cells (part, size, colour, qty), jobs (stage_type, stage_name, part, days, vendors, materials)
PUT /v1/plans/{id}Edit a plan not yet started.
lot_number, number_once, ref_jump_ok, style_id, style_name, buyer_id, buyer_name, order_ref, order_qty, piece_weight_g, m_per_piece, pieces_per_m, cutting_week, delivery_date, target_sp, target_cost, sizes (label, qty), colours (colour, qty), stages (stage_type, stage_name, vendor_id, vendor_name, planned_rate, back_by), materials (id, material, name, unit, per_piece, stage_type, stock_lot_id, line_id, more_lots), costs (cost_type, amount)
POST /v1/plans/{id}/startStart production from a plan: mints the lot.
started_on
POST /v1/fabric-plansSave a fabric plan.
run_number, number_once, ref_jump_ok, fabric_style_id, fabric_style_name, fabric_class, starts_from, construction_type, fibres (fibre, percent, cotton_combing, cotton_variety), gsm, finishes, purpose, needed_by, buyer_id, buyer_name, order_ref, first_door_week, target_cost, costs (cost_type, amount), yarn, yarn_kg, programme_stock_lots (stock_lot_id, line_id), yarn_count, dia_inches, machine_dia, gauge, loop_length_mm, feeders, woven_m, warp_count, weft_count, width_inches, reed, pick_count, dias (dia, qty), colours (colour, qty), materials (id, material, name, unit, need, stock_lots), stages (stage_type, stage_name, vendor_id, vendor_name, planned_rate, back_by)
PUT /v1/fabric-plans/{id}Edit a fabric plan not yet started.
run_number, number_once, ref_jump_ok, fabric_style_id, fabric_style_name, fabric_class, starts_from, construction_type, fibres (fibre, percent, cotton_combing, cotton_variety), gsm, finishes, purpose, needed_by, buyer_id, buyer_name, order_ref, first_door_week, target_cost, costs (cost_type, amount), yarn, yarn_kg, programme_stock_lots (stock_lot_id, line_id), yarn_count, dia_inches, machine_dia, gauge, loop_length_mm, feeders, woven_m, warp_count, weft_count, width_inches, reed, pick_count, dias (dia, qty), colours (colour, qty), materials (id, material, name, unit, need, stock_lots), stages (stage_type, stage_name, vendor_id, vendor_name, planned_rate, back_by)
POST /v1/fabric-plans/{id}/materials/{mid}/blocksHold stock for a fabric plan's yarn or fabric.
stock_lot_id, line_id, quantity
POST /v1/fabric-plans/{id}/requestsRaise a purchase request from a fabric plan.
number, number_once, ref_jump_ok, supplier_id, supplier, wanted_by, remarks, lines (plan_material_id, quantity)
POST /v1/fabric-plans/{id}/startStart production from a fabric plan: mints the run.
started_on
POST /v1/plans/{id}/requestsRaise a purchase request from a plan.
number, number_once, ref_jump_ok, supplier_id, supplier, wanted_by, remarks, lines (plan_material_id, quantity)
POST /v1/plans/{id}/materials/{mid}/blocksHold 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}/closeClose a purchase request short. No body.
POST /v1/lotsAdd a lot (style and pieces).
lot_number, number_once, ref_jump_ok, started_on, style_id, style_name, size_run, fabric_class, planned_size, order_ref, delivery_date, target_sp, notes
PUT /v1/lots/{id}Edit a lot.
lot_number, started_on, style_id, style_name, size_run, season, planned_size, order_ref, delivery_date, target_sp, notes
PUT /v1/lots/{id}/sizesSet a lot's sizes.
sizes (id, label, planned_qty)
POST /v1/lots/{id}/duplicateRepeat a lot.
lot_number, number_once, ref_jump_ok, planned_size, order_ref, delivery_date, target_sp, notes
PUT /v1/lots/{id}/programmeSave a lot's programme: parts, sizes, colours, how many, ratios, typed counts and dias. Whole: what is left out is removed.
parts (name, per_set), sizes (label, ratio), colours (colour), order_qty, ratios (part, colour, ratio), cells (part, size, colour, qty), dias (dia, size, ratio)
POST /v1/lots/{id}/cutting/outCutting Out at the door: the cloth that goes to a cutter, out of stock.
date, vendor_id, vendor_name, in_house, fabrics (fabric_lot_id, fabric_lot_line_id, qty, rolls), due, challan, number_once, notes, entry_key, allow_negative_stock
POST /v1/lots/{id}/cutting/inCutting In at the door: pieces cut by colour and size, and the cloth that came back. Never past the programme.
date, vendor_id, vendor_name, in_house, colours (colour, part, sizes), fabric (issue_id, back_kg, back_m, end_bits_kg, end_bits_m, rolls_back), rate, basis, challan, notes, entry_key
POST /v1/lots/{id}/cuttingRecord a cutting entry.
fabrics (fabric_lot_id, fabric_lot_line_id, weight_kg, end_bits_kg), pieces_cut, lot_size_id, rate_per_pc, payout, allow_negative_stock, flags_ok, cut_date, notes, fabric_lot_id, fabric_lot_line_id, cut_kg
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, lot_size_id, rate_per_pc, payout, allow_negative_stock, flags_ok, cut_date, week_start, notes, comments
POST /v1/lots/{id}/stagesAdd a stage, or add it already sent to a vendor.
stage_type, stage_name, sequence_order, is_applicable, part, vendor_id, vendor_name_override, bill_value, bill_basis, due_date, dc_number, number_once, notes, pieces_out, log_out_date, pieces_in, pieces_rejected, log_in_date, rate_per_piece, rejection_reason
PUT /v1/lots/{id}/stages/{stageId}Send a stage, receive it back, or edit it.
vendor_id, vendor_name_override, bill_value, bill_basis, due_date, dc_number, number_once, notes, pieces_out, log_out_date, pieces_in, pieces_rejected, log_in_date, rate_per_piece, rejection_reason, sequence_order, is_applicable, materials (material, stock_lot_id, line_id, quantity), allow_negative_stock
POST /v1/lots/{id}/stages/{stageId}/movementsSend a batch, or receive one: one dated movement of a stage, with its colours. Answers the stage's book.
kind, vendor_id, vendor_name, in_house, date, qty, dias (dia, qty), lines (colour, qty, rate, rejected, reasons, sizes), rejected, challan, number_once, due, last, late_ok, earlier_rates (colour, rate), rate, basis, notes, materials (material, stock_lot_id, line_id, quantity), allow_negative_stock
PUT /v1/lots/{id}/stages/{stageId}/movements/{moveId}Correct a batch.
kind, vendor_id, vendor_name, in_house, date, qty, dias (dia, qty), lines (colour, qty, rate, rejected, reasons, sizes), rejected, challan, number_once, due, last, late_ok, earlier_rates (colour, rate), rate, basis, notes
POST /v1/lots/{id}/stages/{stageId}/itemsAdd 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}/trimsSend trims with a stage.
ta_lot_id, ta_lot_line_id, quantity_used, allow_negative_stock
POST /v1/lots/{id}/stages/{stageId}/fabricSend fabric with a stage.
fabric_lot_id, fabric_lot_line_id, weight_kg, allow_negative_stock
POST /v1/lots/{id}/costsAdd another cost to a lot.
cost_type, description, amount
POST /v1/samplesStart a sample by its kind; a lab dip or a knit-down is a fabric sample.
type, number, number_once
PUT /v1/samples/{id}Edit a sample: name, start date, sampling cost, a fabric sample's vendor.
name, started_on, processes (side, name), sampling_cost, vendor_id
PUT /v1/samples/{id}/runLink 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}/materialsCall material in to a sample from stock.
material, stock_lot_id, line_id, quantity, called_on, allow_negative_stock
POST /v1/fabric-runsStart a fabric run.
lot_number, number_once, ref_jump_ok, date, starts_from, fabric_style_id, fabric_style_name, fabric_class, construction_type, gsm, yarn_count, dia_inches, width_inches, reed, pick_count, warp_count, weft_count, description, comments, buyer_id, buyer_name, order_ref, needed_by
PUT /v1/fabric-runs/{id}Edit a fabric run.
lot_number, date, season, fabric_style_id, fabric_style_name, fabric_class, construction_type, gsm, yarn_count, dia_inches, width_inches, reed, pick_count, warp_count, weft_count, description, comments, buyer_id, buyer_name, order_ref, needed_by
PUT /v1/fabric-runs/{id}/programmeSave a fabric run's programme: dias or widths, colours, how many, ratios, typed counts and the machine. Whole: what is left out is removed.
axes (value, ratio), colours (colour, ratio), qty, cells (at, colour, qty), gauge, loop_length_mm, feeders, weft_feeders, reed, pick_count, machine
POST /v1/fabric-runs/{id}/costsAdd another cost to a fabric run.
cost_type, description, amount
POST /v1/fabric-runs/{id}/inputsIssue yarn or fabric to a run.
yarn_lot_id, yarn_lot_line_id, fabric_lot_id, fabric_lot_line_id, stage_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}/stagesAdd a run stage, or add it already sent.
stage_type, stage_name, is_applicable, vendor_id, vendor_name_override, bill_value, bill_basis, due_date, dc_number, number_once, notes, in_kg, in_date, out_kg, rejected_kg, out_date, rate_per_kg, colour, gauge, loop_length_mm, machine_diameter_in, feeders, achieved_gsm
PUT /v1/fabric-runs/{id}/stages/{stageId}Send a run stage, receive it back, or edit it.
vendor_id, vendor_name_override, bill_value, bill_basis, due_date, dc_number, number_once, notes, in_kg, in_date, out_kg, rejected_kg, out_date, rate_per_kg, colour, gauge, loop_length_mm, machine_diameter_in, feeders, achieved_gsm, stage_name, sequence_order, is_applicable
POST /v1/fabric-runs/{id}/stages/{stageId}/movementsSend 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, in_house, date, qty, dias (dia, qty), lines (colour, qty, rate, rejected, reasons, sizes), rejected, challan, number_once, due, last, late_ok, earlier_rates (colour, rate), rate, basis, notes
PUT /v1/fabric-runs/{id}/stages/{stageId}/movements/{moveId}Correct a batch.
kind, vendor_id, vendor_name, in_house, date, qty, dias (dia, qty), lines (colour, qty, rate, rejected, reasons, sizes), rejected, challan, number_once, due, last, late_ok, earlier_rates (colour, rate), rate, basis, notes
POST /v1/fabric-runs/{id}/stages/{stageId}/returnsRecord a colour coming back from a run stage.
colour, out_kg, rejected_kg, rate_per_kg, bill_value, achieved_gsm, out_date, sort_order
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, sort_order
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, fabric_class, starts_from
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" }'