Deleting an item and optionally, its children in a Push source

Being able to delete a single item in a Push source, possibly along with its children, can especially useful when you’re testing the service or when you need to perform a very small content update.

This article provides an overview of the DELETE /sources/{sourceId}/documents HTTP request.

Sequence diagram for DELETE documents request
Sequence diagram illustrating the handling of a DELETE /sources/{sourceId}/documents Push API request (highlighted) as it progresses through the Coveo indexing pipeline.
Important

You should never use this operation repetitively to delete many items in a Push source (that is, to perform a large scale content update). When this is what you need to do, depending on what you want to achieve, you should either use:

Request template

Request definition

DELETE https://api.cloud.coveo.com/push/v1/organizations/<MyOrganizationId>/sources/<MySourceId>/documents?deleteChildren=<true|false>&documentId=<MyItemURI> HTTP/1.1

Authorization: Bearer <MyAccessToken>

In the request path:

In the query string:

  • Set deleteChildren to true if you want to recursively delete all items matching the <MyItemURI> + /. Set it to false otherwise.

    Important

    This means that the following request:

    DELETE https://api.cloud.coveo.com/push/v1/organizations/mycoveocloudv2organizationg8tp8wu3/sources/mycoveocloudv2organizationg8tp8wu3-rp5rxzbdz753uhndklv2ztkfgy/documents?deleteChildren=true&documentId=file%3A%2F%2Ffolder HTTP/1.1
    
    Authorization: Bearer **********-****-****-****-************

    will recursively delete all items whose documentId matches file://folder/* from the target Push source (for example, file://folder/file1.txt, file://folder/subfolder/file2.txt, etc.).

  • Replace <MyItemURI> with the URL-encoded URI of the item to delete in the target Push source (for example, file%3A%2F%2Ffolder%2FdummyItem.html).

In the Authorization HTTP header:

A successful response (202 Accepted) indicates that the delete operation was successfully forwarded to the service and is now enqueued to be processed in the Coveo indexing pipeline.

Note

This doesn’t imply that the item was successfully deleted in the target Push source (see About the Push API processing delay).

Tip
Leading practice: Update the status of your Push source

If you set your Push source to an active status before, you should consider setting it back to the IDLE status once this operation has successfully returned, assuming you have no more operations to perform as part of this content update (see Updating the status of a Push source).

Sample request

The following example shows how to delete an item and its children.

Request definition

DELETE https://api.cloud.coveo.com/push/v1/organizations/mycoveocloudv2organizationg8tp8wu3/sources/mycoveocloudv2organizationg8tp8wu3-rp5rxzbdz753uhndklv2ztkfgy/documents?deleteChildren=true&documentId=file%3A%2F%2Ffolder%2F HTTP/1.1

Authorization: Bearer **********-****-****-****-************

Successful response - 202 Accepted

null