Automate a flow
The whole path: from the catalogs to a queryable result, without opening Kaax.
- 1
Read the catalogs first
The valid reportType values and statistics are edited by the Kaax super admin. Hardcoding them guarantees a break the day someone adds an index. Watch `defaults.mapResolution`: it is a number (72, 150 or 300), and sending it as text is refused for its type.
javascriptconst types = await kaax("/api/v2/catalogs/report-types"); const vi = await kaax("/api/v2/catalogs/vegetation-index-defaults"); - 2
Build the template from a preset
Authoring `layouts` by hand means writing nested 0..1 normalised coordinates. The preset already carries the structure; you only change the name.
javascriptconst { data: presets } = await kaax("/api/v2/templates/presets"); const preset = presets.find((p) => p.key === "counting-density"); const template = await kaax("/api/v2/templates", { method: "POST", body: { ...preset.seedPayload, name: "Densidad — Banano Álamos" }, }); - 3
Resolve the lot and the configuration
Only lots with a measured area can run: one without geometry cannot be matched to a raster and the queue skips it. The configuration's `tag` is what a queue step references, and its `modelId` is the detection model bound to that tag.
javascriptconst { data: lots } = await kaax("/api/v2/lots?withGeometry=true"); const { data: configs } = await kaax("/api/v2/analysis-configs"); const tag = configs.counting[0]?.tag; - 4
Follow the queue and collect the result
Kaax sends no push notifications, so status is polled. Once a step is `completed`, its `analysisId` is the bridge to the result.
javascriptconst { data: runs } = await kaax("/api/v2/queue-runs?status=completed"); const done = runs.flatMap((r) => r.steps).filter((s) => s.analysisId); const { data: analyses } = await kaax("/api/v2/analyses?limit=100"); for (const step of done) { const result = analyses.find((a) => a._id === step.analysisId); }
Enqueuing stays manual. Creating and running a queue consumes credits and storage, so the public API only reads. It is assembled from the dashboard or by talking to the MCP.
