Register an guardrail
const url = 'https://example.com/v1/guardrails';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"id":"example","projectId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","name":"example","description":"example","kind":"zero-llm","check":"example","config":{},"action":{"on-violation":"halt","retry":{"maxAttempts":1},"escalateTo":"example","compensateWith":"example"},"severity":"info","scope":{"when":"always","agents":["example"],"flows":["example"],"tenants":["example"],"tools":["example"]},"at":"before-tool","sees":"turn","budget":{"maxCostUsd":1,"maxLatencyMs":1},"judgeCapabilities":{}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/guardrails \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "id": "example", "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "description": "example", "kind": "zero-llm", "check": "example", "config": {}, "action": { "on-violation": "halt", "retry": { "maxAttempts": 1 }, "escalateTo": "example", "compensateWith": "example" }, "severity": "info", "scope": { "when": "always", "agents": [ "example" ], "flows": [ "example" ], "tenants": [ "example" ], "tools": [ "example" ] }, "at": "before-tool", "sees": "turn", "budget": { "maxCostUsd": 1, "maxLatencyMs": 1 }, "judgeCapabilities": {} }'Body is a full Guardrail shape. Server validates via @kindgi/guardrails.validateGuardrailSpec. The check id must reference an implementation already available to the runtime; check code is not uploaded through this route.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Guardrail spec. Validated server-side via @kindgi/guardrails.validateGuardrailSpec. Metadata-only registration: the check id must reference an implementation already available to the runtime.
object
Responses
Section titled “Responses”Guardrail registered.
object
Examplegenerated
{ "guardrailId": "example"}Validation failed (see details.issues); or projectId isn’t a project id (a UUID). Or reference-out-of-scope: a pack check it names isn’t registered in its project, its org or the workspace (details.issues); a built-in check is every project’s.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}permission-denied: the caller may not make this change. Without an authorization store, key-project-mismatch (details.keyProjectId): the API key or session is limited to a project, and this writes above it, to the workspace, an org or a team (with a store, that is permission-denied).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The body’s projectId names no project of this workspace (project-not-found).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Guardrail already registered at that id. Or environment-takes-promotions: the project is a later environment of an environment order, which takes builds only by promotion from the one before it; publish in the order’s first environment instead (details.firstProjectId, when you can read that project; details.position, the project’s place from 0). Nothing is written. Or registry-read-only: this registry takes no writes (under kindgi dev, the pack’s files are the source); the message says what to do instead. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}guardrail-config-invalid: the guardrail’s config breaks the configSchema of the check it names (a pack check’s, or a built-in’s), which would refuse it on every call. details.issues lists each problem, { path, message } with path a JSON pointer into the guardrail (/config/maxChars); the message names the guardrail, the check and the setting. Checked when the check’s deployment carries its schema.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "schema-compile-time", on a server with a compile budget (Kindgi Cloud): this workspace’s schemas spent details.budgetMs compiling in the last 60 seconds. Nothing was stored; Retry-After says when to send it again. Or rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/guardrails: List guardrails- Operate a self-hosted runtime
- Error code
authz-backend-unavailable - Error code
database-busy - Error code
environment-takes-promotions - Error code
guardrail-config-invalid - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
key-project-mismatch - Error code
permission-denied - Error code
project-not-found - Error code
rate-limit-exceeded - Error code
reference-out-of-scope - Error code
registry-read-only - Error code
request-too-large - Error code
tenant-state-unavailable - Every error code