POST /agent/apply. Use the scope and selected_cells fields to constrain the agent to a particular region of the sheet.
Request
The natural-language instruction for the agent. For example:
"Build a quarterly revenue forecast with 10% QoQ growth starting from 100 in B3".Prior conversation turns, ordered oldest-first. Each element must have a
role field ("user" or "assistant") and a content field (string). Pass the full history on follow-up turns so the agent has context about what it has already written.Controls which cells the agent can see when building its context.
"sheet"— the entire active sheet (default)"selection"— only the cells listed inselected_cells
A list of cell addresses in A1 notation that are currently selected in the UI, for example
["A1", "B2", "C3"]. Used when scope is "selection", and also passed to the agent as a hint about where the user’s cursor is.Name of the sheet to target. Defaults to the active sheet when omitted.
The LLM model ID to use for this request, for example
"gemini-2.0-flash". When omitted, GridOS selects the best available model from your configured providers.Response
The agent ID that handled the request. Matches
agent_id. Typical values are "finance" and "general".The agent’s plain-language explanation of what it is proposing and why.
The name of the sheet the preview targets.
The agent ID selected by the router. Pass this back unchanged in the
POST /agent/apply request body.The top-left cell of the proposed write after collision resolution, in A1 notation (for example
"B3"). Pass this as target_cell in POST /agent/apply.The top-left cell as originally requested by the agent, before any collision shift. Useful for debugging placement differences.
The individual cells that would be written, each represented as an object with
cell (A1 address) and value (the proposed content). Empty when the agent has nothing to write this turn (for example, a pure acknowledgement or a macro proposal).A 2-D array (array of arrays) of the proposed cell values, in row-major order.
null when the agent has no grid write for this turn — for example, when it proposes only a chart or a macro.A chart specification object if the agent is proposing a chart, otherwise
null. Fields include data_range, chart_type ("bar", "line", or "pie"), title, anchor_cell, and orientation. Pass this through to POST /agent/apply unchanged.A macro proposal if the agent is suggesting a new named formula, otherwise
null. The macro is not saved automatically — you must approve it separately before it can be used in formulas. Contains name, params, description, body, and a replaces_existing boolean.A validation error message if the agent proposed a macro that failed to compile, otherwise
null. Surface this to the user so they can adjust their request.A multi-section build plan emitted on the first turn only for complex builds (financial models, forecasts, budgets, and so on). Contains
title, anchor, and a sections array where each section has label, target, and notes. On subsequent turns this field is null.When
values is null and chart_spec is also null, the agent has nothing to write or render this turn. The UI should hide the Apply button and display reasoning as a conversational response.