Editing the draft
How PATCH /v1/agents/{id}/draft works — merge-patch semantics, how to clear a value, size limits, and where every settings field is documented.
Every agent setting is written through PATCH /v1/agents/{id}/draft, then
promoted and deployed (Agents). This page covers write
semantics; the fields live in the map below.
curl -X PATCH https://api.kejue.co/v1/agents/AGENT_ID/draft \
-H "Authorization: Bearer $KEJUE_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"prompt": "Collect the policy number before incident details.",
"behavior": {
"guardrails": {"guardrail_set_ids": ["GUARDRAIL_SET_ID"]}
}
}'Merge-patch semantics
The draft patch is a merge patch at the top level only: omitted top-level
fields keep their values; an empty object body is a successful no-op
(updated: false). Nested objects are not merged — behavior replaces the
complete behavior document, so read the draft first and resend every block
you keep.
Clearing is explicit and field-dependent:
| You send | Effect |
|---|---|
| Field omitted | Current value preserved |
{} as the whole body | No-op; updated: false |
prompt | Replaces the prompt; cannot be blank |
behavior: {...} | Replaces the whole object; omitted blocks reset to documented defaults. behavior: {} resets everything and removes all assignments. |
"" on a model/voice reference (llm_provider_model_id, stt_provider_model_id, tts_provider_model_id, tts_voice_id, speechlm_provider_model_id) | Clears the selection |
null on those references | Rejected — 422 validation_failed, field code invalid_type. null never clears. |
"" on stt_language | Clears the fixed language |
{} on tts_voice_settings | Clears the per-agent voice override |
Limits and validation
prompt ≤ 500,000 characters; behavior and tts_voice_settings ≤ 1 MiB
each. Validation failures return 422 validation_failed with exact field
paths in error.details.fields; the draft is never partially changed. Draft
patches need no idempotency key — retries are safe.
The legacy storage fields model_config and stt_hints are not public and
are rejected as unknown fields. behavior is closed too: unknown fields
error instead of being silently dropped.
Where the fields live
| Page | Covers |
|---|---|
| Speech & turn-taking | Pipeline mode, endpointing, transcription language, models and voice, voice settings, turn taking, background noise |
| Conversation behavior | Temperature, opening, connection wait, recording, inactivity, memory, resume |
| Transfers & call actions | System tools (transfers, scheduling, end call), tool/MCP, guardrail, and pronunciation assignments, transfer records |
| Prompt variables | Everything the prompt can reference |
| Guardrails | Authoring guardrail sets |
| Pronunciation | Authoring pronunciation tables |
| Voices & models | The catalog the model/voice reference fields point into |