Create AI Privacy Preset
Endpoint
POST /apiops/settings/ai-privacy-presets/{presetName}/
Authentication
Requires a Personal API Access Token with admin privileges.
Header
Authorization: Bearer YOUR_TOKEN
Request
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
| Content-Type | application/json | Yes |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| presetName | string | Yes | Name of the privacy preset. Must match the name in the body (case-insensitive); if name is omitted from the body it defaults to this value. |
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| projectId | string | No | admin | Scope project id. Omit for the admin/global scope. |
Request Body
Full JSON Body Example
{
"name": "internal-account-id",
"patternType": "REGEX",
"regexPattern": "ACC-[0-9]{8}",
"operation": "MASK",
"enabled": true
}
Full JSON Body Example - Partial Mask
{
"name": "customer-phone",
"patternType": "REGEX",
"regexPattern": "(?<!\\d)0\\d{10}(?!\\d)",
"operation": "MASK",
"maskMode": "KEEP_LAST",
"maskPattern": "*",
"maskVisibleCharCount": 4,
"enabled": true
}
Masks 05321234567 as *******4567.
Request Body Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | No | path value | Preset name. Must equal presetName (case-insensitive); defaults to the path value when omitted. |
| patternType | string | Yes | - | Match pattern type: ELEMENT_NAME or REGEX. BUILTIN is rejected — see Notes. |
| regexPattern | string | Conditional | - | Custom regex pattern (Java java.util.regex syntax). Required when patternType = REGEX. |
| elementName | string | No | - | Header/param/body field name to match when patternType = ELEMENT_NAME |
| operation | string | Yes | - | Action applied on match: MASK, DELETE, ENCRYPT, HASH, DETECT |
| maskMode | string | No | FIXED | Mask shape when operation = MASK: FIXED, KEEP_FIRST, KEEP_LAST, MASK_FIRST |
| maskPattern | string | No | *** | With FIXED, the full replacement text. With the partial shapes, its first character is used as the mask character (default *). |
| maskVisibleCharCount | integer | No | 4 | Number of characters kept (or masked, with MASK_FIRST) in the partial shapes |
| enabled | boolean | No | - | Whether the preset is active |
Notes
- The request body must not be empty
namein the body must matchpresetNamein the path (case-insensitive)builtInis server-controlled and ignored on write — you cannot create a built-in preset via the APIpatternType=BUILTINis no longer accepted in this catalog and returns400with error keypatterntypebuiltinunsupported. ExistingBUILTINpresets were converted toREGEXon upgrade, with the equivalent built-in pattern written intoregexPattern, so every rule is expressed by a visible, editable pattern. Note the behavioural difference: the oldBUILTINpath also ran a semantic check after the regex matched (national-ID checksum, IBAN mod-97, card Luhn); theREGEXpath does not, so the deliberately broad patterns may produce more false positives — narrow the pattern if that matters.- An invalid
regexPatternis rejected at write time with error keyregexpatterninvalid. A pattern that compiles but fails the runtime ReDoS guard is accepted here yet skipped at request time — validate it with the PII Patterns test panel in the UI before relying on it. idis server-controlled and ignored on write
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"deploymentResult": {
"success": true
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
| status | string | Response status: SUCCESS or FAILURE |
| deploymentResult | object | Deployment result summary |
| deploymentResult.success | boolean | true 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 privacy preset name in path (internal-account-id) does not match name in body (other-name)!"
}
Other possible messages:
{
"status": "FAILURE",
"resultMessage": "AI privacy 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-privacy-presets/internal-account-id/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "internal-account-id",
"patternType": "REGEX",
"regexPattern": "ACC-[0-9]{8}",
"operation": "MASK",
"enabled": true
}'
Notes and Warnings
- Admin Only:
- Only sysAdmin users (or users with the
ADMINrole) can create AI privacy presets - A project-scoped
AI_DEVELOPMENTtoken is not sufficient
- Only sysAdmin users (or users with the
- 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
- Name Consistency:
- The
namein the body must matchpresetNamein the path (case-insensitive)
- The
- No Secret Fields:
- Privacy presets carry no secret (
@SecretData) fields, so no values are masked
- Privacy presets carry no secret (
Related Documentation
- Update AI Privacy Preset - Update an existing preset
- Delete AI Privacy Preset - Delete a preset
- AI Privacy Presets API - Resource overview