Remove Scheduled Queries

Deletes specified scheduled queries. Administrator privileges are required to call this API. This REST API supports partial failure. If any scheduled queries fail to be deleted, the failures parameter returns the identifiers of those scheduled queries and the failure reason.

HTTP Request

DELETE /api/sonar/scheduled-queries

Request using cURL

curl -H "Authorization: Bearer <API_KEY>" \
     -d guids="GUID1,GUID2,GUIDN"
     -d policy="skip"
     -X DELETE https://HOSTNAME/api/sonar/scheduled-queries

Request Parameters

KeyRequiredTypeDescriptionNote
guidsOStringGUID list of scheduled queriesComma-separated list
policyXStringDelete optionEither skip or force. (Default: skip)
  • skip: does not delete the scheduled query if it is running.
  • force: stop and delete the scheduled query, even if it is running.

Success Responses

Successful Request
{
     "succeeded": 1,
     "failures": []
}
  • (32-bit integer) succeeded: Total number of scheduled queries that have been successfully deleted. Any scheduled queries whose policy is skip are not included.
  • (Array) failures: Failure details
    • (String) id: GUID of the scheduled query
    • (String) reason: Error description
Partial Successful Request

Request Example

curl -k -H "Authorization: Bearer API_KEY" \
     -d guids="0ff16aa8-dbc1-458a-9769-342de5cf9219,65c6c0d3-b8a4-49b3-b4ea-ddd0e321c221,b7007eb2-c1df-4d4d-84f1-5d0af91db25d" \
     -X DELETE https://HOSTNAME/api/sonar/scheduled-query

Response Example

{
     "succeed": 1,
     "failures": [
          {
               "id": "0ff16aa8-dbc1-458a-9769-342de5cf9219",
               "reason": "scheduled-query-not-found"
          }
     ]
}

Error Responses

Required argument is missing

HTTP status code 400

{
     "error_code": "null-argument",
     "error_msg": "guids should be not null"
}
Identifier is not in valid GUID format

HTTP status code 400

{
     "error_code": "invalid-param-type",
     "error_msg": "guids should be guid type."
}
Scheduled query is not found

HTTP status code 200

{
     "succeed": 0,
     "failures": [
          {
               "id": "0fb16ff8-dbc1-458a-9769-342de5cf9219",
               "reason": "scheduled-query-not-found"
          }
     ]
}
No administrator privileges

HTTP status code 500

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