Skip to Content
Agents

Partially update the mutable agent draft

Permissionagents:updateAuthentication
PATCH
/agents/{id}/draft

Merge-patches one mutable draft. Omitted fields are preserved. Same-value patches return updated false and retain the aggregate revision. A stale If-Match fails before any persistence.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Use a Voice API key or connected-app OAuth access token. Authentication.

Path Parameters

id*string
Formatuuid

Header Parameters

If-Match?string

Optional strong ETag (or *) from a prior response. A stale tag returns 412 without changing the resource.

Request Body

application/json
  1. body

Merge-style patch of the one mutable draft. Omitted fields are preserved.

prompt?string

Non-blank prompt template. Omit it to preserve current content; null is invalid and an empty string cannot erase runnable content.

Length1 <= length <= 500000
pipeline_topology?string

Legacy engine selector; prefer pipeline_mode, which overrides it when both are sent. three_stage is accepted only when the deployment capability enables it, except that three_stage sent for a draft whose pipeline_mode is cascaded is the reported label being echoed back and is ignored. Most realtime STT integrations require two_stage_speechlm; the server validates the selected model's published capabilities.

Value in"three_stage""two_stage_speechlm"
pipeline_mode?string

Source-of-truth runtime pipeline selector. speech_model feeds the brain raw caller audio; cascaded feeds a realtime STT transcript to a text brain then TTS. Both modes run on the v2 turn engine, so the stored engine selector stays two_stage_speechlm; reads report pipeline_topology three_stage for cascaded and two_stage_speechlm for speech_model. Omit to preserve the current value.

Value in"speech_model""cascaded"
endpointing_mode?string

Legacy version-level turn endpointing selector; prefer behavior.turn_taking.endpointing_mode. auto uses the engine's default endpointing; stt uses STT-driven turn endpointing, which takes effect only on a cascaded pipeline with a transcriber whose stt_capabilities.endpointing in GET /providers reports capable and reliable; otherwise it falls back to auto at runtime rather than being rejected. Ignored when the same request supplies behavior: the value is then derived from behavior.turn_taking.endpointing_mode (absent means auto). Omit to preserve the current value. audio always uses the agent's own audio endpointer; auto lets Kejue pick (on the self-hosted speech recognizer that is the recognizer's own turn detection).

Value in"auto""stt""audio"
stt_language?string
Match^[A-Za-z0-9_-]*$
Lengthlength <= 64
stt_language_hints?array<string>

Languages the caller is expected to speak, for transcribers whose auto-detection takes a hint list (providers with stt_capabilities.language_hints: true in GET /providers). Each entry is a 2–3 letter language code with an optional two-letter region, such as ar, en, or pt-br; the server trims, lower-cases, and de-duplicates the list and drops blank entries, and at most 10 distinct codes may remain (code too_many). Every code must be in the selected provider's stt_capabilities.languages catalog. Send an empty array to clear; omit to preserve. Setting a non-empty list on a transcriber without the capability is rejected with code incompatible_model; a stored list survives an STT switch and is simply not forwarded.

stt_vocabulary?|

Per-agent recognition vocabulary: custom terms, free-text context notes, key/value hints, and spoken-to-written translations the recognizer should favor. Accepted when the selected transcriber advertises stt_capabilities.vocabulary: true in GET /providers (already resolved for the selected model). Send null or an empty object to clear; omit to preserve. Rejected with code incompatible_model otherwise.

behavior?

Complete version-scoped behavior document. Supplying behavior replaces the previous behavior document on the mutable draft; omitted behavior leaves it unchanged. Omitted blocks and fields use the runtime defaults documented on their schemas. New writes use only this canonical shape; supported legacy inactivity and transfer rows are normalized before public responses are emitted.

llm_provider_model_id?|

UUID of an enabled compatible catalog resource, or an empty string to clear the optional reference.

stt_provider_model_id?|

UUID of an enabled compatible catalog resource, or an empty string to clear the optional reference.

tts_provider_model_id?|

UUID of an enabled compatible catalog resource, or an empty string to clear the optional reference.

tts_voice_id?|

UUID of an enabled compatible catalog resource, or an empty string to clear the optional reference.

speechlm_provider_model_id?|

UUID of an enabled compatible catalog resource, or an empty string to clear the optional reference.

tts_voice_settings?

Writable provider-specific override layered over the selected voice's catalog settings. The selected connector permits only its advertised subset and can impose narrower ranges; inspect voice_settings_schema in GET /providers before authoring. Send {} to clear every per-agent override. Dialect is intentionally absent because it belongs to the selected voice catalog entry.

Response Body

Success

application/json
  1. response
id*string
Formatuuid
agent_id*string
Formatuuid
updated*boolean

False only when the patch was a semantic no-op.

revision*integer
Formatint64
Range1 <= value
updated_at*string

Aggregate update timestamp corresponding to revision.

Formatdate-time
draft*|

Full draft or immutable snapshot. Drafts have is_draft=true and omit version; immutable snapshots have is_draft=false and require their positive version number. prompt and workflow are mutually exclusive. Modern runnable rows have exactly one of them; neither is allowed only so a versionless or migrated legacy empty row remains readable and can be repaired through draft authoring.

Example Request
curl -X PATCH 'https://api.kejue.co/v1/agents/497f6eca-6276-4993-bfeb-53cbbbba6f08/draft' \  -H 'Content-Type: application/json' \  -d '{  "prompt": "You are a billing-triage assistant. Keep answers concise for {{vars.customer_tier}} callers in call {{system.call_id}}.",  "pipeline_topology": "two_stage_speechlm"}'
Example Response
{  "id": "22222222-2222-4222-8222-222222222222",  "agent_id": "11111111-1111-4111-8111-111111111111",  "updated": true,  "revision": 3,  "updated_at": "2026-07-20T09:08:00Z",  "draft": {    "id": "22222222-2222-4222-8222-222222222222",    "is_draft": true,    "prompt": "You are a billing-triage assistant. Keep answers concise for {{vars.customer_tier}} callers in call {{system.call_id}}.",    "pipeline_topology": "two_stage_speechlm",    "pipeline_mode": "speech_model",    "endpointing_mode": "auto",    "created_at": "2026-07-20T09:00:00Z"  }}