Vai al contenuto
Riferimento API
Riferimento API

Creare un'assegnazione di guardrail

Collega una guardrail a una chiave API Standard o a un membro dell'account.

Collega una guardrail a una chiave API Standard o a un membro dell’account.

Endpoint

POST /api/v1/guardrail_assignments
URL di base
https://runapi.ai
Versione API
v1
Autenticazione
Authorization: Bearer YOUR_MANAGEMENT_API_KEY
Autorizzazione
Gli amministratori dell'account possono assegnare qualsiasi target idoneo. Gli utenti non amministratori possono assegnare solo le proprie chiavi API Standard.
02

Richiesta

Corpo JSON

Invia i valori solo nella posizione di richiesta elencata.

Corpo JSON3 campi
account_user_idstring
Opzionale

ID prefisso del membro dell'account. Questo target richiede un amministratore dell'account.

api_token_idstring
Opzionale

ID prefisso della Chiave API Standard. Fornisci esattamente un ID target.

guardrail_idstring
Obbligatorio

ID prefisso del Guardrail.

03

Risposta di successo

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

Risposta di errore (401)

HTTP 401
Schema della risposta
JSON
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Esempio di risposta

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

Risposta di errore (403)

HTTP 403
Schema della risposta
JSON
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Esempio di risposta

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

Risposta di errore (400)

HTTP 400
Schema della risposta
JSON
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Messaggio di errore leggibile.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Riepilogo di convalida leggibile dall'utente.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Messaggi di convalida con chiave per campo della richiesta pubblica, con un array di stringhe leggibili dall'utente per ogni campo.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}

Esempio di risposta

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

Risposta di errore (403)

HTTP 403
Schema della risposta
JSON
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Esempio di risposta

JSON
{
  "error": "Forbidden"
}
08

Risposta di errore (404)

HTTP 404
Schema della risposta
JSON
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Esempio di risposta

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

Risposta di errore (422)

HTTP 422
Schema della risposta
JSON
{
  "properties": {
    "error": {
      "description": "Riepilogo di convalida leggibile dall'utente.",
      "type": "string"
    },
    "errors": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "description": "Messaggi di convalida con chiave per campo della richiesta pubblica, con un array di stringhe leggibili dall'utente per ogni campo.",
      "type": "object"
    }
  },
  "required": [
    "error",
    "errors"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Esempio di risposta

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

Esempio cURL

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