Ana içeriğe geç

Create AI Prompt-Guard Preset

Endpoint

POST /apiops/settings/ai-prompt-guard-presets/{presetName}/

Authentication

Requires a Personal API Access Token with admin privileges.

Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer {token}Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
presetNamestringYesName of the prompt-guard preset. Must match the name in the body (case-insensitive); if name is omitted from the body it defaults to this value.

Query Parameters

ParameterTypeRequiredDefaultDescription
projectIdstringNoadminScope project id. Omit for the admin/global scope.

Request Body

Full JSON Body Example

{
"name": "block-internal-hostnames",
"ruleValue": "(?i)internal\\.corp\\.local",
"action": "FLAG",
"category": "system-leak",
"description": "Flags mentions of internal hostnames",
"enabled": true
}

Request Body Fields

FieldTypeRequiredDefaultDescription
namestringNopath valuePreset name. Must equal presetName (case-insensitive); defaults to the path value when omitted.
ruleValuestringYes-Java regex pattern matched against prompt content
actionstringYes-Action applied on match: BLOCK, FLAG, MASK
categorystringNo-Optional category label (e.g. jailbreak, injection, system-leak)
descriptionstringNo-Optional description for display
enabledbooleanNo-Whether the preset is active

Notes

  • The request body must not be empty
  • name in the body must match presetName in the path (case-insensitive)
  • builtIn is server-controlled and ignored on write — you cannot create a built-in preset via the API
  • id is server-controlled and ignored on write

Response

Success Response (200 OK)

{
"status": "SUCCESS",
"deploymentResult": {
"success": true
}
}

Response Fields

FieldTypeDescription
statusstringResponse status: SUCCESS or FAILURE
deploymentResultobjectDeployment result summary
deploymentResult.successbooleantrue when the preset was saved successfully

Error Response (400 Bad Request)

Returned on validation failure, name mismatch, an attempt to overwrite a built-in preset, or when the caller lacks the ADMIN role.

{
"status": "FAILURE",
"resultMessage": "AI prompt-guard preset name in path (block-internal-hostnames) does not match name in body (other-name)!"
}

Other possible messages:

{
"status": "FAILURE",
"resultMessage": "AI prompt-guard preset body can not be empty!"
}
{
"status": "FAILURE",
"resultMessage": "Built-in presets are read-only"
}

Error Response (401 Unauthorized)

{
"status": "FAILURE",
"resultMessage": "Token is not valid!"
}

cURL Example

curl -X POST \
"https://demo.apinizer.com/apiops/settings/ai-prompt-guard-presets/block-internal-hostnames/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "block-internal-hostnames",
"ruleValue": "(?i)internal\\.corp\\.local",
"action": "FLAG",
"category": "system-leak",
"description": "Flags mentions of internal hostnames",
"enabled": true
}'

Notes and Warnings

  • Admin Only:
    • Only sysAdmin users (or users with the ADMIN role) can create AI prompt-guard presets
    • A project-scoped AI_DEVELOPMENT token is not sufficient
  • Upsert by Name:
    • If a preset with the same name already exists in the scope, this call updates it
    • Otherwise a new custom preset is created
  • Built-in Presets Are Read-only:
    • You cannot create or overwrite a built-in (seeded) preset; such attempts are rejected
  • Regex Pattern:
    • ruleValue is a Java regex; remember to escape backslashes in JSON (e.g. \\. for a literal dot)
  • No Secret Fields:
    • Prompt-guard presets carry no secret (@SecretData) fields, so no values are masked