Skip to content

POST /delete

For deleting documents, the /delete endpoint accepts a list of document ids under the parameter docs for a particular locale. Note that the document id should be the unique id field as defined in the schema. For every document id in the list, we return a status message indicating success or failure, along with an explanatory message for failures.

Request

HTTP request

POST https://api.904labs.com/sls/{customer_id}/delete?api_key={api_key}

Request attributes

Attribute Type Description
customer_id string (required) Your customer ID

Request parameters

Parameter Type Description
api_key string (required) Your API key

Request body

Property name Value Description
docs list (required) List of document id objects you want to delete from the index. The objects in the list are of the form: {"id": "document_id", "type": "page"}. The type parameter is optional and if omitted defaults to page.
locale string (required) Country and language of the shop/site in ll_TT format, where ll is the language in ISO 639-1 format and TT is the territory in ISO 3166 format (e.g., en_US).

Example request

In the example request below, a customer is deleting two documents with ids document_id_1 and document_id_2.

import requests as r

headers = {"content-type": "application/json"}
URL_INDEX = "https://api.904labs.com/sls/CUSTOMER_ID/delete"
params = {
    "api_key": "APIKEY"
}
payload = {
    "docs": [{"id": "document_id_1", "type": "page"}, {"id": "document_id_2"}]
}

response = r.post(URL_INDEX, json=payload, headers=headers, params=params)

Response

{
    "error_messages": [
        {
            "id": string,
            "processed": boolean,
            "message": string
        }
    ],
    "success_messages": [
        {
            "id": string,
            "processed": boolean,
            "message": string
        }
    ]
}
Property name Value Description
success_messages list A list of dictionaries, each item in the list corresponds to an input document successfully deleted.
error_messages list A list of dictionaries, each item in the list corresponds to an input document that failed.
id string The ID of the document.
processed boolean A flag indicating whether the document was processed (deleted) from the index (true) or not (false).
message string Details of what happened to the document. In case of an error, this property contains the error message.

Example response

The response contains a message for each document in the request, grouped into two lists, success_messages for successes and error_messages for failures, for easier parsing. In the response below, the system indicates that both documents, document_id_1 and document_id_2 have been successfully removed from the search index.

{
    "error_messages": [],
    "success_messages": [
        {
            "id": "document_id_1",
            "processed": true,
            "message": "Document processed"
        },
        {
            "id": "document_id_2",
            "processed": true,
            "message": "Document processed"
        }
    ]
}