---
title: "Edit an agent as a draft"
method: POST
path: "/api/v1/agent-definitions/{definition_id}/revisions"
tags: ["authed"]
---

# Edit an agent as a draft

`POST /api/v1/agent-definitions/{definition_id}/revisions`

## Request

- Base URL: `https://api.teaflask.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.teaflask.com/api/v1/agent-definitions/{definition_id}/revisions`
- Auth: none declared

Save an edit to an agent's configuration as a draft revision; it
isn't live until published with publish_agent_definition. Read the
agent with get_agent_definition just before editing and pass its
latest_revision.id as parent_revision_id and
latest_revision.content_version as parent_content_version. If anyone
changed the agent since that read, nothing is stored and you're told
so: read it again, reapply your edit, and save again. The agent's
configuration is checked the same way either way, and a refused
configuration is described problem by problem.

## Path parameters

- `definition_id` string, uuid, required: The agent's id, as list_agent_definitions returns it.

## Request body

- CreateAgentDefinitionRevisionRequest: Saving an edit: the revision the editor started from becomes the parent — lineage is how history and future diffs work.
  - `config` object, required: The agent's whole configuration, "version": "agent/v1", shaped like get_agent_definition's latest_revision.config.
  - `parent_revision_id` string, uuid, required: latest_revision.id from get_agent_definition, read just before editing.
  - `parent_content_version` integer, required: latest_revision.content_version from the same read.
  - `amend_working_draft` boolean: Leave false unless re-saving a draft you just saved. When true and latest_revision is your own unpublished draft saved in the last 30 minutes and not yet run in the playground, that draft is updated in place and keeps its id; otherwise a new draft revision is added with a new id.

## Response `200`

The editor's open working draft was amended in place

- AgentDefinitionRevisionResponse
  - `id` string, uuid, required: The revision's id.
  - `agent_definition_id` string, uuid, required: The agent it belongs to.
  - `parent_revision_id` string, uuid, nullable, required: The revision this one was edited from; null for the first.
  - `config` object, required: The agent's whole configuration: model (which model answers and how hard it thinks), routing (fallback models) and user_model_choice (whether visitors may pick the model); prompt (its system prompt); tools (what it may use: searching and reading docs, navigating, reading, highlighting and filling in pages of the organization's own app, calling the organization's API actions by slug, handing work to subagents, a code workspace, the page register); docs_scope and skills (which docs and skills it may read); memory (whether it remembers each signed-in visitor); suggestions (first questions offered to visitors); end_users (whether visitors must sign in or connect an AI subscription, and what they may spend before one is required); and steering and interventions (the checks that steer or stop its actions).
  - `config_format` 'agent/v1', required: Versions of the agent config vocabulary; evolves additively, never in place.
  - `status` 'draft' | 'published' | 'superseded', required
  - `authored_by_user_id` string, uuid, required: The member who wrote it.
  - `content_version` integer, required: Changes each time this revision is edited in place; send it back as parent_content_version.
  - `created_at` string, date-time, required: When the revision was created.
  - `updated_at` string, date-time, required: When the revision last changed: an edited draft or a status change.

## Other responses

- `201`: Successful Response
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not found
- `405`: Method not allowed
- `422`: Validation error
- `500`: Internal server error

---

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