Box Push API — Developer Guide

API for inserting records into MSSQL tables CS_BOX_COIL, CS_BOX_COIL_OCR, CS_BOX_INVOICE, and API_CUSTOMER_PO on database CSMetal_WELLGROW.

Base URL

EnvironmentURL
Productionhttps://mothercoilpo.csmetal.online

All paths below are relative to this base URL.

General conventions

ItemValue
ProtocolHTTPS
Request bodyJSON (Content-Type: application/json)
Character encodingUTF-8
CORSEnabled (Access-Control-Allow-Origin: *)
AuthenticationNone (network access to the host is the boundary)

Response envelope

Success (HTTP 2xx):

{
  "ok": true,
  "message": "pushed to CS_BOX_COIL",
  "table": "CS_BOX_COIL",
  "coil_no": "C-12345"
}

Error (HTTP 4xx / 5xx):

{
  "ok": false,
  "message": "human-readable error description"
}

Duplicate invoice errors also include "status": "INVOICE_DUPLICATE" (see Box Invoice Push).

Validation rules

Health check

Verify API and database connectivity before integrating.

GET /api/health

Success (200)

{
  "ok": true,
  "message": "database reachable"
}

Example

curl -s https://mothercoilpo.csmetal.online/api/health

1. Box Coil Push

Inserts one row into CS_BOX_COIL.

POST /api/box-coil-push

Required field

JSON fieldDB columnTypeMax length
coil_noCOIL_NOstring150

Optional fields

JSON fieldDB columnTypeNotes
po_noPoNostringmax 150
invoice_noINVOICE_NOstringmax 150
spec_and_gradeSPEC_AND_GRADEstringmax 250
mill_mat_specMILL_MAT_SPECstringmax 150
cs_mat_specCS_MAT_SPECstringmax 150
thicknessTHICKNESSnumber (decimal)
widthWIDTHnumber (decimal)
lengthLENGTHinteger
product_massPRODUCT_MASSinteger
mill_nameMILL_NAMEstringmax 250
mill_plant_cdMILL_PLANT_CDstringmax 50
mill_plant_nameMILL_PLANT_NAMEstringmax 150
customer_nameCUSTOMER_NAMEstringmax 150
send_date_timeSEND_DATE_TIMEdatetime (ISO)If omitted, server sets current UTC time

Success response (201)

{
  "ok": true,
  "message": "pushed to CS_BOX_COIL",
  "table": "CS_BOX_COIL",
  "coil_no": "C-12345",
  "invoice_no": "INV-2026-001"
}

Example request

curl -s -X POST https://mothercoilpo.csmetal.online/api/box-coil-push \
  -H "Content-Type: application/json" \
  -d '{
    "coil_no": "C-12345",
    "po_no": "PO-2026-001",
    "invoice_no": "INV-2026-001",
    "spec_and_grade": "SPCC 1.0x1200",
    "thickness": 1.0,
    "width": 1200,
    "length": 2500,
    "product_mass": 18000,
    "mill_name": "Example Mill",
    "customer_name": "Example Customer"
  }'

Example (JavaScript / fetch)

const response = await fetch("https://mothercoilpo.csmetal.online/api/box-coil-push", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    coil_no: "C-12345",
    po_no: "PO-2026-001",
    thickness: 1.0,
    width: 1200,
  }),
});

const data = await response.json();
if (!response.ok || !data.ok) {
  throw new Error(data.message || "box-coil-push failed");
}
console.log(data);

HTTP status codes

CodeMeaning
201Row inserted
400Validation error (e.g. missing coil_no, no valid fields)
500Database error

2. Box Invoice Push

Inserts one row into CS_BOX_INVOICE.

INVOICE_NO is the primary key. Duplicate invoice_no values are rejected.

POST /api/box-invoice-push

Required field

JSON fieldDB columnTypeMax length
invoice_noINVOICE_NOstring (PK)150

Optional fields

JSON fieldDB columnTypeNotes
po_noPoNostringmax 150
vessel_nameVESSEL_NAMEstringmax 150
shipping_markSHIPPING_MARKstringmax 250
total_amountTOTAL_AMOUNTnumber (decimal)
grand_total_amountGRAND_TOTAL_AMOUNTnumber (decimal)
total_net_wtTOTAL_NET_WTinteger
total_gross_wtTOTAL_GROSS_WTinteger
bl_dateBL_DATEdatetime (ISO)
bl_noBL_NOstringmax 150
shippint_agencySHIPPINT_AGENCYstringmax 50 — DB column spelling
port_of_landing_etaPORT_OF_LANDING_ETAdatetime (ISO)
port_of_discharge_etaPORT_OF_DISCHARGE_ETAdatetime (ISO)
net_wtNET_WTinteger
gross_wtGROSS_WTinteger
total_no_packageTOTAL_NO_PACKAGEinteger
port_of_loadingPORT_OF_LOADINGstringmax 50
port_of_dischargePORT_OF_DISCHARGEstringmax 50
paymentPAYMENTstringmax 150
hs_codeHS_CODEstringmax 50

Success response (201)

{
  "ok": true,
  "message": "pushed to CS_BOX_INVOICE",
  "table": "CS_BOX_INVOICE",
  "invoice_no": "INV-2026-001"
}

Duplicate response (409)

Returned when invoice_no already exists in CS_BOX_INVOICE.

{
  "ok": false,
  "status": "INVOICE_DUPLICATE",
  "message": "invoice already exists: INV-2026-001",
  "invoice_no": "INV-2026-001"
}

Example request

curl -s -X POST https://mothercoilpo.csmetal.online/api/box-invoice-push \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_no": "INV-2026-001",
    "po_no": "PO-2026-001",
    "vessel_name": "MV EXAMPLE",
    "bl_no": "BL-999",
    "bl_date": "2026-05-20T10:00:00",
    "total_amount": 50000.50,
    "grand_total_amount": 52000.00,
    "total_net_wt": 18000,
    "total_gross_wt": 18500,
    "port_of_loading": "BKK",
    "port_of_discharge": "SGSIN",
    "payment": "L/C",
    "hs_code": "7209"
  }'

Example (Python / requests)

import requests

url = "https://mothercoilpo.csmetal.online/api/box-invoice-push"
payload = {
    "invoice_no": "INV-2026-001",
    "vessel_name": "MV EXAMPLE",
    "bl_no": "BL-999",
    "total_amount": 50000.50,
}

resp = requests.post(url, json=payload, timeout=30)
data = resp.json()
if resp.status_code == 409 and data.get("status") == "INVOICE_DUPLICATE":
    raise RuntimeError(f"duplicate invoice: {data.get('invoice_no')}")
if not resp.ok or not data.get("ok"):
    raise RuntimeError(data.get("message", resp.text))
print(data)

HTTP status codes

CodeMeaning
201Row inserted
400Validation error (e.g. missing invoice_no, no valid fields)
409Duplicate invoice_no (status: INVOICE_DUPLICATE)
500Database error

3. OCR Coil Push

Inserts one row into CS_BOX_COIL_OCR (OCR-extracted coil / packing-list data).

POST /api/ocr-coil-push

Required field

JSON fieldDB columnTypeMax length
coil_noCOIL_NOstring150

Optional fields

JSON fieldDB columnTypeNotes
mill_mat_specMILL_MAT_SPECstringmax 150
cs_mat_specCS_MAT_SPECstringmax 150
thicknessTHICKNESSnumber (decimal)
widthWIDTHnumber (decimal)
net_wtNET_WTinteger
unit_priceUNIT_PRICEnumber (decimal)
po_noPO_NOstringmax 50
invoice_noINVOICE_NOstringmax 150
invoice_dateINVOICE_DATEdatetime (ISO)
pl_refPL_REFstringmax 150
insurance_cert_noINSURANCE_CERT_NOstringmax 150
bl_noBL_NOstringmax 50
vesselVESSELstringmax 50
eta_thailandETA_THAILANDstringmax 50
millsheet_noMILLSHEET_NOstringmax 50
list_generation_dateLIST_GENERATION_DATEdatetime (ISO)
coil_priceCOIL_PRICEnumber (decimal)

Success response (201)

{
  "ok": true,
  "message": "pushed to CS_BOX_COIL_OCR",
  "table": "CS_BOX_COIL_OCR",
  "coil_no": "C-OCR-001",
  "invoice_no": "INV-2026-001"
}

Example request

curl -s -X POST https://mothercoilpo.csmetal.online/api/ocr-coil-push \
  -H "Content-Type: application/json" \
  -d '{
    "coil_no": "C-OCR-001",
    "po_no": "PO-2026-001",
    "invoice_no": "INV-2026-001",
    "mill_mat_spec": "SPCC",
    "thickness": 1.2,
    "width": 1000,
    "net_wt": 8500,
    "unit_price": 42.5,
    "vessel": "MV EXAMPLE",
    "invoice_date": "2026-05-20T10:00:00"
  }'

HTTP status codes

CodeMeaning
201Row inserted
400Validation error (e.g. missing coil_no, no valid fields)
500Database error

4. Customer PO Push

Inserts one row into API_CUSTOMER_PO (customer purchase-order line data).

POST /api/customer-po-push

Required field

JSON fieldDB columnTypeMax length
po_noPO_NOstring50

Optional fields

JSON fieldDB columnTypeNotes
customerCUSTOMERstringmax 50
source_fileSOURCE_FILEstringmax 150
document_typeDOCUMENT_TYPEstringmax 50
contract_noCONTRACT_NOstringmax 150
vendor_part_noVENDOR_PART_NOstringmax 150
part_namePART_NAMEstringmax 150
mat_specMAT_SPECstringmax 150
thicknessTHICKNESSnumber (decimal)
widthWIDTHnumber (decimal)
lengthLENGTHstringmax 50
sizeSIZEstringmax 50
qtyQTYinteger
unitUNITstringmax 50
due_dateDUE_DATEdatetime (ISO)
unit_priceUNIT_PRICEnumber (decimal)
amountAMOUNTnumber (decimal)
remarkREMARKstringmax 250
update_timeUPDATE_TIMEdatetime (ISO)If omitted, server sets current UTC time

Success response (201)

{
  "ok": true,
  "message": "pushed to API_CUSTOMER_PO",
  "table": "API_CUSTOMER_PO",
  "po_no": "PO-2026-001"
}

Example request

curl -s -X POST https://mothercoilpo.csmetal.online/api/customer-po-push \
  -H "Content-Type: application/json" \
  -d '{
    "po_no": "PO-2026-001",
    "customer": "Example Customer",
    "document_type": "PO",
    "part_name": "Steel Coil",
    "mat_spec": "SPCC",
    "thickness": 1.2,
    "width": 1000,
    "qty": 5,
    "unit": "COIL",
    "unit_price": 42.5,
    "amount": 212.5,
    "due_date": "2026-06-30T00:00:00"
  }'

HTTP status codes

CodeMeaning
201Row inserted
400Validation error (e.g. missing po_no, no valid fields)
500Database error

Sample HTML forms (manual testing)

PageURL
Homehttps://mothercoilpo.csmetal.online/
Box coil form/box-coil
OCR coil form/ocr-coil
Box invoice form/box-invoice
Customer PO form/customer-po
API docs (this page)/api-docs

Backend reference (for maintainers)

ItemLocation
FastAPI app/home/csmetal-mothercoilpo/app/main.py
Coil / OCR coil endpoints/home/csmetal-mothercoilpo/app/routers/coil.py
Customer PO endpoint/home/csmetal-mothercoilpo/app/routers/customer_po.py
Invoice endpoint/home/csmetal-mothercoilpo/app/routers/invoice.py
DB mapping & insert/home/csmetal-mothercoilpo/app/mssql_db.py
Processuvicorn app.main:app on 127.0.0.1:8095 (proxied by nginx)

Database: Microsoft SQL ServerCSMetal_WELLGROW (connection is server-side only; clients do not need DB credentials).

Integration checklist

  1. Call GET /api/health and confirm "ok": true.
  2. Send a test POST with only the required field (coil_no for coil/OCR endpoints, or invoice_no for invoice).
  3. Confirm HTTP 201 and "ok": true in the response body.
  4. Verify the row in MSSQL on CS_BOX_COIL, CS_BOX_COIL_OCR, CS_BOX_INVOICE, or API_CUSTOMER_PO.
  5. Handle "ok": false and non-2xx status codes in your client (including 409 INVOICE_DUPLICATE for invoices).

Changelog

DateChange
2026-05-20Initial document: POST /api/box-coil-push, POST /api/box-invoice-push
2026-05-20box-coil-push: added optional invoice_noINVOICE_NO on CS_BOX_COIL
2026-05-20box-invoice-push: reject duplicate INVOICE_NO with HTTP 409 INVOICE_DUPLICATE
2026-05-21Added POST /api/ocr-coil-pushCS_BOX_COIL_OCR; sample form at /ocr-coil
2026-06-01Added POST /api/customer-po-pushAPI_CUSTOMER_PO; sample form at /customer-po