AI Gateway Policies

Create an AI Gateway Policy

Changed on

Registers a new policy for the AI Gateway.

post/v1/ai-gateways/{gatewayId}/policies

Request

  • Base URL: https://global.api.konghq.com
  • URL: https://global.api.konghq.com/v1/ai-gateways/{gatewayId}/policies
  • Auth: one of:
    • HTTP bearer
    • HTTP bearer
    • HTTP bearer
    • HTTP bearer

Request body

display_namestring required

The display name for this policy instance.

namestring required

Identifier for an AI Gateway entity. In some cases, this may be the entity name or ID.

typestring required

The type of the Policy. This is equivalent to the Kong 3 plugin name. Some examples are: 'ai-sanitizer', 'ai-prompt-guard', and 'rate-limiting'. Note: Plugins have been renamed to Policies in Kong AI Gateway. Policy types and configuration documentation can be found in the Developer Docs.

enabledboolean

Whether the policy is enabled.

globalboolean

Whether the policy is globally applied to all resources.

configobject required

Configuration for the policy. This is equivalent to the Kong 3 plugin configuration. Note: Plugins have been renamed to Policies in Kong AI Gateway. Policy types and configuration documentation can be found in the Developer Docs.

conditionstring nullable

An expression used for conditional control over plugin execution. If the expression evaluates to true during the request flow, the plugin is executed; otherwise, it is skipped.

Requires a minimum runtime version of 2.1.

labelsPublicLabels

Public labels store information about an entity that can be used for filtering a list of objects.

Public labels are intended to store PUBLIC metadata.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

managed_byManagedBy

Stores information about what manages this entity, such as the tool or system responsible for its lifecycle (for example, terraform).

Keys must be 1–63 characters long and start with an alphanumeric character.

Example request

{
  "display_name": "My Cool AI PII Sanitizer Policy",
  "name": "my-entity-name",
  "type": "ai-sanitizer",
  "enabled": true,
  "config": {
    "anonymize": [
      "phone",
      "creditcard"
    ],
    "stop_on_error": true
  },
  "labels": {
    "category": "finance"
  },
  "managed_by": {
    "owner": "terraform"
  }
}

Response

Policy created successfully.

display_namestring required

The display name for this policy instance.

namestring required

Identifier for an AI Gateway entity. In some cases, this may be the entity name or ID.

typestring required

The type of the Policy. This is equivalent to the Kong 3 plugin name. Some examples are: 'ai-sanitizer', 'ai-prompt-guard', and 'rate-limiting'. Note: Plugins have been renamed to Policies in Kong AI Gateway. Policy types and configuration documentation can be found in the Developer Docs.

enabledboolean

Whether the policy is enabled.

globalboolean

Whether the policy is globally applied to all resources.

configobject required

Configuration for the policy. This is equivalent to the Kong 3 plugin configuration. Note: Plugins have been renamed to Policies in Kong AI Gateway. Policy types and configuration documentation can be found in the Developer Docs.

conditionstring nullable

An expression used for conditional control over plugin execution. If the expression evaluates to true during the request flow, the plugin is executed; otherwise, it is skipped.

Requires a minimum runtime version of 2.1.

labelsPublicLabels

Public labels store information about an entity that can be used for filtering a list of objects.

Public labels are intended to store PUBLIC metadata.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

managed_byManagedBy

Stores information about what manages this entity, such as the tool or system responsible for its lifecycle (for example, terraform).

Keys must be 1–63 characters long and start with an alphanumeric character.

idstring uuid required

Contains a unique identifier used for this resource.

created_atstring date-time required

An ISO-8601 timestamp representation of entity creation date.

updated_atstring date-time required

An ISO-8601 timestamp representation of entity update date.

Example response

{
  "display_name": "My Cool AI PII Sanitizer Policy",
  "name": "my-entity-name",
  "type": "ai-sanitizer",
  "enabled": true,
  "config": {
    "anonymize": [
      "phone",
      "creditcard"
    ],
    "stop_on_error": true
  },
  "labels": {
    "category": "finance"
  },
  "managed_by": {
    "owner": "terraform"
  },
  "id": "5f9fd312-a987-4628-b4c5-bb4f4fddd5f7",
  "created_at": "2022-11-04T20:10:06.927Z",
  "updated_at": "2022-11-04T20:10:06.927Z"
}

Changes

    • breaking

      added to the / response property oneOf list for the response status

    • warning

      added the new key_invalid enum value to the ////// response property for the response status

    • warning

      added the new unique enum value to the ////// response property for the response status

    • warning

      added the new 400.00 enum value to the response property for the response status

    • warning

      added the new 403.00 enum value to the response property for the response status

    • warning

      added the new 404.00 enum value to the response property for the response status

    • warning

      added the new 409.00 enum value to the response property for the response status