Create batch orders (Excel upload)
POST/api/batchShipping
Creates several orders from the filled-in Excel template (GET /api/batchShipping). Each row is validated and processed separately.
The response is 200 even if some rows fail: check isValid and response_message of each row in data[].
codeExcel is the row number in the Excel file, to locate the errors.
How to send the file
- Send it as
multipart/form-datain thefilefield, with the Excel content type (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet). If the file arrives with another type (for exampleapplication/octet-stream), it is rejected. With curl:-F "file=@plantilla.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet". - Only the .xlsx format is read. An .xls file (old format) is rejected with
El archivo no pudo ser leído como Excel. - The first sheet is read; row 1 holds the headers and empty rows are skipped.
- Fill in the template in Excel or another spreadsheet app that saves formula results: the hidden columns calculate the IDs (address, municipality, service) from what you pick in the lists. If the file is generated with a library that does not calculate formulas, the rows fail.
Columns and per-row validations
Each row is validated in this order and only the first error is reported:
| Column | Data | Rule | Message if it fails |
|---|---|---|---|
| B | Client name | Required, 2 to 150 characters | El nombre del cliente es obligatorio y no puede estar vacío, El nombre del cliente debe contener al menos 2 caracteres, El nombre del cliente es demasiado largo. No puede superar los 150 caracteres |
| C | Client phone | Required, 7 to 9 characters: digits and, optionally, a hyphen | El número de teléfono del cliente es obligatorio, El número de teléfono del cliente no puede tener más de 9 caracteres. Puede ingresarse con o sin guion, El número de teléfono del cliente solo puede contener números y, opcionalmente, un guion |
| D | Shipping address | Required, 5 to 250 characters | La dirección del cliente es obligatoria y no puede estar vacía, La dirección del cliente es demasiado corta. Debe contener al menos 5 caracteres, La dirección del cliente es demasiado larga. No puede superar los 250 caracteres |
| E, F | Department and municipality | Picked from the list | No se pudo identificar el municipio del cliente. Verifica que el municipio exista y esté correctamente seleccionado |
| A | Pickup address | Picked from the list | Seleccione una dirección de recolección válida |
| I | Courier | Required | Seleccione un courier válido |
| J | Service | Required | Seleccione un servicio |
| K | Service type | Required; the courier, service and type combination must exist in the list | Seleccione un tipo de servicio, La combinación de courier, servicio y tipo de servicio no es válida |
| L | Delivery type | Entrega Normal (Sin Cobro) (normal delivery, no collection) or Cobro Contra Entrega (cash on delivery) | Seleccione un tipo de entrega válido |
| N | Product description | Required, up to 150 characters | Ingrese una descripción del producto, La descripción del producto es demasiado larga |
| H | Weight (lb) | Number greater than 0 | Ingrese un peso válido |
| G | Number of packages | Integer from 1 to 50 | Ingrese una cantidad de paquetes válida |
| M | Amount to collect | Greater than 0 with Cobro Contra Entrega; without collection, empty or greater than or equal to 0 | Ingrese un monto a cobrar válido, por ejemplo 15.50, El monto a cobrar no puede ser negativo |
| O | Comments | Optional, up to 300 characters | Los comentarios son demasiado largos |
What each valid row does
Saves or updates the recipient in the merchant's clients and creates the order just like POST /api/orders:
it generates the shipping label and deducts the cost from the balance. If the creation fails (for example, because of the balance or a courier error),
the row comes back with isValid: false and the message of that error. The other rows are still processed.
Request
Responses
- 200
- 400
- 401
- 500
File processed; check the result of each row
The file is not valid. Possible messages: No se envió ningún archivo, El archivo enviado no es válido,
El archivo enviado no es un archivo Excel válido, El archivo no pudo ser leído como Excel,
El archivo Excel no contiene hojas, El archivo Excel no contiene registros.
The token is missing, expired (it lasts 15 minutes) or invalid. Log in again to get a new one.
Internal error while processing the file