Zum Inhalt springen
API-Referenz
API-Referenz

Eine Guardrail-Zuweisung erstellen

Einen Guardrail einem Standard-API-Schlüssel oder einem Kontomitglied zuweisen.

Einen Guardrail einem Standard-API-Schlüssel oder einem Kontomitglied zuweisen.

Endpunkt

POST /api/v1/guardrail_assignments
Basis-URL
https://runapi.ai
API-Version
v1
Authentifizierung
Authorization: Bearer YOUR_MANAGEMENT_API_KEY
Autorisierung
Kontoadministratoren können jedes geeignete Ziel zuweisen. Nicht-Administrator-Benutzer können nur ihre eigenen Standard-API-Schlüssel zuweisen.
02

Anfrage

JSON-Body

Werte nur am angegebenen Anfrage-Speicherort senden.

JSON-Body3 Felder
account_user_idstring
Optional

Präfix-ID des Kontomitglieds. Dieses Ziel erfordert einen Kontoadministrator.

api_token_idstring
Optional

Standard-API-Schlüssel-Präfix-ID. Geben Sie genau eine Ziel-ID an.

guardrail_idstring
Erforderlich

Guardrail-Präfix-ID.

03

Erfolgsantwort

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

Fehlerantwort (401)

HTTP 401
Antwort-Schema
JSON
{
  "properties": {
    "error": {
      "description": "Für Menschen lesbare Fehlermeldung.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Antwortbeispiel

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

Fehlerantwort (403)

HTTP 403
Antwort-Schema
JSON
{
  "properties": {
    "error": {
      "description": "Für Menschen lesbare Fehlermeldung.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Antwortbeispiel

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

Fehlerantwort (400)

HTTP 400
Antwort-Schema
JSON
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Für Menschen lesbare Fehlermeldung.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Menschenlesbare Validierungszusammenfassung.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Validierungsmeldungen nach öffentlichem Anforderungsfeld gegliedert, mit einem Array menschenlesbarer Zeichenketten für jedes Feld.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}

Antwortbeispiel

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

Fehlerantwort (403)

HTTP 403
Antwort-Schema
JSON
{
  "properties": {
    "error": {
      "description": "Für Menschen lesbare Fehlermeldung.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Antwortbeispiel

JSON
{
  "error": "Forbidden"
}
08

Fehlerantwort (404)

HTTP 404
Antwort-Schema
JSON
{
  "properties": {
    "error": {
      "description": "Für Menschen lesbare Fehlermeldung.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Antwortbeispiel

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

Fehlerantwort (422)

HTTP 422
Antwort-Schema
JSON
{
  "properties": {
    "error": {
      "description": "Menschenlesbare Validierungszusammenfassung.",
      "type": "string"
    },
    "errors": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "description": "Validierungsmeldungen nach öffentlichem Anforderungsfeld gegliedert, mit einem Array menschenlesbarer Zeichenketten für jedes Feld.",
      "type": "object"
    }
  },
  "required": [
    "error",
    "errors"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Antwortbeispiel

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

cURL-Beispiel

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"}'