Create a guardrail set
Creates one reusable ordered set.
An omitted definition, or omitted definition.guardrails, normalizes to {"guardrails":[]}.
For each rule, authored whitespace is normalized as described by its schema, and an omitted kind means llm. The response always emits the canonical kind.
Idempotency
Idempotency-Key is required for API-key clients. Replaying the identical logical request returns the original 201 status, body, Location, ETag and Cache-Control with Idempotency-Replayed: true, and creates no second resource or audit event.
Reusing the key with a different method, path, query, security context or body returns 409.
bearerAuthAuthorizationBearer <token>Use a Voice API key or connected-app OAuth access token. Authentication.
Idempotency-Key*stringRequired. Reuse the same key to retry this write safely. Retries and idempotency.
^[A-Za-z0-9!#$%&'*+.^_`|~-]+$1 <= length <= 255application/json- body
Creates one immutable-slug catalog resource. slug, name, description, rule identifiers, rule names, and severity are trimmed. Control characters are rejected in single-line fields. Omitted description becomes null and omitted definition becomes the canonical empty definition. 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.
slug*GuardrailSetSlugInputImmutable workspace-unique slug on create. The complete raw value contains at most 64 Unicode characters. Surrounding Unicode separator characters are accepted and removed; the normalized value contains 2–64 lowercase ASCII letters, digits, hyphens, or underscores. Controls, internal whitespace, uppercase letters, and unpaired Unicode surrogate escapes are rejected.
^\p{Z}*[a-z0-9_-]{2,64}\p{Z}*$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 <= 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.
Guardrail set created and returned in canonical form.
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 POST 'https://api.kejue.co/v1/guardrail-sets' \ -H 'Idempotency-Key: string' \ -H 'Content-Type: application/json' \ -d '{ "slug": "payment_safety", "name": "Payment safety", "description": "Prevent collection of payment credentials.", "definition": { "guardrails": [ { "id": "never-request-card", "name": "Do not collect cards", "severity": "high", "instruction": "Never ask the caller to read a complete payment-card number, CVV, PIN, password, or one-time passcode." }, { "id": "prohibited-phrases", "name": "Block credential prompts", "severity": "block", "kind": "static", "phrases": [ "read me your password", "tell me the one time passcode" ] } ] }}'{ "id": "11111111-1111-4111-8111-111111111111", "slug": "payment_safety", "name": "Payment safety", "description": "Prevent collection of payment credentials.", "archived_at": null, "created_at": "2026-07-20T09:00:00Z", "updated_at": "2026-07-20T09:00:00Z", "definition": { "guardrails": [ { "id": "never-request-card", "name": "Do not collect cards", "severity": "high", "kind": "llm", "instruction": "Never ask the caller to read a complete payment-card number, CVV, PIN, password, or one-time passcode." }, { "id": "prohibited-phrases", "name": "Block credential prompts", "severity": "block", "kind": "static", "phrases": [ "read me your password", "tell me the one time passcode" ] } ] }}