Skip to content

Publish an agent definition

View as Markdown
POST
/v1/agents
curl --request POST \
--url https://example.com/v1/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "id": "example", "version": "example", "name": "example", "description": "example", "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "instructions": { "prompt": "example", "version": "example" }, "parameters": [ { "name": "example", "description": "example", "type": "string", "required": true, "default": "example" } ], "settings": [ { "id": "example", "version": "example" } ], "modelSettings": { "id": "example", "version": "example" }, "capabilities": [ {} ], "tools": [ { "id": "example", "version": "example" } ], "retrieval": [ { "source": "facts", "types": [ "example" ], "roles": [ "user" ], "scope": "same-conversation", "limit": 1, "mode": "keyword" } ], "memory": { "instructionTypes": [ "example" ], "remember": { "types": [ "example" ], "scope": "same-user", "keepDays": 1 } }, "files": { "update": true, "create": true }, "guardrails": [ "example" ], "preferredProvider": "example", "preferredModel": "example", "conversationPolicy": { "historyLimit": 1, "hitlAfterTurns": 1, "hitl": { "afterTurns": 1, "tools": { "default": "never_ask", "overrides": { "additionalProperty": "never_ask" } }, "defaultReviewerRole": "standard", "separateApprover": { "default": true, "overrides": { "additionalProperty": true } }, "timeoutMs": 1, "onTimeout": "escalate" } }, "budget": { "maxSteps": 1, "maxCostUsd": 1, "maxWallMs": 1 }, "tags": [ "example" ], "output": { "schema": {}, "name": "example", "maxRepairs": 1 }, "toolErrors": { "maxRetries": 1, "retryOn": [ "invalid-arguments" ] }, "parallelToolCalls": true, "mcp": { "expose": true, "readOnly": true, "destructive": true } }'

Body is a full defineAgent spec. Server validates via @kindgi/agents.defineAgent before persisting.

Idempotency-Key
string
>= 1 characters

Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the workspace is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1). A retry sent while the first request still runs is answered 409 idempotency-key-in-flight with Retry-After, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets 409 idempotency-key-replay-withheld, with the first request’s status and when it succeeded (from 0.1.5). A request whose key store can’t be read before it runs is answered 503 idempotency-store-unavailable with Retry-After: nothing ran, so retry with the same key (from 0.3.0).

Media typeapplication/json

Full defineAgent spec. Validated server-side via @kindgi/agents.defineAgent — validation failures return 400 validation-failed with the issue list under details.issues.

object
id
required
string
version
required
string
name
required
string
description
string
projectId
required

Project this belongs to (its content scope). Required: missing, or not a project in the caller’s workspace → 400 bad-input.

string format: uuid
instructions
required
One of:
string
>= 1 characters
parameters
Array<object>
object
name
required
string
description
string
type
required
string
Allowed values: string number boolean date
required
boolean
default

Default value used when the caller omits this parameter.

settings

Settings blocks the agent reads, by range: tools read them as ToolContext.settings['<id>'], templates as settings["<id>"]. Pinned at publish (pins.settings).

Array<object>

A settings block an agent reads, by id and semver range.

object
id
required

The settings block id.

string
version
required

A semver range (^1.0.0, 1.2.0).

string
modelSettings

A model-settings block by range: its temperature, maxOutputTokens and thinking go into the turn’s model calls. Pinned at publish.

object
id
required

The settings block id.

string
version
required

A semver range (^1.0.0, 1.2.0).

string
capabilities
required
Array<object>

Capability declaration — see @kindgi/capabilities. Additional properties are permitted so new capability kinds do not require a wire change.

object
key
additional properties
any
tools
required
Array<object>

Typed tool reference. version is a semver range (npm-style: 1.2.3 exact pin, ^1.2.3 compatible-updates, ~1.2.3 patch-updates-only, >=1.0.0 <2.0.0 explicit range). Dispatch resolves the range to a concrete active version via semver.maxSatisfying at run start. No implicit “latest” — every tool ref names both id and range.

object
id
required
string
>= 1 characters
version
required
string
>= 1 characters
retrieval
required
Array<object>
object
source

What it reads: facts (the default), or messages of this agent’s earlier conversations, quoted in the turn’s <memory> block as earlier conversation, never as turns.

string
Allowed values: facts conversations
types

The fact types it retrieves: required for facts; not used for conversations.

Array<string>
>= 1 items
roles

For conversations: whose messages it recalls. Default ['user'], the people’s own words. Adding agent recalls the agent’s earlier answers too, which can carry its mistakes: they are quoted as unverified earlier answers, and publishing warns recall-agent-answers.

Array<string>
>= 1 items unique items
Allowed values: user agent
scope
required

What the intent selects within what the run may see. Facts: this conversation’s; the run’s end user’s only (same-user: none when the run names no participantId); the run’s project’s (none without a project); or every fact of the type it may see (tenant). Conversations: this end user’s other conversations with the agent (same-user: none when the run names no participantId); this conversation’s messages older than the history window (same-conversation); conversations in the run’s segment path (same-segment) or its project (same-project), whoever had them: those two quote other people’s conversations, so publishing warns and their messages are marked as another person’s. same-segment is for conversations only, tenant for facts only.

string
Allowed values: same-conversation same-user same-segment same-project tenant
limit
integer
>= 1
mode

With the user’s message as the query: full-text, by meaning (fails the turn with semantic-unavailable on a runtime without embeddings), or both fused by rank (without embeddings, the keyword half). Absent: the newest facts.

string
Allowed values: keyword semantic both
memory

How the agent uses what it retrieves.

object
instructionTypes

Fact types that are instructions for this agent: a retrieved, verified fact of one of these types goes into the system message under ‘Policies (verified)’. Default: none.

Array<string>
remember

Lets the agent remember: its turns offer the built-in tool kindgi_remember (built-in tools are kindgi_<verb>; an agent cannot list one in tools, and a published tool cannot use the prefix). The model picks the type, the text (up to 2,000 characters), an optional slot key and when it stops being true; the scope comes from here and the run. Every remembered fact is unverified, attributed to the agent version and the call that wrote it, and expires after keepDays unless a person verifies it. A person approves it before any read sees it when the scope is wider than one person (same-project, tenant) or the text reads like an instruction.

object
types
required

The fact types it may write.

Array<string>
>= 1 items
scope
required

Where its facts go: the conversation’s end user (else the user the run acts for), the conversation, the run’s project, or the workspace (tenant). Each but tenant includes the run’s project.

string
Allowed values: same-user same-conversation same-project tenant
keepDays

Days an unverified fact is kept. Default 30.

integer
>= 1 <= 3650
files

Lets the agent’s model change its run’s files, text only. update: true offers the built-in tool kindgi_update_file: a new version of a text file the run has, given the version the model read. create: true offers kindgi_create_file: a new text file of the run’s. Built-in tools are kindgi_<verb>; an agent can’t list one in tools. Each call changes something, so the agent’s approval rules apply, and the run needs write where the file is. A runtime with no file store offers neither. Absent: neither tool.

object
update

Offers kindgi_update_file. Absent means false.

boolean
create

Offers kindgi_create_file. Absent means false.

boolean
guardrails
required
Array<string>
preferredProvider

Soft hint — the router prefers this provider by id (e.g. anthropic) when at least one of its models satisfies capabilities.needs + workspace policy. Combine with preferredModel to pin the exact (provider, model) tuple.

string
>= 1 characters
preferredModel

Soft hint at the model level (ModelInfo.name). Combined with preferredProvider to pin an exact tuple; alone to select a model across every provider that exposes it.

string
>= 1 characters
conversationPolicy
object
historyLimit
integer
>= 1
hitlAfterTurns
integer
>= 1
hitl

When the agent’s turns and tool calls wait for a person’s approval: its tool gates, the reviewer role their approvals need, four eyes, how long an approval waits, and the session gate. The workspace’s approval rules can only make them stricter.

object
afterTurns

Once the conversation has this many completed turns, each new turn waits for an approval before it runs. Takes precedence over hitlAfterTurns.

integer
>= 1
tools

The agent’s tool gates. A tool overrides doesn’t name takes default. Without default, a read-only tool (mutating: false) runs without asking and any other tool asks on first use. Without tools, the agent’s own rules gate no tool.

object
default

A tool’s gate. never_ask: its calls run without asking. ask_on_first_use: a call asks the first time the conversation makes it with those arguments, and once approved, the same call runs without asking. always_ask: every call asks.

string
Allowed values: never_ask ask_on_first_use always_ask
overrides

By tool id: a mode, or a mode and the reviewer role its approvals need.

object
key
additional properties
One of:

A tool’s gate. never_ask: its calls run without asking. ask_on_first_use: a call asks the first time the conversation makes it with those arguments, and once approved, the same call runs without asking. always_ask: every call asks.

string
Allowed values: never_ask ask_on_first_use always_ask
defaultReviewerRole

Reviewer role class. Hierarchy: standard < senior < admin.

string
Allowed values: standard senior admin
separateApprover
One of:
boolean
timeoutMs

How long an approval waits for a decision, in milliseconds. Default 24 hours. The workspace’s approval rules may cap it.

integer
>= 1
onTimeout

What an approval does when its time runs out: it goes to the next reviewer role, and at admin it expires and the turn fails. The only behavior, and the default.

string
Allowed values: escalate
budget
object
maxSteps
integer
>= 1
maxCostUsd
number
maxWallMs
integer
>= 1
tags
Array<string>
output
object
schema
required

JSON Schema (draft 2020-12) the final answer must match.

object
name

A name for the output, shown to the model and in errors. Default output.

string
>= 1 characters
maxRepairs

How many times the model is asked to repair an invalid answer. Default 1.

integer
toolErrors
object
maxRetries

Failed calls sent back to the model per turn. Default 1.

integer
<= 10
retryOn

Which failures are sent back: arguments that don’t fit the input schema (invalid-arguments), a tool the agent doesn’t have (unknown-tool), a tool that ran and failed (tool-error), a tool that failed the call on purpose (tool-failed). Default invalid-arguments, unknown-tool.

Array<string>
unique items
Allowed values: invalid-arguments unknown-tool tool-error tool-failed
parallelToolCalls

Whether calls to read-only tools (mutating: false, no changing effect) that a model step asks for one after another run at the same time, up to 8 at once. A call to a read-only tool that pauses or declares connections runs on its own, since it may wait. Default true. false: every call runs on its own, in the order the model asked for them. Either way, the step’s results reach the conversation and the model in that order, and once a call needs a review, the step’s calls that haven’t started run one at a time. It doesn’t change what the model may ask for.

boolean
mcp

Whether an agent or a flow is a tool in a person’s chat app, through the API’s MCP server (/mcp). An agent’s tool is named by its id, a flow’s by flow. and its id. The chat app lists it only to people who can see it. Absent, or expose: false: it isn’t one.

object
expose
required

Offer it as a tool to the people who can see it.

boolean
readOnly

Tells the chat app that a run changes nothing (the tool’s readOnlyHint). Absent: no hint, so the chat app applies the protocol’s default.

boolean
destructive

Tells the chat app that a run may change or remove things in a way that can’t be undone (the tool’s destructiveHint). Absent: no hint, so the chat app applies the protocol’s default.

boolean

Agent published.

Media typeapplication/json
object
agentId
required
string
version
required
string
warnings

What the agent should know about this deployment before its first turn, e.g. semantic-unavailable (a retrieval intent searches by meaning and the deployment has no embeddings), remember-unavailable (the agent remembers and the deployment cannot store agent memories), recall-other-people (an intent recalls conversations in the run’s segment or project, whoever had them), recall-unavailable (the deployment cannot recall earlier conversations) or files-unavailable (the agent declares files and the deployment has no file store).

Array<object>
object
code
required
string
message
required
string
planWarning

The plan limits’ counts that are at their plan or past it, with this write: flows and agents in production, against the license key’s plan or the workspace’s own limit. Past most, new ones are refused (plan-limit-reached); what runs keeps running.

object
>= 1 properties
flows
object
plan
required

The plan’s number: the license key’s, or the workspace’s own limit (TenantLimits).

integer
most
required

The most it runs: its plan and a margin. A write past this is refused.

integer
inUse
required

How many run in production, with this write.

integer
agents
object
plan
required

The plan’s number: the license key’s, or the workspace’s own limit (TenantLimits).

integer
most
required

The most it runs: its plan and a margin. A write past this is refused.

integer
inUse
required

How many run in production, with this write.

integer
Examplegenerated
{
"agentId": "example",
"version": "example",
"warnings": [
{
"code": "example",
"message": "example"
}
],
"planWarning": {
"flows": {
"plan": 1,
"most": 1,
"inUse": 1
},
"agents": {
"plan": 1,
"most": 1,
"inUse": 1
}
}
}

Validation failed (see details.issues); or projectId isn’t a project id (a UUID). Or reference-out-of-scope: a tool, guardrail or data block it names isn’t registered in its project, its org or the workspace (details.issues, each with path, kind and id).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Missing / malformed / expired / revoked bearer token.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

permission-denied: the caller may not make this change. Or plan-limit-reached: this adds flows or agents to production past the most this runtime’s license key runs, so none of them is added; what runs keeps running. details has projectId (on a reinstate, when its version records one); over, each count over (flows first) with its limit (flows or agents), the number it adds (adding), and the key’s plan, most and inUse when they count this workspace alone; the first of them again at the top (details.limit, …); newIds, the flows and agents it adds; and next, where a larger plan is, when the runtime names one. Without an authorization store, key-project-mismatch (details.keyProjectId): the API key or session is limited to a project, and this writes above it, to the workspace, an org or a team (with a store, that is permission-denied).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

The body’s projectId names no project of this workspace (project-not-found).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

agent-already-registered: that (id, version) is taken. Or agent-project-mismatch: the agent’s versions live in another project (an agent belongs to the project its first version was published into and never moves, though in a workspace with environment orders a version may be made in another project of that project’s order; the message doesn’t name the project). Or environment-takes-promotions: the project is a later environment of an environment order, which takes builds only by promotion from the one before it; publish in the order’s first environment instead (details.firstProjectId, when you can read that project; details.position, the project’s place from 0). Nothing is written. Or registry-read-only: this registry takes no writes (under kindgi dev, the pack’s files are the source); the message says what to do instead. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}
Retry-After
integer
>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

The request body is over the API’s limit (request-too-large; details.maxBytes says how much).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

rate-limit-exceeded with details.limit: "schema-compile-time", on a server with a compile budget (Kindgi Cloud): this workspace’s schemas spent details.budgetMs compiling in the last 60 seconds. Nothing was stored; Retry-After says when to send it again. Or rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}
Retry-After
integer
>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

Server error (unmapped domain code or framework crash).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

plan-count-busy (with Retry-After): counting the flows and agents in production took too long, so none of them is added; a retry is safe. Or idempotency-store-unavailable (with Retry-After): the Idempotency-Key store couldn’t be read before the request ran, so nothing was changed. Or the authorization store couldn’t be reached (authz-backend-unavailable, with Retry-After), or the database was too busy for the authorization check (database-busy, with Retry-After), so the request wasn’t run. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}
Retry-After
integer
>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

See also