Skip to main content
POST
/
api
/
cotizaciones
curl -X POST 'https://your-domain.com/api/cotizaciones' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: session=your-session-token' \
  -d '{
    "fecha": "2026-02-10",
    "hora": "14:30",
    "impo_expo": "IMPO",
    "fcl_lcl": "LCL",
    "cliente_id": 3,
    "origen_id": 2,
    "via_id": 1,
    "kgs": 500,
    "cbm_facturables": 2.5,
    "cbm_reales": 2.3,
    "detalle": "Electronics components",
    "apilable": "SI",
    "moneda": "USD",
    "gastos_origen_neto": 100,
    "gastos_origen_venta": 150,
    "flete_neto": 500,
    "flete_venta": 650,
    "cerrada": "ENCOTIZACION"
  }'
{
  "id": 15,
  "quote_number": "COT-2602-0015",
  "date": "2026-02-10",
  "time": "14:30",
  "impo_expo": "IMPO",
  "tipo": null,
  "load_type": "LCL",
  "sale_condition": null,
  "client_id": 3,
  "origin_id": 2,
  "via_id": 1,
  "end_client": null,
  "kgs": 500,
  "billable_cbm": 2.5,
  "actual_cbm": 2.3,
  "description": "Electronics components",
  "imo": null,
  "stackable": "SI",
  "pickup_address": null,
  "currency": "USD",
  "origin_costs_net": 100,
  "origin_costs_sale": 150,
  "freight_net": 500,
  "freight_sale": 650,
  "freight_net_type": null,
  "freight_sale_type": null,
  "status": "ENCOTIZACION",
  "close_date": null,
  "sales_order": null,
  "notes": null,
  "reference": null,
  "rate_validity": null,
  "profit": 200,
  "month": 2,
  "year": 2026,
  "week": 7,
  "user_id": 5,
  "created_at": "2026-02-10T14:30:00.000Z",
  "updated_at": "2026-02-10T14:30:00.000Z"
}
Creates a new quotation with auto-generated quotation number.

Authorization

Requires active session. For non-admin users, vendedor_id is automatically set to session.userId (request body value is ignored).

Request Body

fecha
string
default:"current date"
Quotation date
hora
string
default:"current time"
Quotation time
impo_expo
string
default:"IMPO"
Import/Export. Values: IMPO, EXPO
tipo
string
Quotation type (optional)
fcl_lcl
string
default:"LCL"
Load type. Values: FCL, LCL
cond_venta
string
Sale condition (optional)
cliente_id
number
required
Client ID (must exist in clients table)
origen_id
number
Origin location ID (optional)
via_id
number
Via/route location ID (optional)
cliente_final
string
End client name (optional)
kgs
number
Weight in kilograms
cbm_facturables
number
Billable cubic meters
cbm_reales
number
Actual cubic meters
detalle
string
Cargo description
imo
string
IMO classification (for hazardous materials)
apilable
string
Stackable. Values: SI, NO
pickup_address
string
Pickup address (optional)
moneda
string
default:"USD"
Currency. Values: USD, EUR, ARS
gastos_origen_neto
number
Origin costs (net)
gastos_origen_venta
number
Origin costs (sale price)
flete_neto
number
Freight cost (net)
flete_venta
number
Freight cost (sale price)
tipo_fn
string
Freight net type (optional)
tipo_fv
string
Freight sale type (optional)
cerrada
string
default:"ENCOTIZACION"
Status. Values: ENCOTIZACION, SI, NO, PEND, PEND A/C
fecha_cierre
string
Close date (only set when status is SI, NO, or PEND A/C)
orden_venta
string
Sales order reference (optional)
observaciones
string
Notes (optional)
referencia
string
Reference (optional)
validez_tarifa
string
Rate validity (optional)
vendedor_id
number
Seller/user IDAdmin only: Admins can assign quotations to other users. Non-admin users will have this automatically set to their own user ID.

Response

data
object
The created quotation object with all computed fieldsAll other fields from the request body are also returned.
curl -X POST 'https://your-domain.com/api/cotizaciones' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: session=your-session-token' \
  -d '{
    "fecha": "2026-02-10",
    "hora": "14:30",
    "impo_expo": "IMPO",
    "fcl_lcl": "LCL",
    "cliente_id": 3,
    "origen_id": 2,
    "via_id": 1,
    "kgs": 500,
    "cbm_facturables": 2.5,
    "cbm_reales": 2.3,
    "detalle": "Electronics components",
    "apilable": "SI",
    "moneda": "USD",
    "gastos_origen_neto": 100,
    "gastos_origen_venta": 150,
    "flete_neto": 500,
    "flete_venta": 650,
    "cerrada": "ENCOTIZACION"
  }'
{
  "id": 15,
  "quote_number": "COT-2602-0015",
  "date": "2026-02-10",
  "time": "14:30",
  "impo_expo": "IMPO",
  "tipo": null,
  "load_type": "LCL",
  "sale_condition": null,
  "client_id": 3,
  "origin_id": 2,
  "via_id": 1,
  "end_client": null,
  "kgs": 500,
  "billable_cbm": 2.5,
  "actual_cbm": 2.3,
  "description": "Electronics components",
  "imo": null,
  "stackable": "SI",
  "pickup_address": null,
  "currency": "USD",
  "origin_costs_net": 100,
  "origin_costs_sale": 150,
  "freight_net": 500,
  "freight_sale": 650,
  "freight_net_type": null,
  "freight_sale_type": null,
  "status": "ENCOTIZACION",
  "close_date": null,
  "sales_order": null,
  "notes": null,
  "reference": null,
  "rate_validity": null,
  "profit": 200,
  "month": 2,
  "year": 2026,
  "week": 7,
  "user_id": 5,
  "created_at": "2026-02-10T14:30:00.000Z",
  "updated_at": "2026-02-10T14:30:00.000Z"
}

Server Logic

Auto-generated Fields

  1. quote_number: Automatically generated in format COT-YYMM-NNNN
    • Query counts existing quotations in current month
    • Increments sequence number
    • Zero-pads to 4 digits
  2. profit: Calculated as (flete_venta - flete_neto) + (gastos_origen_venta - gastos_origen_neto)
    • Rounded to 2 decimal places
  3. week, month, year: Computed from fecha field
  4. user_id:
    • For admin users: Uses vendedor_id from request body, or falls back to session.userId
    • For non-admin users: Always set to session.userId (ignores request body)
  5. close_date: Only saved when cerrada is SI, NO, or PEND A/C. Otherwise set to null.

Default Values

  • fecha: Current date if not provided
  • hora: Current time if not provided
  • impo_expo: "IMPO"
  • fcl_lcl: "LCL"
  • moneda: "USD"
  • cerrada: "ENCOTIZACION"

Notes

  • The quotation number is sequential per month and resets each month
  • Non-admin users cannot assign quotations to other users
  • Profit is automatically calculated from cost and sale prices

Build docs developers (and LLMs) love