Skip to main content

Overview

The Costs API manages direct production costs associated with batches. It tracks various cost concepts related to dairy production and provides detailed cost breakdowns per batch.

Base URL

/costos
Authentication Required: Yes (all endpoints require cookie-based JWT authentication)

Create Cost

curl -X POST https://api.tambo360.com/costos/registrar \
  -H "Content-Type: application/json" \
  -H "Cookie: token=<jwt_token>" \
  -d '{
    "loteId": "b2c3d4e5-6789-01ab-cdef-234567890abc",
    "concepto": "leche_cruda",
    "monto": 1200.50,
    "observaciones": "Costo estimado para producción del lote"
  }'
Registers a new direct cost for a production batch.

Request Body

loteId
string
required
UUID of the batch this cost is associated with. The batch must exist and belong to the authenticated user.
concepto
string
required
Cost concept/category. Must be one of:
  • insumos_basicos: Basic supplies (salt, packaging, etc.)
  • leche_cruda: Raw milk
  • cuajo_y_fermentos: Rennet and ferments
  • refrigeracion: Refrigeration and cold storage
monto
number
required
Cost amount. Must be positive and cannot exceed 999,999,999. Value is automatically rounded to 2 decimal places.
observaciones
string
Additional notes about the cost. Maximum 500 characters. Cannot contain only whitespace.

Response

statusCode
integer
HTTP status code (201 for success)
message
string
“Costo registrado correctamente”
data
object
Created cost object:
idCostoDirecto
string
UUID of the cost record
idLote
string
UUID of the associated batch
concepto
string
Cost concept
monto
number
Cost amount (rounded to 2 decimals)
observaciones
string
Observations (nullable)
fechaCreacion
string
Creation timestamp (ISO 8601)
timestamp
string
Server timestamp
{
  "statusCode": 201,
  "message": "Costo registrado correctamente",
  "data": {
    "idCostoDirecto": "f5g6h7i8-9abc-45de-f012-67890abcdef1",
    "idLote": "b2c3d4e5-6789-01ab-cdef-234567890abc",
    "concepto": "leche_cruda",
    "monto": 1200.50,
    "observaciones": "Costo estimado para producción del lote",
    "fechaCreacion": "2026-03-08T16:20:00.000Z"
  },
  "timestamp": "2026-03-08T16:20:00.000Z",
  "success": true
}

Get Cost by ID

curl -X GET https://api.tambo360.com/costos/detalle/f5g6h7i8-9abc-45de-f012-67890abcdef1 \
  -H "Cookie: token=<jwt_token>"
Retrieves a specific cost record by its ID.

Path Parameters

id
string
required
UUID of the cost record

Response

{
  "statusCode": 200,
  "message": "Costo obtenido correctamente",
  "data": {
    "idCostoDirecto": "f5g6h7i8-9abc-45de-f012-67890abcdef1",
    "idLote": "b2c3d4e5-6789-01ab-cdef-234567890abc",
    "concepto": "leche_cruda",
    "monto": 1200.50,
    "observaciones": "Costo estimado para producción del lote",
    "fechaCreacion": "2026-03-08T16:20:00.000Z"
  },
  "timestamp": "2026-03-08T16:25:00.000Z",
  "success": true
}

List Costs by Batch

curl -X GET https://api.tambo360.com/costos/costos-lote/b2c3d4e5-6789-01ab-cdef-234567890abc \
  -H "Cookie: token=<jwt_token>"
Retrieves all costs associated with a specific batch.

Path Parameters

loteId
string
required
UUID of the batch

Response

statusCode
integer
HTTP status code (200 for success)
message
string
“Costos obtenidos correctamente”
data
array
Array of cost objects for the batch:
idCostoDirecto
string
Cost UUID
concepto
string
Cost concept
monto
number
Cost amount
observaciones
string
Observations (nullable)
fechaCreacion
string
Creation timestamp
{
  "statusCode": 200,
  "message": "Costos obtenidos correctamente",
  "data": [
    {
      "idCostoDirecto": "f5g6h7i8-9abc-45de-f012-67890abcdef1",
      "concepto": "leche_cruda",
      "monto": 1200.50,
      "observaciones": "Costo estimado para producción del lote",
      "fechaCreacion": "2026-03-08T16:20:00.000Z"
    },
    {
      "idCostoDirecto": "g6h7i8j9-0bcd-56ef-0123-78901bcdef23",
      "concepto": "cuajo_y_fermentos",
      "monto": 350.75,
      "observaciones": null,
      "fechaCreacion": "2026-03-08T16:25:00.000Z"
    }
  ],
  "timestamp": "2026-03-08T16:30:00.000Z",
  "success": true
}

Update Cost

curl -X PUT https://api.tambo360.com/costos/actualizar/f5g6h7i8-9abc-45de-f012-67890abcdef1 \
  -H "Content-Type: application/json" \
  -H "Cookie: token=<jwt_token>" \
  -d '{
    "monto": 1350.00,
    "observaciones": "Monto ajustado según factura"
  }'
Updates an existing cost record. Only costs associated with incomplete batches can be updated.

Path Parameters

id
string
required
UUID of the cost to update

Request Body

All fields are optional. Only include fields you want to update.
concepto
string
New cost concept (must be a valid concept)
monto
number
New cost amount (positive, max 999,999,999)
observaciones
string
Updated observations (max 500 characters)

Response

{
  "statusCode": 200,
  "message": "Costo actualizado correctamente",
  "data": {
    "idCostoDirecto": "f5g6h7i8-9abc-45de-f012-67890abcdef1",
    "idLote": "b2c3d4e5-6789-01ab-cdef-234567890abc",
    "concepto": "leche_cruda",
    "monto": 1350.00,
    "observaciones": "Monto ajustado según factura",
    "fechaCreacion": "2026-03-08T16:20:00.000Z"
  },
  "success": true
}

Delete Cost

curl -X DELETE https://api.tambo360.com/costos/eliminar/f5g6h7i8-9abc-45de-f012-67890abcdef1 \
  -H "Cookie: token=<jwt_token>"
Deletes a cost record. Only costs associated with incomplete batches can be deleted.

Path Parameters

id
string
required
UUID of the cost to delete

Response

{
  "statusCode": 200,
  "message": "Costo eliminado correctamente",
  "data": null,
  "success": true
}

Cost Concepts Reference

insumos_basicos

Basic production supplies including:
  • Salt and seasonings
  • Packaging materials
  • Cleaning supplies
  • General production consumables

leche_cruda

Raw milk costs - the primary input for dairy production.

cuajo_y_fermentos

Rennet and fermentation cultures:
  • Rennet (cuajo) for cheese making
  • Bacterial cultures
  • Fermentation starters

refrigeracion

Refrigeration and cold storage costs:
  • Energy costs for cooling
  • Cold storage facility expenses
  • Temperature control systems

Error Responses

400 Bad Request

  • Invalid input data or validation errors
  • Invalid cost concept
  • Amount out of range
  • Batch is completed (cannot modify costs)

401 Unauthorized

  • Missing or invalid authentication token

403 Forbidden

  • User does not own the batch/cost
  • Insufficient permissions

404 Not Found

  • Cost does not exist
  • Associated batch does not exist

500 Internal Server Error

  • Unexpected server error

Build docs developers (and LLMs) love