Skip to content
API Reference
API Reference

Create a guardrail assignment

Attach one guardrail to a Standard API key or an account member.

Attach one guardrail to a Standard API key or an account member.

Endpoint

POST /api/v1/guardrail_assignments
Base URL
https://runapi.ai
API version
v1
Authentication
Authorization: Bearer YOUR_MANAGEMENT_API_KEY
Authorization
Account admins can assign any eligible target. Non-admin users can assign only their own Standard API keys.
02

Request

JSON body

Send values only in the listed request location.

JSON body3 fields
account_user_idstring
Optional

Account-member prefix ID. This target requires an account admin.

api_token_idstring
Optional

Standard API key prefix ID. Provide exactly one target ID.

guardrail_idstring
Required

Guardrail prefix ID.

03

Success response

HTTP 201

POST /api/v1/guardrail_assignments

JSON
{
  "account_user_id": null,
  "api_token_id": "token_123",
  "created_at": "2026-07-27T10:00:00.000Z",
  "guardrail_id": "guardrail_123",
  "id": "guardrail_assignment_123"
}
04

Error response (401)

HTTP 401
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Authentication required"
}
05

Error response (403)

HTTP 403
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Management API key required"
}
06

Error response (400)

HTTP 400
Response schema
JSON
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Human-readable error message.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Human-readable validation summary.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}

Response example

JSON
{
  "error": "page must be an integer"
}
07

Error response (403)

HTTP 403
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Forbidden"
}
08

Error response (404)

HTTP 404
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Resource not found"
}
09

Error response (422)

HTTP 422
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable validation summary.",
      "type": "string"
    },
    "errors": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
      "type": "object"
    }
  },
  "required": [
    "error",
    "errors"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Validation failed",
  "errors": {
    "base": [
      "Validation failed"
    ]
  }
}
10

cURL example

CURL
curl -X POST https://runapi.ai/api/v1/guardrail_assignments \
  -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"guardrail_id":"guardrail_123","api_token_id":"token_123"}'