Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sdarionicolas-boop/AgroIA-RAG/llms.txt

Use this file to discover all available pages before exploring further.

AgroIA provides three ingestion endpoints to cover different workflows: an asynchronous endpoint for production use, a synchronous endpoint that blocks until the record is written (useful for testing), and a bulk endpoint that accepts a GeoJSON file and processes all features in the background. All three endpoints require Bearer token authentication.
All three endpoints validate the Authorization header against INGESTA_SECRET_KEY. See API overview and authentication for details.

POST /ingesta

Ingests a single agronomic lot asynchronously. The record is written to informes_lotes and lote_historial in a background task, so the endpoint returns 202 Accepted immediately without waiting for the database write to complete.

Request body

lote_id
string
required
Unique identifier for the lot. Must be between 1 and 100 characters.
fecha
string
required
Report date in ISO 8601 format. Any format other than YYYY-MM-DD is rejected with a validation error.
ndvi_promedio
float
default:"null"
Average NDVI value for the lot. Must be between 0.0 and 1.0 inclusive. Optional.
gdd_acumulados
float
default:"null"
Accumulated growing degree days from NASA POWER climate data. Must be 0.0 or greater. Optional.
contenido_tecnico
string
default:"null"
Free-text agronomic report content. This field is embedded with nomic-embed-text via Ollama and stored as a 768-dimension vector for RAG retrieval. Optional.
metadata
object
default:"null"
Arbitrary JSONB metadata for the lot. Stores fields such as score_total, cv_espacial, cultivo, superficie_ha, zonificacion_activa, and puntos_zona_c when present. Optional.
historial_anos
array
default:"null"
Array of historical year objects for the lot. Each item is written as a row in lote_historial. Use ASCII key names — anio not año. Optional.

Response

status
string
Always "accepted" for this endpoint. The background task may still be processing.
lote_id
string
Echo of the submitted lote_id.
fecha
string
Echo of the submitted fecha.

Examples

curl -X POST http://localhost:8000/ingesta \
  -H "Authorization: Bearer your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{
    "lote_id": "INTA_PIVOTE_001",
    "fecha": "2025-11-15",
    "ndvi_promedio": 0.72,
    "gdd_acumulados": 1450.5,
    "contenido_tecnico": "Lote con alto vigor en etapa de llenado de grano. Sin anomalias detectadas.",
    "metadata": {
      "cultivo": "maiz",
      "score_total": 81.4,
      "superficie_ha": 48.3,
      "cv_espacial": 0.12
    },
    "historial_anos": [
      {
        "anio": 2023,
        "cultivo": "maiz",
        "ndvi_critico": 0.68,
        "horas_calor": 1380.0,
        "score_total": 78.2,
        "score_vigor": 32.1,
        "score_estabilidad": 24.5,
        "score_limpieza": 15.8,
        "score_clima": 5.8,
        "valido_para_score": true
      }
    ]
  }'

POST /ingesta/debug

Synchronous version of /ingesta. The request blocks until the record is fully written to informes_lotes and lote_historial, then returns the database-assigned ID. Use this endpoint for integration testing and pipeline verification — not for production load.
The debug endpoint returns the database id of the new or updated record, which lets you confirm the upsert succeeded and trace the exact row in informes_lotes.

Request body

Same schema as POST /ingesta. All fields from the InformeAgricola model apply.

Response

status
string
Always "ok" on success.
id
integer
The database ID of the record in informes_lotes returned by the RETURNING id clause of the upsert.
lote_id
string
Echo of the submitted lote_id.

Examples

curl -X POST http://localhost:8000/ingesta/debug \
  -H "Authorization: Bearer your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{
    "lote_id": "TEST_LOTE_99",
    "fecha": "2025-06-01",
    "ndvi_promedio": 0.55,
    "gdd_acumulados": 900.0,
    "contenido_tecnico": "Prueba de ingesta sincrona para validacion."
  }'

POST /ingesta/geojson

Accepts a multipart file upload containing a GeoJSON FeatureCollection and processes all features as individual lots in a background task. Each feature’s properties object is stored as metadata, and lote_id is derived from the id property of each feature (formatted as POLIGONO_<id>). This is the recommended endpoint for ingesting output from the SAM polygon delineator.
The ingestion date (fecha) is automatically set to today’s date for each feature. NDVI and GDD values default to 0.0 until the full pipeline enriches the record.
If the GeoJSON file contains no features array or the array is empty, the endpoint returns an error response without scheduling a background task.

Request — multipart form

file
file
required
A GeoJSON file in application/geo+json or application/json format. The file must be a valid FeatureCollection with a non-empty features array.

Response

status
string
"accepted" when at least one feature was found and processing was scheduled.
message
string
Human-readable confirmation: "Archivo GeoJSON recibido y en proceso de carga masiva".
total_features
integer
Count of features found in the uploaded file that were submitted for processing.

Examples

curl -X POST http://localhost:8000/ingesta/geojson \
  -H "Authorization: Bearer your_secret_key" \
  -F "file=@/path/to/poligonos_definitivos.geojson"

Build docs developers (and LLMs) love