Api clients / JavaScript / V3 / Methods

Delete Objects | JavaScript API Client V3 (Deprecated)

Deprecated content
This documentation is for a deprecated version of JavaScript API client. Some features and settings may be missing or their usage may have changed. Refer to the documentation for the latest version of JavaScript API client for up-to-date information.
Required API Key: any key with the deleteObject ACL
Method signature
index.deleteObjects(array objectIds, callback)

index.deleteObject(string objectID, callback) // delete a single object

About this method

Remove objects from an index using their object ids.

This method enables you to remove one or more objects from an index.

There are 2 methods available to delete objects:

  • this one, which uses an objectID to identify objects
  • and delete by, which uses filters to identify objects

Note: This method also has a singular version.

Examples

Delete multiple objects using their objectIDs

1
$index->deleteObjects(["myID1", "myID2"]);

Delete a single object

1
$index->deleteObject('myID');

Delete multiple objects and send extra HTTP headers

1
2
3
4
5
$objectIDs = [/* objectIDs */];

$index->deleteObjects($objectIDs, [
  'X-Forwarded-For' => '94.228.178.246'
]);

Parameters

objectIDs
type: list
Required

List of objectIDs to delete.

requestOptions
type: key value mapping
default: No request options
Optional

A mapping of [`requestOptions`](/doc/api-client/getting-started/request-options/) to send along with the query.

objectID
type: integer|string
Required

The objectID of the object to delete.

Response

In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.

JSON format

1
2
3
4
5
6
7
{
  "objectIDs": [
    "myObjectID1",
    "myObjectID2"
  ],
  "taskID": 678,
}
objectIDs
list

List of the objectIDS of the deleted objects.

taskID
integer

The taskID used with the waitTask method.

Did you find this page helpful?