Guardrails
Preview

Create a guardrail

Makes version 1. Where it applies is a list of conditions that all have to hold; what it requires is a list of requirements. A relaxing guardrail holds one fast path and waives the approvals other guardrails ask for where it holds. Taking `guardrail:manage` on the organization.

POST
/guardrails
cookiebetter-auth.session_token<token>

Better Auth session cookie. Production uses the __Secure- prefixed name.

Idempotency-Key?string

Makes retries safe. A repeated key with the same request returns the first result and sets Idempotent-Replayed: true. The same key with a different request answers 409 idempotency.key_reused, and while the first request is still running 409 idempotency.in_progress. Results are kept for 24 hours. Server errors and refusals for lack of sign-in or permission are not kept, so a retry runs again.

Match^[A-Za-z0-9_.:-]+$
Length1 <= length <= 255
application/json
  1. body
fromPreset?string

The preset the guardrail is made from; kept for the editor's "From preset" chip.

Lengthlength <= 120
name*string
Length1 <= length <= 80
description?string
Lengthlength <= 300
kind?string
Value in"rule""relax"
ownerTeamId?string
mode*string
Value in"enforce""warn""off"
scope?array<>
Itemsitems <= 20
requires*array<>
Items1 <= items <= 20
actions?array<>

The actions it governs; left out, release and rollback.

Itemsitems <= 4
summary?string

What changed, for the history.

Lengthlength <= 200

Response Body

The new guardrail.

application/json
  1. response
actions*array<>

The actions it governs. A guardrail saved before it named any reads as release and rollback, which is what it has always governed.

id*string
Formatuuid
name*string
description*string
kind*string
Value in"rule""relax"
mode*string
Value in"enforce""warn""off"
builtin*boolean
fromPreset?string

The preset it was made from, when it was.

builtinKey?string

Set on the guardrails Wardn ships, such as protected_branch and freezes.

ownerTeamId?string

The team that owns it and alone may add exceptions; absent for the organization and for a caller who may not read the team.

ownerTeamName?string

The owning team's name, shown to anyone who reads the guardrail.

cover?
exceptionsInEffect?integer

Exceptions in effect on places the caller may see. Present on a single guardrail read, with cover.

scope*array<>
requires*array<>
version*
newestVersion*integer
archived*boolean
createdAt*string
Formatdate-time
updatedAt*string
Formatdate-time
Example Request
curl -X POST 'https://wardn.example.com/api/v1/guardrails' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "mode": "enforce",  "requires": [    {      "id": "string",      "kind": "approval"    }  ]}'
Example Response
{  "actions": [    "release"  ],  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "name": "string",  "description": "string",  "kind": "rule",  "mode": "enforce",  "builtin": true,  "fromPreset": "string",  "builtinKey": "string",  "ownerTeamId": "string",  "ownerTeamName": "string",  "cover": {    "deployments": 0,    "apps": 0,    "clusters": 0,    "leftOut": 0,    "summary": "string",    "lowered": [      "string"    ]  },  "exceptionsInEffect": 0,  "scope": [    {      "field": "class",      "op": "is",      "value": "string",      "label": "string"    }  ],  "requires": [    {      "id": "string",      "kind": "approval",      "count": 1,      "humanOnly": true,      "group": "security",      "level": "propose",      "when": "freeze",      "branch": "string",      "system": "servicenow",      "afterSeconds": 60,      "days": 1,      "label": "string"    }  ],  "version": {    "version": 1,    "summary": "string",    "mode": "enforce",    "createdBy": {      "id": "string",      "name": "string"    },    "createdAt": "2019-08-24T14:15:22Z"  },  "newestVersion": 0,  "archived": true,  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}