Skip to main content
POST
/
venta
curl -X POST https://api.example.com/venta \
  -H "Content-Type: application/json" \
  -d '{
    "descripcion": "Venta de productos electrónicos",
    "clienteId": 123,
    "formapagoId": 1,
    "detalle": [
      {
        "productoId": 456,
        "cantidad": 2.0,
        "precio": 118.0
      },
      {
        "productoId": 789,
        "cantidad": 1.0,
        "precio": 59.0
      }
    ]
  }'
{
  "id": 1,
  "serie": "XYZ",
  "numero": "000123",
  "descripcion": "Venta de productos electrónicos",
  "clienteId": 123,
  "cliente": {
    "id": 123,
    "dni": "12345678",
    "nombre": "Juan",
    "apellido": "Pérez"
  },
  "formapagoId": 1,
  "formaPago": {
    "id": 1,
    "nombre": "Efectivo"
  },
  "fechaVenta": "2026-03-06T10:30:00",
  "baseImponible": 250.0,
  "igv": 45.0,
  "total": 295.0,
  "detalle": [
    {
      "id": 1,
      "productoId": 456,
      "producto": {
        "id": 456,
        "codigo": "ELEC001",
        "nombre": "Mouse Inalámbrico",
        "precioVenta": 118.0,
        "estado": true,
        "categoria": {
          "id": 1,
          "nombre": "Electrónica"
        }
      },
      "cantidad": 2.0,
      "precio": 118.0,
      "baseImponible": 200.0,
      "igv": 36.0,
      "total": 236.0
    },
    {
      "id": 2,
      "productoId": 789,
      "producto": {
        "id": 789,
        "codigo": "ELEC002",
        "nombre": "Teclado USB",
        "precioVenta": 59.0,
        "estado": true,
        "categoria": {
          "id": 1,
          "nombre": "Electrónica"
        }
      },
      "cantidad": 1.0,
      "precio": 59.0,
      "baseImponible": 50.0,
      "igv": 9.0,
      "total": 59.0
    }
  ]
}

Request Body

The sale object automatically calculates totals based on line item details. Series and number are auto-generated if not provided.
descripcion
string
Optional description for the sale
clienteId
long
ID of the client making the purchase
formapagoId
long
Payment method ID
fechaVenta
string
Sale date and time in ISO-8601 format. Defaults to current timestamp if not provided.
detalle
array
required
Array of sale line items. Each item represents a product being sold.

Response

Returns the created sale object with auto-generated fields and calculated totals.
id
integer
Unique identifier for the sale
serie
string
Auto-generated 3-letter series code (e.g., “ABC”)
numero
string
Auto-generated 6-digit invoice number (e.g., “000123”)
descripcion
string
Sale description
clienteId
long
Client ID
cliente
object
Client information object
formapagoId
long
Payment method ID
formaPago
object
Payment method information
fechaVenta
string
Sale timestamp
baseImponible
double
Total taxable amount (calculated automatically)
igv
double
Total IGV/tax amount (calculated automatically at 18%)
total
double
Total sale amount including tax (calculated automatically)
detalle
array
Array of sale line items
curl -X POST https://api.example.com/venta \
  -H "Content-Type: application/json" \
  -d '{
    "descripcion": "Venta de productos electrónicos",
    "clienteId": 123,
    "formapagoId": 1,
    "detalle": [
      {
        "productoId": 456,
        "cantidad": 2.0,
        "precio": 118.0
      },
      {
        "productoId": 789,
        "cantidad": 1.0,
        "precio": 59.0
      }
    ]
  }'
{
  "id": 1,
  "serie": "XYZ",
  "numero": "000123",
  "descripcion": "Venta de productos electrónicos",
  "clienteId": 123,
  "cliente": {
    "id": 123,
    "dni": "12345678",
    "nombre": "Juan",
    "apellido": "Pérez"
  },
  "formapagoId": 1,
  "formaPago": {
    "id": 1,
    "nombre": "Efectivo"
  },
  "fechaVenta": "2026-03-06T10:30:00",
  "baseImponible": 250.0,
  "igv": 45.0,
  "total": 295.0,
  "detalle": [
    {
      "id": 1,
      "productoId": 456,
      "producto": {
        "id": 456,
        "codigo": "ELEC001",
        "nombre": "Mouse Inalámbrico",
        "precioVenta": 118.0,
        "estado": true,
        "categoria": {
          "id": 1,
          "nombre": "Electrónica"
        }
      },
      "cantidad": 2.0,
      "precio": 118.0,
      "baseImponible": 200.0,
      "igv": 36.0,
      "total": 236.0
    },
    {
      "id": 2,
      "productoId": 789,
      "producto": {
        "id": 789,
        "codigo": "ELEC002",
        "nombre": "Teclado USB",
        "precioVenta": 59.0,
        "estado": true,
        "categoria": {
          "id": 1,
          "nombre": "Electrónica"
        }
      },
      "cantidad": 1.0,
      "precio": 59.0,
      "baseImponible": 50.0,
      "igv": 9.0,
      "total": 59.0
    }
  ]
}

Notes

  • The serie and numero fields are automatically generated using a secure random algorithm if not provided in the request
  • All monetary calculations (baseImponible, igv, total) are performed automatically by the system
  • IGV (tax) is calculated at 18% and is included in the precio field
  • The system uses the formula: baseImponible = precio / 1.18, igv = precio - baseImponible
  • Line item totals are summed to calculate the sale totals

Build docs developers (and LLMs) love