Skip to content

Guardrails API Pro+

Manage infrastructure policy guardrails that evaluate Terraform plans before they are applied.

Endpoints Summary

MethodEndpointDescription
GET/api/guardrailsList all guardrails
POST/api/guardrailsCreate a guardrail
GET/api/guardrails/:idGet guardrail details
PATCH/api/guardrails/:idUpdate a guardrail
DELETE/api/guardrails/:idDelete a guardrail
POST/api/guardrails/:id/deployDeploy to repositories
POST/api/guardrails/:id/undeployRemove from repositories
GET/api/guardrails/templatesList guardrail templates

Authentication

All endpoints require a Bearer token in the Authorization header.

Authorization: Bearer <your-api-token>

List Guardrails

GET /api/guardrails

Returns all guardrails for the current organization.

Query Parameters:

ParameterTypeDescription
statusstringFilter: active, inactive
enforcementstringFilter by mode: block, warn, dry_run, require_approval
pagenumberPage number (default: 1)
limitnumberItems per page (default: 20)

Example:

bash
curl -X GET "https://api.controlinfra.com/api/guardrails?enforcement=block" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "guardrails": [
    {
      "_id": "665a1b2c3d4e5f6a7b8c9d0e",
      "name": "No Public S3 Buckets",
      "description": "Prevent S3 buckets with public access",
      "enforcement": "block",
      "rules": [
        {
          "resourceType": "aws_s3_bucket",
          "attribute": "acl",
          "operator": "equals",
          "value": "public-read"
        }
      ],
      "deployedTo": ["663f1a2b...", "663f1a2c..."],
      "evaluationCount": 45,
      "violationCount": 3,
      "createdAt": "2025-01-01T00:00:00Z"
    }
  ],
  "total": 8,
  "page": 1,
  "pages": 1
}

Create a Guardrail

POST /api/guardrails

Request Body:

FieldTypeRequiredDescription
namestringYesGuardrail name
descriptionstringNoDescription
enforcementstringYesblock, warn, dry_run, or require_approval
rulesarrayYesOne or more policy rules
rules[].resourceTypestringYesTerraform resource type (e.g., aws_s3_bucket)
rules[].attributestringYesAttribute to evaluate
rules[].operatorstringYesComparison operator
rules[].valueanyNoValue to compare against (not needed for exists/not_exists)

Example:

bash
curl -X POST "https://api.controlinfra.com/api/guardrails" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Enforce Encryption at Rest",
    "description": "All RDS instances must have storage encryption enabled",
    "enforcement": "block",
    "rules": [
      {
        "resourceType": "aws_db_instance",
        "attribute": "storage_encrypted",
        "operator": "equals",
        "value": false
      }
    ]
  }'

Response: 201 Created

json
{
  "_id": "665a1b2c3d4e5f6a7b8c9d0e",
  "name": "Enforce Encryption at Rest",
  "enforcement": "block",
  "rules": [...],
  "deployedTo": [],
  "createdAt": "2025-01-15T10:00:00Z"
}

Get Guardrail Details

GET /api/guardrails/:id

Returns full details including evaluation history.

Example:

bash
curl -X GET "https://api.controlinfra.com/api/guardrails/665a1b2c3d4e5f6a7b8c9d0e" \
  -H "Authorization: Bearer YOUR_TOKEN"

Update a Guardrail

PATCH /api/guardrails/:id

Update guardrail properties. Only provided fields are updated.

Example:

bash
curl -X PATCH "https://api.controlinfra.com/api/guardrails/665a1b2c3d4e5f6a7b8c9d0e" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "enforcement": "warn",
    "description": "Updated: warn instead of block"
  }'

Delete a Guardrail

DELETE /api/guardrails/:id

Deletes the guardrail and removes it from all deployed repositories.

Example:

bash
curl -X DELETE "https://api.controlinfra.com/api/guardrails/665a1b2c3d4e5f6a7b8c9d0e" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response: 204 No Content


Deploy Guardrail

POST /api/guardrails/:id/deploy

Deploy a guardrail to one or more repositories.

Request Body:

FieldTypeRequiredDescription
repositoryIdsstring[]YesRepository IDs to deploy to

Example:

bash
curl -X POST "https://api.controlinfra.com/api/guardrails/665a1b2c.../deploy" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "repositoryIds": ["663f1a2b...", "663f1a2c..."]
  }'

Response:

json
{
  "message": "Guardrail deployed to 2 repositories",
  "deployedTo": ["663f1a2b...", "663f1a2c..."]
}

Undeploy Guardrail

POST /api/guardrails/:id/undeploy

Remove a guardrail from repositories.

Request Body:

FieldTypeRequiredDescription
repositoryIdsstring[]YesRepository IDs to remove from

Example:

bash
curl -X POST "https://api.controlinfra.com/api/guardrails/665a1b2c.../undeploy" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "repositoryIds": ["663f1a2b..."]
  }'

List Templates

GET /api/guardrails/templates

Returns built-in guardrail templates.

Example:

bash
curl -X GET "https://api.controlinfra.com/api/guardrails/templates" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "templates": [
    {
      "_id": "tpl_no_public_s3",
      "name": "No Public S3 Buckets",
      "description": "Block S3 buckets with public ACLs or public access",
      "category": "security",
      "rules": [
        {
          "resourceType": "aws_s3_bucket",
          "attribute": "acl",
          "operator": "equals",
          "value": "public-read"
        }
      ]
    },
    {
      "_id": "tpl_enforce_encryption",
      "name": "Enforce Encryption",
      "description": "Require encryption on RDS, S3, EBS, and EFS",
      "category": "security",
      "rules": [...]
    }
  ]
}

TIP

Use templates as a starting point. Create a guardrail from a template by copying its rules into a POST /api/guardrails request and customizing as needed.