By default we recommend to use the Search Only API Key from the client to avoid any security issues. Those keys don’t have the rights to delete an object from an index. You have to provide (or create) a specific API key that will have the rights to do it. You can find more information about API Keys and how to generate them inside the documentation. Keep in mind that by exposing a key like this one to the client, a malicious user can erase the full content of the index.
Once you have the proper API Key you can use the
refresh method. Here is an example.
Note that every indexing operations inside Algolia are asynchronous. You may want to be sure that the record is correctly removed before calling the
refresh method. To wait until the delete operation complete you can use the
waitTask method on the client.
Hope that helps, let me know if you have questions.