Update a guardrail set
Replaces any supplied name, description, or complete definition. Omitted fields are unchanged, a null or blank description clears it, and slug is immutable. Archived sets return 409.
A definition change is measured against every agent using it
The candidate definition is checked across every active draft, staging and production agent version that references this set. A 422 validation_failed response identifies each affected agent and stage, and returns either assigned_agent_configuration_invalid when an existing assignment must be repaired first, or one of:
assigned_agent_guardrail_rule_budget_exceededassigned_agent_guardrail_instruction_budget_exceededassigned_agent_guardrail_phrase_budget_exceededassigned_agent_guardrail_phrase_character_budget_exceeded
Detach the set from an agent, or reduce the candidate definition, before retrying.
Concurrency
If-Match is optional: omitting it is an unconditional write, * accepts the current representation, and one or a comma-separated list of strong tags is accepted when any tag matches. Malformed or weak tags return 400; stale strong tags return 412 with the current ETag.
A semantic no-op writes only a no-op audit event and preserves updated_at, the resource version, the response body and the ETag.
bearerAuthAuthorizationBearer <token>Use a Voice API key or connected-app OAuth access token. Authentication.
id*stringuuidIf-Match?stringOptional strong ETag (or *) from a prior response. A stale tag returns 412 without changing the resource.
application/json- body
Partial metadata update with complete replacement semantics for definition. slug is not patchable. At least one supported field must be present. A JSON request body over 4,194,304 encoded bytes returns 413; a definition over its narrower 1,048,576 byte limit returns 422 with a definition field error.
1 <= propertiesname?GuardrailSetNameHuman label after trimming. The raw and normalized value must each contain 1–200 Unicode characters and no control characters.
1 <= length <= 200description?|Optional authored description. Leading/trailing whitespace is removed; null or a blank string normalizes to null. The raw and normalized value must contain at most 2000 Unicode characters. Newline, carriage return, and tab are accepted; other control characters and unpaired Unicode surrogate escapes are rejected.
length <= 2000definition?Complete ordered set replacement. Omission of this object on create, or omission of guardrails within it, normalizes to guardrails:[]. The encoded definition and its normalized form must each be at most 1,048,576 bytes. One definition may contain at most 100 rules; a larger array reports too_many_items at definition.guardrails. Once shape-valid, a single set is admitted only when it contains at most 40,000 LLM-instruction characters, 1,000 static phrases, and 100,000 static-phrase characters, reported respectively as guardrail_instruction_budget_exceeded, guardrail_phrase_budget_exceeded, and guardrail_phrase_character_budget_exceeded. An agent's ordered aggregate of assigned sets has those same limits plus the 100-rule limit; the first set ID that crosses a limit reports guardrail_rule_budget_exceeded or the corresponding character/phrase code at behavior.guardrails.guardrail_set_ids[i]. A live definition PATCH uses the analogous assigned_agent_guardrail_* code at definition and names the affected agent and deployment stage.
Updated set, or the unchanged set for a semantic no-op.
application/json- response
Complete normalized resource. configuration_errors is omitted for canonical rows. When present, it identifies legacy stored fields/rules that were unsafe to emit or an aggregate runtime budget exceeded by the stored definition. When the root and guardrails array are representable, invalid rules are omitted independently. A malformed or missing root/array, a stored definition above the 1,048,576-byte encoded limit, or an oversized normalized safe view returns the canonical empty definition instead. A legacy array above 100 rules is truncated to its first 100 entries and reports too_many_items; those entries are then normalized independently. Aggregate-only diagnostics retain every individually valid rule among those first 100, so this object always remains schema-valid and can be repaired with one complete-definition PATCH.
id*stringuuidslug*GuardrailSetSlugCanonical immutable workspace-unique slug emitted after input normalization. It contains only lowercase ASCII letters, digits, hyphens, and underscores and never includes surrounding whitespace.
^[a-z0-9_-]+$2 <= length <= 64name*GuardrailSetNameHuman label after trimming. The raw and normalized value must each contain 1–200 Unicode characters and no control characters.
1 <= length <= 200description*|Optional authored description. Leading/trailing whitespace is removed; null or a blank string normalizes to null. The raw and normalized value must contain at most 2000 Unicode characters. Newline, carriage return, and tab are accepted; other control characters and unpaired Unicode surrogate escapes are rejected.
length <= 2000archived_at*|date-timecreated_at*stringdate-timeupdated_at*stringdate-timedefinition*Canonical response definition. guardrails is always present and preserves authored rule order.
configuration_errors?array<>Exact legacy-repair diagnostics. Replace the complete definition using the current ETag; do not assume an omitted invalid rule or a rule beyond the 100-entry response boundary still executes. When the returned definition is empty because its root/array could not be represented safely or the stored definition exceeded the encoded-size limit, do not infer that any stored rule executes. An oversized legacy array uses too_many_items. Container/rule diagnostics use stored_value_invalid, too_large, invalid_type, unknown, required, too_many_items, too_few_items, too_long, invalid, invalid_unicode, invalid_format, invalid_enum, duplicate, or not_allowed as applicable. Aggregate diagnostics can use guardrail_instruction_budget_exceeded, guardrail_phrase_budget_exceeded, or guardrail_phrase_character_budget_exceeded without omitting individually valid rules from the returned definition.
1 <= itemscurl -X PATCH 'https://api.kejue.co/v1/guardrail-sets/497f6eca-6276-4993-bfeb-53cbbbba6f08' \ -H 'Content-Type: application/json' \ -d '{ "description": "Credential collection and disclosure policy.", "definition": { "guardrails": [ { "id": "never-request-card", "severity": "high", "kind": "llm", "instruction": "Never request or repeat complete payment credentials." }, { "id": "prohibited-phrases", "severity": "block", "kind": "static", "phrases": [ "read me your password" ] } ] }}'{ "id": "11111111-1111-4111-8111-111111111111", "slug": "payment_safety", "name": "Payment safety", "description": "Credential collection and disclosure policy.", "archived_at": null, "created_at": "2026-07-20T09:00:00Z", "updated_at": "2026-07-20T09:30:00Z", "definition": { "guardrails": [ { "id": "never-request-card", "severity": "high", "kind": "llm", "instruction": "Never request or repeat complete payment credentials." }, { "id": "prohibited-phrases", "severity": "block", "kind": "static", "phrases": [ "read me your password" ] } ] }}