Delete saved object of type url via Kibana 7 API

Ahead of upgrading Kibana from 7 (yes I know) to 8, I'm looking at ~1500 short URLs which it has been decided are no longer needed. (N.B. Some short URLs are still wanted.) Deleting them using the Kibana GUI would be exceeding tedious, especially when it's apparently impossible to search for the objects Search url Saved Objects by Title - #4 by Tortoise . Having worked out how to extract the relevant from exported JSON, I've been looking at the Kibana API as described at

There is no mention of saved object of type url there. But the wording of

(Required, string) Valid options include visualization, dashboard, search, index-pattern, config.

is such as to imply that the types given are just same of the ones which are valid (“includes”, not “are”, though why not state all valid values for clarity) and exported JSON of the URLs says type is url. E.g.

  "id": "f3546b40-480f-11ef-9f7b-67a2b5099a35",
  "references": [],
  "sort": [
    1721641881588,
    0
  ],
  "type": "url",

So based on that I think the way to delete one should be

[kibana:production:~]$ curl -u foo -H "kbn-xsrf: true" -X DELETE "https://$(hostname):5601/api/saved_objects/url/f3546b40-480f-11ef-9f7b-67a2b5099a35";echo
Enter host password for user 'foo':
{"statusCode":404,"error":"Not Found","message":"Saved object [url/f3546b40-480f-11ef-9f7b-67a2b5099a35] not found"}
[kibana:production:~]$

except as you can see that doesn't work.

So how does one delete a saved object of type url via the Kibana API?

Not sure if it is possible, in the linked documentation you have this:

type
(Required, string) Valid options include visualization, dashboard, search, index-pattern, config.

url is not listed as a valid option for the type parameter.

But, as I said, the wording of the documentation is such that it does not say that the list is complete.

This:

(Required, string) Valid options are visualization, dashboard, search, index-pattern, config.

would imply the list is complete. Maybe that’s what the documentation is intended to mean, but it is not what the documentation says.

Yeah, but the fact that it is not working suggests that the list are complete with the allowed types, have you made a test to create and delete one of the listed types to see if it works:

Only someone from Elastic would be able to confirm that, but considering that this is on a unsupported version and on an deprecated API endpoint in newer versions, not sure anyone will be able to provide this information.

As far as I remeber this endpoint never want GA, it was a preview and then it was decided to deprecated it, so maybe the documentation has the wrong wording, but there is nothing to do here to change it.

I hadn’t, but that’s a great suggestion so I did it and successfully deleted a visualisation via the API. Which proves deleting things via the API in general does work. And while doing that I had a thought, and that led me to the discovery that how to delete a saved object of type url via the API is do it exactly the way I thought it should be done but with the essential element of having the competence to be doing it on the Kibana server that is configured to use the index which contains those saved objects.

We have multiple Kibana servers, each configured to use it’s own index for settings. I exported the url saved objects as JSON from Kibana A, and yesterday I was trying to delete things whilst logged in to a Kibana notA. Which is…

Thank you @leandrojmp for engaging with my question about to do something on an EOL Kibana version (wish we weren’t using it but so it goes) that I only asked because I failed to realise I was logged in to the wrong server.

I see you solved this, but just for the record, I was able with 7.17.29 to find the /goto/.... stuff via:

curl -s 'http://localhost:5601/api/kibana/management/saved_objects/_find?type=url' | jq .

One can also add perPage=N and page=M options.

And then delete a specific id, in this case with id="c4dd24d0-3419-11f1-a5d7-b166d0b839d1" via:

curl -v -s -H "kbn-xsrf: true" -X DELETE 
'http://localhost:5601/api/saved_objects/url/c4dd24d0-3419-11f1-a5d7-b166d0b839d1

which gets a HTTP 200 back, but without a reassuring {"acknowledged" : "true"} or similar.