Skip to main content

Delete Data

Delete data endpoint allows you to delete the historical data in your collection. You can delete all the data for a specific type of data, or you can delete only data in a time range.

The procedure to delete the data of a type for a collection is as follows:

  1. send a DEL request to the delete data endpoint with the type of data and the dates range you want to delete;
  2. retrieve the request id from the response;
  3. poll the platform periodically to check the status of the delete request to ensure that the data deletion is successful.

1. Send a DEL request

To delete data, you need to send a DEL request to the delete data endpoint:

/api/collection/{collectionId}/data/{dataType}/delete

This endpoint requires the following parameters:

  • collectionId: the identifier of the collection containing the data you want to delete;
  • dataType: the type of data you want to delete. Available values are: sales_orders, purchase_orders.

In the request body, you can specify the following args as a JSON object:

  • from_date, the start date of the range of data to delete (format: yyyy-mm-ddThh:MM:ss+hh:MM, timezone optional);
  • to_date, the end date of the range of data to delete (format: yyyy-mm-ddThh:MM:ss+hh:MM, timezone optional).

from_date and to_date are optional parameters. If not specified, all the data of the specified type will be deleted. If only from_date is specified, all the data from that date onwards will be deleted. If only to_date is specified, all the data up to that date will be deleted.

The request must also include an header with the authorization token.

An example of the request to delete sales orders data to the collection my-collection-id is shown below.

curl --location'https://nostradamus.u-hopper.com/api/collection/{my-collection-id}/data/sales_orders/delete' \
--header 'Authorization: Token my-secret-token' \
--header 'Content-Type: application/json' \
--data '{
"args": {
"from_date": "2024-01-01T00:00"
}
}'

2. Retrieve the request id

If the delete request is successful (status code 202), the response will follow the UploadRequest schema defined in the OpenApi documentation. The id field in the response will contain the identifier of the delete request you just sent, and the status field will be set to queued. You will need the identifier to check the status of the delete request.

If the request is unsuccessful, the response will contain the error message.

An example of the response is shown below:

{
"id": "my-delete-request-id",
"collectionId": "my-collection-id",
"dataType": "sales_orders",
"args": {
"from_date": "2024-01-01T00:00"
},
"status": "queued",
"message": null,
"deletionErrors": null
}

3. Poll the platform to check the status of the delete request

To retrieve the status of a delete request, you can send a GET request to the following endpoint, replacing my-upload-request-id with the id of the delete request:

/api/collection/{collectionId}/data/{dataType}/delete/{my-upload-request-id}

Here is an example of how to check the status of the delete request with id my-delete-request-id:

curl --location 'https://nostradamus.u-hopper.com/api/collection/{my-collection-id}/data/sales_orders/delete/{my-delete-request-id}' \
--header 'Authorization: Token my-secret-token'

The response (if the request succeeded, i.e. status code 200) will follow the DeleteRequest schema defined in the OpenApi documentation. The status field in the response will indicate the status of the request.

The status can be one of the following values: queued, in_progress, completed, error. In particular:

  • a status queued indicates that the request has been received by the platform and is waiting to be processed;
  • a status in_progress indicates that the request is being processed;
  • a status completed indicates that the deletion process is successfully terminated and your data has been deleted from the collection;
  • a status error indicates that the deletion process terminated with errors; the failure motivation will appear in the field deletionErrors of the response; the existing data in the collection will not be modified.

An example of the response is shown below:

{
"id": "my-delete-request-id",
"collectionId": "my-collection-id",
"dataType": "sales_orders",
"args": {
"from_date": "2024-01-01T00:00"
},
"status": "completed",
"message": null,
"deletionErrors": null
}

You may need to poll the platform periodically to check the status of your delete request. This ensures that you receive timely updates on the progress and outcome of your request.