---
title: Create a guardrail
url: https://runapi.ai/docs/api/management/guardrails/create.md
canonical: https://runapi.ai/docs/api/management/guardrails/create
locale: en
---

# Create a guardrail

Create a reusable model, provider, and budget policy.

## Endpoint

POST /api/v1/guardrails

Base URL: https://runapi.ai

API version: v1

Authentication: Authorization: Bearer YOUR_MANAGEMENT_API_KEY


Authorization: Requires an account-admin Management API key.

## Request

Send values only in the listed request location.

### JSON body

```json
{
  "allowed_models": {
    "description": "Model allowlist.",
    "required": false,
    "type": "array | null"
  },
  "allowed_providers": {
    "description": "Provider-name allowlist.",
    "required": false,
    "type": "array | null"
  },
  "blocked_models": {
    "description": "Model blocklist, which takes precedence over the allowlist.",
    "required": false,
    "type": "array | null"
  },
  "blocked_providers": {
    "description": "Provider-name blocklist.",
    "required": false,
    "type": "array | null"
  },
  "credit_limit_cents": {
    "description": "Total spending cap in USD cents.",
    "required": false,
    "type": "integer | null"
  },
  "credit_limit_reset_interval": {
    "description": "Reset cadence for the total spending cap.",
    "enum": [
      "daily",
      "weekly",
      "monthly"
    ],
    "required": false,
    "type": "string | null"
  },
  "description": {
    "description": "Optional free-form description.",
    "required": false,
    "type": "string"
  },
  "enabled": {
    "default": true,
    "description": "Whether the guardrail is enforced.",
    "required": false,
    "type": "boolean"
  },
  "model_budgets": {
    "description": "Per-model budget rules.",
    "required": false,
    "type": "array | null"
  },
  "name": {
    "description": "Guardrail name unique within the account.",
    "required": true,
    "type": "string"
  }
}
```

## Success response

HTTP 201 - POST /api/v1/guardrails

```json
{
  "allowed_models": [
    "gpt-5.4"
  ],
  "allowed_providers": [],
  "assignment_count": 1,
  "blocked_models": [],
  "blocked_providers": [],
  "created_at": "2026-07-27T10:00:00.000Z",
  "credit_limit_cents": 50000,
  "credit_limit_reset_interval": "monthly",
  "description": "Production policy",
  "enabled": true,
  "id": "guardrail_123",
  "model_budgets": [
    {
      "credit_limit_cents": 10000,
      "credit_limit_reset_interval": "monthly",
      "match_mode": "include",
      "models": [
        "gpt-5.4"
      ]
    }
  ],
  "name": "Production budget"
}
```

## Error response (401)

HTTP 401

```json
{
  "error": "Authentication required"
}
```

## Error response (403)

HTTP 403

```json
{
  "error": "Management API key required"
}
```

## Error response (403)

HTTP 403

```json
{
  "error": "Account admin required"
}
```

## Error response (400)

HTTP 400

```json
{
  "error": "page must be an integer"
}
```

## Error response (422)

HTTP 422

```json
{
  "errors": {
    "base": [
      "Validation failed"
    ]
  }
}
```

## cURL example



### curl

```curl
curl -X POST https://runapi.ai/api/v1/guardrails \
  -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Production budget","description":"Production policy","enabled":true,"credit_limit_cents":50000,"credit_limit_reset_interval":"monthly","allowed_models":["gpt-5.4"],"model_budgets":[{"match_mode":"include","models":["gpt-5.4"],"credit_limit_cents":10000,"credit_limit_reset_interval":"monthly"}]}'
```

## Related reference

- [Guardrails](/docs/api/management/guardrails)
- [Guardrail object](/docs/api/management/guardrails/object)
