Update user-defined filter

Updates a specified user-defined filter.

Required Permissions

Requires the ADMIN role or higher.

HTTP Request

PUT /api/sonar/user-defined-filters
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
     -d guid=a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
     -d name="Internal IP filter" \
     -d description="Updated internal network IP address filter" \
     -d 'predicate={"type": "and", "args": [{"type": "expr", "value": "src_ip == \"192.0.2.10\""}]}' \
     -X PUT \
     https://HOSTNAME/api/sonar/user-defined-filters
Request Parameters
KeyRequiredTypeDescriptionNote
guidYesStringUser-defined filter GUID36 characters
nameYesStringUser-defined filter name
descriptionNoStringUser-defined filter description
predicateYesString key/value mapFilter predicate conditionExpression tree object

The predicate is a recursive expression tree. Each node contains the following keys:

  • type (String, required): Node type. One of and, or, eq, neq, in, is_null, is_not_null, gt, gte, lt, lte, starts_with, ends_with, contains, value, expr
  • args (Array): List of child conditions for logical operators such as and and or. Each item follows the same expression tree structure.
  • value (String): Comparison value used by value and expr types
  • comment (String, optional): Condition description

Success Response

{}

Error Responses

Required argument is missing

HTTP status code 400

{
  "error_code": "null-argument",
  "error_msg": "name should be not null"
}
type is missing in the condition expression

HTTP status code 400

{
  "error_code": "invalid-argument",
  "error_msg": "type should be not null."
}
Filter name is in GUID format

HTTP status code 400

{
  "error_code": "invalid-argument",
  "error_msg": "user-defined filter name cannot be guid format"
}
Filter is not found

HTTP status code 500

{
  "error_code": "illegal-state",
  "error_msg": "user-defined filter not found: a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
No permission

HTTP status code 500

{
  "error_code": "illegal-state",
  "error_msg": "no-permission"
}