Restore Batch Rule Version
Rolls back the specified batch rule to a given version snapshot. After identifying the target version through the Get Batch Rule Versions API and Get Batch Rule Version API, call this API. On success, the configuration at that point is applied to the current rule and a new version is created automatically. If validation fails (for example, when referenced objects such as schemas, ticket repositories, or loggers are missing, or the name conflicts with another rule), the rule is left unchanged and the failure reasons are returned in the failures array.
Required Permissions
Requires the ADMIN role or higher.
HTTP Request
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
-X POST \
https://HOSTNAME/api/sonar/batch-rules/3b05608f-8dd0-4218-9d6d-391515b6280d/versions/2/restore
Request Parameters
Path Parameters
| Key | Type | Description | Note |
|---|---|---|---|
| guid | String | Batch rule GUID | 36 characters |
| version | 32-bit integer | Version number of the snapshot to restore |
Success Response
{
"result": true,
"failures": []
}
- result (Boolean): Whether the restore succeeded.
trueon success. - failures (Array): List of validation failures. Empty array on success.
Validation Failure Response
When the snapshot to restore does not match the current system state (for example, when referenced schemas, ticket repositories, loggers, or alarm groups have been deleted, or when the name conflicts), the API returns HTTP status code 200 but result is false and the failures array contains the failure reasons.
{
"result": false,
"error_msg": "validation-falied",
"failures": [
{
"field": "schema",
"value": "edr-process",
"reason": "not-found"
}
]
}
- result (Boolean):
falsewhen restore fails - error_msg (String): Error identifier. Always
validation-falied(verbatim from the source code). - failures (Array): List of validation failures
- field (String): Name of the field that failed validation. One of
schema,ticket_repo,address_group,rule_category,audit_category,reviewer,auditor,alarm_group,logger,logger_model,ticket_assignee,name. - value (String): Value of the field that failed validation
- reason (String): Failure reason. One of
not-found(referenced object does not exist) orduplicate(name conflicts with another rule).
- field (String): Name of the field that failed validation. One of
Error Responses
Missing parameter
HTTP status code 400
{
"error_code": "null-argument",
"error_msg": "version should be not null"
}
Identifier is not in valid GUID format
HTTP status code 400
{
"error_code": "invalid-param-type",
"error_msg": "guid should be guid type."
}
Batch rule is not found
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "batch rule not found: 3b05608f-8dd0-4218-9d6d-391515b6280d"
}
Snapshot of the specified version is not found
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "batch rule snapshot not found: 3b05608f-8dd0-4218-9d6d-391515b6280d v9"
}
No permission
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "no-permission"
}