Reference

External agent API

An agent running somewhere else — your own machine, a chat app, anything that can make an HTTPS request — can read your farm record and add to it on your behalf. You issue it a key, you choose what it may touch, and you can turn it off at any moment.

If you are an agent, start here

  • /llms.txt — the whole contract as plain text. Every tool, every argument, every rule. Public.
  • /api/agent/openapi — the same as OpenAPI 3.1, and the only public place with the tool argument schemas. Public.
  • GET /api/agent/tools with your key — what you may do, with parameters, plus the tools you are missing and the permission each would need.

This page names the tools and their permissions but not their parameters — those are on the two links above.

What no key can do

These are not settings. They hold for every key, at every permission level, and they are enforced in code rather than stated as policy.

You cannot write the Mind

The Mind is Dear Farm's own agent's knowledge graph, and that agent is its only author. No scope grants a write, and no tool that performs one is callable — the endpoint answers 'unknown tool' whatever your key holds. What you can do is REPORT: POST /api/agent/memory/request with a plain-language observation, and that agent decides whether to keep it, how to key it and how to link it. You propose; it disposes.

There is no approval step here

Inside the app, every write an agent proposes is a card the farmer clicks to accept. This endpoint has no card and no UI to draw one in, so a write lands the moment you call it. Do not tell the farmer something is 'awaiting approval' — it is already done. Confirm with them BEFORE you call a write tool, not after.

You act as one person, and only as them

Your key is pinned to one user in one organization at one role. Identity is never read from the request body, so there is nothing you can send that makes a call act as somebody else. Everything you read and write is what that person can read and write.

Nothing reaches settings

No tool changes account settings, permissions, billing, or who the agent is. The agent's personality is a settings change and a Mind write at once, and is withheld on both counts.

Deletes are mostly soft, and there is no undo here

Deleting a plot, plant, note or activity log hides it from every read rather than destroying it — but no tool here brings it back. Calendar events are the exception: those are removed outright. Prefer an edit over a delete when the farmer means 'this changed' rather than 'this never happened'.

Getting a key

  1. In Dear Farm, go to Settings → External Agents and create one. Name it after the agent that will hold it.
  2. Tick what it may do. The defaults suit a conversational assistant; grant less if you are unsure — you can widen it later without reissuing the key.
  3. Copy the key. It is shown once and never again. If you lose it, revoke it and make another.

A key acts as you, in your organization, at your role. Everything it can reach is something you can reach; it never sees another member’s private data and cannot act as anyone else. Revoking takes effect immediately.

Only owners and admins can issue or change keys, and a key cannot issue a key — key management is reachable only from a signed-in browser session. If it were not, revoking a compromised key would mean nothing, because the holder could simply issue itself another.

Authentication

Send the key as the x-agent-key header on every call — or as Authorization: Bearer <your key>, if that is what your client sends. Both are read and they are the same credential. There is no user id to send — the key carries who it acts as.

curl https://dear.farm/api/agent/tools \
  -H "x-agent-key: df_your_key_here"

401 — the key is missing, unknown or revoked. All three answer identically, on purpose.

403 — authenticated, but this key lacks the permission. The body names which one, so the agent can ask for it by name.

400 — the arguments were wrong, or the tool is not available to external agents. The body says which.

Permissions

A key holds some of these. They only ever subtract — no permission lets a key do something the person it acts as could not.

identity:readLook up identity

Resolve a phone number to a user and organization. Needed only by an agent that receives messages from numbers it must match to accounts — a key that already acts as one person does not need this.

farm:readRead farm data

Farms, plots, plants, activity, notes, calendar, weather, catalog, attachments and stats — for the farms this key's user can reach. Read-only and repeatable; nothing here consumes anything.

farm:writeWrite farm data

Create, update AND DELETE plots, plants, activity logs, notes and calendar events, and edit farm details. Writes land immediately — there is no approval step on this endpoint, so the guest must confirm with the farmer itself. Deletes are soft except calendar events, which are removed outright.

expensesExpenses

Read and write expenses, and extract them from uploaded receipts. New expenses land as drafts for the farmer to confirm.

attachmentsUpload files

Upload photos, PDFs and documents, and attach them to records.

messagesPush messages

Send message history into the app's message log. This is for an agent that fronts a messaging channel — a guest that talks to the farmer somewhere else does not need it.

events:consumeTake from the event queue

Poll the queue of things that happened in the app. GRANT THIS TO EXACTLY ONE AGENT. Reading DRAINS it — each event is delivered once, to whichever caller asks first — so a second holder does not see the same events, it silently steals them, and the first agent simply stops hearing about things with no error anywhere. The queue is also organization-wide rather than farm-scoped: its rows carry no farm id, so its summaries name farms outside this key's farm access.

memory:readRead the Mind

Read the knowledge graph, research reports, and the agent's composed system prompt.

memory:requestAsk the Mind to remember

Report something learned elsewhere. Dear Farm's agent decides whether to record it, how to key it and how to link it. No external key can write the Mind directly — this is the only road in.

Retired and no longer grantable: memory:write, memory:destructive. See the first rule above.

Endpoints

GET/api/agent/toolsany key

What this key can do. Returns every tool with its parameters and whether this key holds the scope for it — tools it cannot call are listed too, so the agent can ask the farmer for the right permission instead of guessing.

POST/api/agent/toolsany key

Run one tool. Body: { tool, input }. The scope required depends on the tool.

GET/api/agent/memorymemory:read

The knowledge graph as nodes and edges, for display. Add ?summary=true for prose instead.

GET/api/agent/memory/requestmemory:request

The reporting contract — what is worth reporting to the Mind and what is not. Read this once at session start.

POST/api/agent/memory/requestmemory:request

Report something you learned. Body: { observation }. Dear Farm's own agent decides whether to record it. This is the ONLY way anything external reaches the Mind.

POST/api/agent/uploadattachments

Upload a file as base64 and attach it to a record. Body: { file_base64, filename, content_type, entity_type, entity_id } — or set create_note: true with farm_id to file it onto a new note.

POST/api/agent/messagesmessages

Push message history into the app's message log. For an agent that fronts a messaging channel.

GET/api/agent/lookupidentity:read

Resolve ?phone= to a user and organization. Only useful to an agent that must match inbound numbers to accounts.

GET/api/agent/openapipublic

This contract as an OpenAPI 3.1 document, including every tool's argument schema. Public — no key needed.

Calling a tool

curl -X POST https://dear.farm/api/agent/tools \
  -H "x-agent-key: df_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"tool":"get_farms","input":{}}'

The response is { "result": … }. A call that reaches the tool and fails its own validation answers 200 with an error field on the result, saying what to fix.

Tools (36)

Reading (18)

get_farmsfarm:read

List every farm this key can reach, with id, name, address, size in acres and notes. Start here — most other tools need a farm_id.

get_plotsfarm:read

List the plots on one farm.

get_plantsfarm:read

List the plants on one farm.

get_recent_activityfarm:read

The most recent activity logs on a farm, newest first.

get_activity_typesfarm:read

The activity type vocabulary for this organization — slug, label, group and colour. Call this before create_activity_log to get a valid log_type slug.

get_notesfarm:read

Recent notes on a farm.

get_calendar_eventsfarm:read

Calendar events on a farm within a date window.

get_weatherfarm:read

Daily forecast for a farm's location — max/min temperature, precipitation, wind and weather code. Needs the farm to have a location set.

search_catalogfarm:read

Search the shared crop catalog by name, variety, crop type or scientific name. Returns up to 5 matches. Use the id with create_plant or get_crop_enrichment.

get_crop_enrichmentfarm:read

Read one section of the researched detail behind a catalog entry. Returns a 'not available yet' message rather than an error when the section has not been generated.

get_attachmentsfarm:read

List the files attached to one record.

get_plant_statsfarm:read

Counts of plants grouped by category, health and lifecycle. Omit farm_id for a total across every farm this key can reach.

get_pending_eventsevents:consume

Things that happened in the app since anyone last asked. DRAINS ON READ: each event is delivered exactly once, to whichever caller asks first, so a second agent polling the same organization does not see them — it takes them. Returns up to 50.

read_memorymemory:read

Read the farmer's knowledge graph — what Dear Farm's own agent has concluded about them and their land.

get_memory_graphmemory:read

Node and edge counts plus a prose summary of the graph.

get_system_promptmemory:read

The composed system prompt Dear Farm's own agent runs under — its active personality and the farmer's standing instructions. Read it to stay consistent with how that agent behaves.

get_research_reportmemory:read

Load a research report in full — title, summary, markdown body, findings and sources.

get_expensesexpenses

List expenses, newest first.

Writing (18)

These change your record the moment they are called. There is no approval step on this API — that is the agent’s job, on its own side, before it calls.

update_farmfarm:write

Edit a farm's name, address or notes. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

create_plotfarm:write

Create a plot on a farm. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

update_plotfarm:write

Edit a plot. Every field is optional; omitted fields are left alone. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

delete_plotfarm:write

Delete a plot. The delete is soft — the record is hidden from every read, not destroyed — but there is no tool here to bring it back. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

create_plantfarm:write

Record a plant (or a group of plants) on a farm. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

update_plantfarm:write

Edit a plant. Use this to record a change in health or growth stage — it is the most common write after an inspection. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

delete_plantfarm:write

Delete a plant record. Soft, like every delete here. If a plant died, prefer update_plant with health_status 'dead' — that keeps the history. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

create_activity_logfarm:write

Log something that was done on the farm — watering, pruning, spraying, a harvest. This is the right home for transient events; do not report them to the Mind. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

update_activity_logfarm:write

Edit an activity log entry. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

delete_activity_logfarm:write

Delete an activity log entry. Soft. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

create_notefarm:write

Write a note against a farm, plot or plant — an observation that is not a task that was performed. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

update_notefarm:write

Replace a note's content. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

delete_notefarm:write

Delete a note. Soft. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

create_calendar_eventfarm:write

Put something on the farm calendar. Lands on the farm's system calendar; the farm must already have one. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

delete_calendar_eventfarm:write

Remove a calendar event. Unlike the other deletes here this one is HARD — the row is removed and cannot be recovered. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

create_expenseexpenses

Record an expense. It lands as a draft — the farmer confirms it in the app before it syncs to their accounting system. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

update_expenseexpenses

Edit an expense. Every field is optional. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

extract_expense_from_fileexpenses

Read a receipt that has already been uploaded and pull the amount, merchant, date and line items out of it. Upload the file first — this takes an attachment id, not bytes. WRITES IMMEDIATELY when called on this endpoint — there is no approval step here, so confirm with the farmer yourself before calling it.

Not available, on purpose

These exist inside Dear Farm and are unreachable from outside it. Calling one answers 400 with the reason — never a silence you would have to guess at.

update_memoryOnly Dear Farm's own agent writes the Mind. Use POST /api/agent/memory/request.
write_preferences_rootWrites the Mind.
write_research_report_nodeWrites the Mind.
write_personality_from_presetWrites the Mind, and rewrites who the agent is. Withheld twice over: it is also a settings change.
delete_memory_nodeErases the Mind.
delete_memory_edgeErases the Mind.
clean_memoryErases the Mind.
reset_memoryErases the Mind.
forget_farm_skeletonErases the Mind.

Telling the agent something

Dear Farm’s own agent keeps a knowledge graph about you and your land — the Mind. It is the only author of it, and that is what makes it trustworthy: everything in it is something that agent worked out. An outside agent writing into it would come back to the agent as its own recollection, and nothing afterwards could tell the two apart.

So an external agent reports instead. It sends what it learned in plain language, and Dear Farm’s agent decides whether to keep it, how to key it and how to link it — the same judgement it applies to its own conversations.

curl -X POST https://dear.farm/api/agent/memory/request \
  -H "x-agent-key: df_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"observation":"Raju said on 12 Aug he will not use synthetic fertiliser on the east block."}'

GET the same path for the reporting contract — what is worth reporting and what belongs in an activity log instead.