---
title: "Create a new Guardrail Rule"
method: POST
path: "/guardrails"
tags: ["Guardrails"]
---

# Create a new Guardrail Rule

`POST /guardrails`

Creates a new guardrail rule with optional notification setup

## Request body

- CreateGuardrailRequest
  - `id` string — Unique identifier of the guardrail rule
  - `accountId` string — Unique identifier of the associated account
  - `createdBy` string, required — Name of the user who created the rule
  - `name` string, required — Name of the guardrail rule
  - `type` 'policy' | 'cost' | 'resource' | 'tag', required — Type of the guardrail rule
  - `scope` object, required — Scope of the guardrail rule
    - `workspaces` object, required — A pattern for including and excluding items using wildcards
      - `include` string[], required — List of patterns to include
      - `exclude` string[] — List of patterns to exclude
    - `repositories` object, required — A pattern for including and excluding items using wildcards
      - `include` string[], required — List of patterns to include
      - `exclude` string[] — List of patterns to exclude
    - `branches` object, required — A pattern for including and excluding items using wildcards
      - `include` string[], required — List of patterns to include
      - `exclude` string[] — List of patterns to exclude
    - `labels` object, required — A pattern for including and excluding items using wildcards
      - `include` string[], required — List of patterns to include
      - `exclude` string[] — List of patterns to exclude
  - `criteria` Criteria, required
    - `cost` union
      - object
        - `thresholdAmount` number, float, required — Absolute threshold amount (in USD) for cost criteria
        - `thresholdPercentage` number, float — Percentage threshold for cost criteria
      - object
        - `thresholdAmount` number, float — Absolute threshold amount (in USD) for cost criteria
        - `thresholdPercentage` number, float, required — Percentage threshold for cost criteria
    - `policy` PolicyCriteria
      - `severity` string — Severity level for policy criteria
      - `policies` Policies — List of policies to include or exclude
        - `include` string[] — List of patterns to include
        - `exclude` string[] — List of patterns to exclude
    - `resource` ResourceCriteria
      - `actions` ResourceActionEnum[], required
      - `regions` object, required — List of regions to include or exclude
        - `include` string[], required — List of patterns to include
        - `exclude` string[] — List of patterns to exclude
      - `assetTypes` object, required — List of asset types to include or exclude
        - `include` string[], required — List of patterns to include
        - `exclude` string[] — List of patterns to exclude
      - `specificResources` string[] — List of specific resources
    - `tag` union
      - AnyTagsCriteria
        - `tagEnforcementMode` 'anyTags', required — Mode of tag enforcement
      - RequiredTagsCriteria
        - `tagEnforcementMode` 'requiredTags', required — Mode of tag enforcement
        - `requiredTags` string[], required — List of required tags
      - RequiredValuesCriteria
        - `tagEnforcementMode` 'requiredValues', required — Mode of tag enforcement
        - `requiredValues` object, required — Map of tag keys to required values
  - `isEnabled` boolean, required — Whether the rule is enabled
  - `createdAt` string, date-time — Timestamp when the rule was created
  - `updatedAt` string, date-time — Timestamp when the rule was last updated
  - `notificationId` string — Unique identifier of the associated notification configuration
  - `severity` 0 | 1 | 2 | 3 | 4, required — Severity level of the guardrail rule
  - `enforceOnNoOp` boolean — Whether to enforce the rule on no-op assets

## Response `200`

Guardrail Rule Created Successfully

- CreateGuardrailResponse
  - `ruleId` string, required — Unique identifier of the created rule
  - `notificationId` string, required — Unique identifier of the created notification

## Other responses

- `400` — Bad Request Error
- `401` — Unauthorized Error
- `403` — Insufficient permissions
- `404` — Not Found Error
- `500` — Internal Server Error

---

[API](https://skmtc.net/firefly/apis/api-gateway.md) · [All operations](https://skmtc.net/firefly/apis/api-gateway/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/firefly/api-gateway/revisions/eea119b4113f/schema)
