palbaseDocs

Palbase ai · API

PUT/ai/agents/{name}

Save an agent's draft

Saves the draft of an agent the project keeps — a new one's first. What its chats talk to changes only once the draft is published. revision names the draft the change was made to: when another was saved since, it is refused (409 draft_changed) and nothing is lost; left out, the last save wins. A name its backend's build defines is refused (409 agent_defined_in_code): that agent is changed in the code.

Called by your server, with the project's secret key.

Path

namestring · requiredThe name: lowercase letters, digits, _ and -, starting with a letter, at most 64.

Query

revisioninteger · optionalThe draft's revision the change was made to.

Request body

advisorobject · optionalA second model beside the agent: it reads what the agent does after every step — its messages, the reasoning its model gives, its tool calls and what they answered — and, when a decision goes against the agent's instructions, its goal or the advisor's own rules (instructions), tells the agent so at its next step. The agent may ask it, and a turn's answer waits for its reading. It only reads: the agent's workspace, and the tools of the MCP servers named here that say they only read (readOnlyHint). Its calls are the turn's: they count in its cost and its limit.
context_windowinteger · optionalThe window, in tokens, the turn works in (the model's standard one unless said; more is billed as its provider bills it — GET /ai/models, context_window and max_input_tokens).
descriptionstring · optionalWhat it is for, in a sentence or two: the people who pick an agent read it, and so does the agent a subagent works for.
effortstring · optionalHow hard the model thinks: none, minimal, low, medium, high, xhigh, max — which rungs a model takes is its catalogue entry's (GET /ai/models, efforts). Left out: the platform's.
envobject · optionalThe agent's own variables (names: upper-case letters, digits and _, not PALBASE_AI_…; 64 at most; a value 32 KiB at most): every command of its sessions has them, on every pool, beside the project's (PUT /ai/env/{key}), masked in a transcript. Each is its value, or {value, hosts, inject, open, secret, acknowledge_open, acknowledge_guessable}: what the secret says of itself, as PUT /ai/env/{key} takes it. A value is never answered again: a definition read back says each name with an empty value (an object where it says more than its value), and a name written with an empty value keeps the value it has — written as a bare string, what it says of itself too.
instructionsstring · optionalIts instructions.
languagestring · optionalThe language of the person the turn works for, as a BCP 47 tag (tr, en-GB): the model writes to them in it on every step, and so do its subagents.
max_tool_callsinteger · optionalHow many tool calls a turn makes at most (10000: the engine's own bound): past it the agent is told it has no tools left and answers. What a turn spends is its budget's to bound.
modelstring · optionalA model's name, as GET /ai/models says it (gpt-6-luna). Left out: the project's default.
outputobject · optionalA JSON Schema a one-shot answer of the agent's is a document of (POST /ai/responses naming the agent): the same keywords a response's schema takes. A chat's turns answer in text.
setupstring · optionalA shell script each of its sessions runs once at its start, before the agent's first command, on every pool (64 KiB at most). On a Mac of yours whose turn runs Claude Code or Codex it runs inside a sandbox of the agent on that machine: it writes the session's workspace and the session's own folders and nothing else of the machine, reads what a session's commands read, and reaches the network with no list of hosts — its files are held, its network is not. Where that sandbox cannot be applied the turn fails at its start saying so; the script is never run outside it. Each of its commands is a process group that is killed when the command ends, so nothing it started goes on writing the workspace; a process that leaves its group on purpose is not found by this. Before the CLI is started, the agent on the machine reads every repository the workspace then holds, running no git: the turn fails at its start, naming the repository and the setting, if one carries anything git would run or load (a hook, an include, an alias, a filter or driver, `core.fsmonitor`, `core.hooksPath`, `core.sshCommand`, a remote that is not `https://`, a credential helper that is not a bare program name with plain arguments, or a setting outside the ones git writes as it makes, fetches and checks out a repository).
subagentsobject[] · optionalIts subagents (16 at most).
thinking"visible" | "hidden" · optionalWhether the model's reasoning is shown in the chat's stream (visible: thinking parts) or not asked for at all (hidden). Left out: the platform's.
tool_outputs"aged" | "window" · optionalWhen what a tool answered some steps ago leaves the conversation the model is sent, in a chat's turns. aged (the default): on every step, an output past 4 KiB that is four messages old is cut to its first three and last five lines, with where the whole of it is kept (the chat's stream says so: a context.offloaded part) — a coding turn's prompts stay small. window: none is cut until the conversation nears the window the turn works in (context_window) — the mark at which the platform compacts it, about three quarters of the window — and past it they are cut before anything is summarised: for an agent that reads material and reproduces it, at the prompt tokens that costs. Its subagents take it unless they say their own.
toolsobject[] · optionalIts tools (64 at most, with its MCP servers').
expose_a2aboolean · optionalOpt-in flag exposing this published agent on /.well-known/agent.json and POST /ai/a2a.
memory_scopesstring[] · optionalMemory namespace prefixes the agent is permitted to read and write.
curl
curl -X PUT "https://<your-ref>.palbase.studio/ai/agents/<name>" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"advisor":{"effort":"none","instructions":"string","model":"string","tools":[{"name":"string","source":"backend"}]},"context_window":1,"description":"string","effort":"none","env":{},"instructions":"string","language":"string","max_tool_calls":1,"model":"string","output":{},"setup":"string","subagents":[{"description":"string","name":"string"}],"thinking":"visible","tool_outputs":"aged","tools":[{"name":"string","source":"backend"}],"expose_a2a":false,"memory_scopes":["string"]}'

Responses

200The agent

400The request is malformed, or names what this module does not offer (the error names which)

401No valid credential

403A publishable key or a user's session: everything here is the project's server's, called with the secret key

409The response's state refuses it

429The project's request rate, or the provider's for its connection, is used up — or the project holds as much as it may at once: 32 open streams at one of the module's servers (too_many_streams), 2 pictures being made (too_many_images), 512 MiB of pictures kept here for their day (image_storage_full), or the service — or the project's share of it — holds as much of its requests at once as it takes: their bodies, an embedding request's vectors, the pictures being made (busy). Retry-After says when to try again

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation PutAgent of ai's contract.