---
title: "Update agent with row_version"
method: PATCH
path: "/v1/agents/{agent_id}"
tags: ["Agents"]
---

# Update agent with row_version

`PATCH /v1/agents/{agent_id}`

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1/agents/{agent_id}`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Product compare-and-set update. row_version is required and must match the current value. Explicit null values are rejected. A successful write creates a new version.

## Headers

- `Idempotency-Key` string

## Request body

- AgentReplaceRequest: Supplied fields replace saved values; explicit null values are rejected.
  - `name` string
  - `model` string: Model ID from the Models API, such as deepseek/deepseek-v4-flash.
  - `instructions` string
  - `description` string
  - `metadata` object: Keys up to 64 characters.
  - `service_tier` 'auto' | 'default' | 'flex' | 'priority' | 'fast'
  - `runtime_profile` 'codex' | 'claude' | 'mcode'
  - `tools` union[]
    - union
      - AgentFunctionTool: Saved function tool. Runs that request a client-side tool result are not supported yet.
        - `type` 'function', required
        - `name` string, required
        - `description` string, required
        - `parameters` object, required: JSON Schema whose type is object.
        - `defer_loading` boolean
      - AgentWebSearchTool: At most one per Agent. Sessions, Services, and Schedules currently require mode disabled.
        - `type` 'web_search', required
        - `mode` 'disabled' | 'cached' | 'live'
        - `context_size` 'low' | 'medium' | 'high'
        - `allowed_domains` string[]
        - `location` object
          - `city` string
          - `country` string
          - `region` string
          - `timezone` string
  - `text` AgentText
    - `format` object
      - `type` 'text' | 'json_schema', required
      - `schema` object: Required for json_schema; its type must be object.
    - `verbosity` 'low' | 'medium' | 'high'
  - `reasoning` AgentReasoning
    - `effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'null', nullable
    - `summary` 'concise' | 'detailed' | 'auto' | 'null', nullable
  - `skills` AgentSkillRef[]
    - `skill_id` string, required: Skill ID (`skl_` prefix) owned by your organization or available from the public Skills catalog.
    - `version` string, nullable: Pinned Skill version. For a new binding, null resolves the current default when the Agent is saved. For an existing binding, null retains its pinned version; pass an explicit version to upgrade.
  - `mcp_connections` AgentMCPConnectionRef[]: Omission selects builtin:sandbase on create. An explicit array replaces the selection; [] disables all MCP tools. Null is rejected.
    - `connection_id` string, required: MCP connection ID (`mcp_` prefix), or builtin:sandbase for the built-in SandBase server.
    - `server_label` string, required: Label unique within the Agent.
    - `allowed_tools` string[], nullable: null allows every tool; an empty array allows none.
    - `required` boolean: Whether the Session must load this server.
  - `note` string: Change note recorded on the new version.
  - `row_version` integer, required

## Response `200`

Updated Agent

- Agent
  - `id` string, required: Agent ID (`agt_` prefix).
  - `object` 'agent', required
  - `model` string, required
  - `name` string, nullable, required
  - `instructions` string, nullable, required
  - `tools` object[], required
  - `text` AgentText, required
    - `format` object
      - `type` 'text' | 'json_schema', required
      - `schema` object: Required for json_schema; its type must be object.
    - `verbosity` 'low' | 'medium' | 'high'
  - `reasoning` object, required
  - `service_tier` string, required
  - `multi_agent` object, required: Always reports enabled false.
  - `visibility` 'private' | 'public', required
  - `status` 'active' | 'archived', required
  - `version` integer, required: Current version number.
  - `row_version` integer, required: Compare-and-set token for PATCH, archive, unarchive, and restore.
  - `projection_status` string, required: Whether the current version is ready for execution. Sessions require ready.
  - `runtime_profile` 'codex' | 'claude' | 'mcode', required
  - `description` string, required
  - `metadata` object, required
  - `mcp_connections` AgentMCPConnectionRef[], required
    - `connection_id` string, required: MCP connection ID (`mcp_` prefix), or builtin:sandbase for the built-in SandBase server.
    - `server_label` string, required: Label unique within the Agent.
    - `allowed_tools` string[], nullable: null allows every tool; an empty array allows none.
    - `required` boolean: Whether the Session must load this server.
  - `skills` AgentSkillRef[], required
    - `skill_id` string, required: Skill ID (`skl_` prefix) owned by your organization or available from the public Skills catalog.
    - `version` string, nullable: Pinned Skill version. For a new binding, null resolves the current default when the Agent is saved. For an existing binding, null retains its pinned version; pass an explicit version to upgrade.
  - `created_at` integer, required: Unix seconds.
  - `updated_at` integer, required: Unix seconds.
  - `archived_at` integer, nullable, required: Unix seconds.
  - `failure_code` string

## Other responses

- `400`: invalid_request (malformed JSON, unknown fields, failed validation, or an unsupported option)
- `401`: unauthorized: missing, malformed, or conflicting API key headers
- `402`: spending_limit_exceeded: API key spending limit or organization balance exhausted
- `403`: insufficient_scope (scoped key) or org_disabled
- `404`: not_found: the resource does not exist in this organization
- `409`: conflict: stale row_version, lifecycle state, or Idempotency-Key reused with a different body
- `502`: executor_rejected or executor_contract_error from the execution layer
- `503`: authorization_unavailable, admission_unavailable, executor_unavailable, storage_unavailable, or internal_error

---

[API](https://skmtc.dev/sandbase/apis/sandbase-api.md) · [All operations](https://skmtc.dev/sandbase/apis/sandbase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbase/apis/sandbase-api/revisions/d40df2467ba2?raw)
