Guardrail Policies

Update a moderation policy

Changed on

Replace a moderation policy's name and config, and optionally its assignments. Management key required.

put/guardrails/policies/moderation/{id}

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Path parameters

id, string uuid required

Policy ID

Example:550e8400-e29b-41d4-a716-446655440000

Request body

UpdateModerationGuardrailPolicyRequest required
api_key_hashes, string[]

Complete new list of assigned API keys. Send together with member_ids, or omit both to keep the stored assignments.

config, GuardrailModerationPolicyConfig required
is_workspace_default, boolean

Omit to keep the stored default status; false unsets the policy as the workspace default.

member_ids, string[]

Complete new list of assigned members. Send together with api_key_hashes, or omit both to keep the stored assignments.

name, string required

Policy name

opted_out_api_key_hashes, string[]

API key hashes

opted_out_member_ids, string[]

Organization member user IDs

workspace_id, string uuid

Workspace the policy belongs to. Required for an organization management key; a workspace-scoped key defaults to its own workspace and gets 403 for any other.

Example request

{
  "api_key_hashes": [
    "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
  ],
  "config": {
    "content_filter_builtins": [
      {
        "action": "block",
        "slug": "secrets"
      }
    ]
  },
  "member_ids": [
    "user_2abcDEFghiJKLmnoPQRstu"
  ],
  "name": "Engineering monthly budget",
  "opted_out_api_key_hashes": [
    "c56454edb818d6b14bc0d61c46025f1450b0f4012d12304ab40aacb519fcbc93"
  ],
  "opted_out_member_ids": [
    "user_2abcDEFghiJKLmnoPQRstu"
  ],
  "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
}

Response

moderation policy updated

ModerationGuardrailPolicyResponse required
data, ModerationGuardrailPolicy required

Example response

{
  "data": {
    "config": {
      "content_filter_builtins": [
        {
          "action": "block",
          "slug": "secrets"
        }
      ]
    },
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Engineering monthly budget"
  }
}

Changes