Yes. You use the REST “DELETE” method against desired submission endpoint
AFAIK there is no exposed REST API to delete a one or more submissions based on a specific criteria, eg date.
Instead, what you have to do is identify the unique REST endpoint corresponding to the specific submission instance under its associated form instance. Typically, the process would be to enumerate your forms (if you didnt already know the form id), eg
HOST=https://kf.kobotoolbox.org
curl -v --header 'Accept: application/json' --user tiritea:$PASSWORD $HOST/assets/
which will give you a long list of all your forms. From this you need to identify the form associated with the submission you wish to delete (FYI this is the same the id used when you save your form), eg
...
"url": "https://kf.kobotoolbox.org/assets/aKydtLQwpyH4XdFfmB2xTB/"
...
where the form id in my case is “aKydtLQwpyH4XdFfmB2xTB”. Then you can list all the submissions for this form using another REST call:
ID=aKydtLQwpyH4XdFfmB2xTB
curl -v --header 'Accept: application/json' --user tiritea:$PASSWORD $HOST/assets/$ID/submissions/
which will give you a (long?) list of all the submissions back, of the form
{
"_notes": [
],
"this_is_a_test": "hello world",
"meta/instanceID": "uuid:61059adb-c644-4f73-8303-3c56950df9b2",
"end": "2019-08-02T12:59:33.923+12:00",
"_submission_time": "2019-08-02T00:59:34",
"_validation_status": {
},
"_uuid": "61059adb-c644-4f73-8303-3c56950df9b2",
"_bamboo_dataset_id": "",
"_tags": [
],
"_attachments": [
],
"start": "2019-08-02T12:59:27.428+12:00",
"_submitted_by": null,
"_geolocation": [
null,
null
],
"_xform_id_string": "aKydtLQwpyH4XdFfmB2xTB",
"_status": "submitted_via_web",
"_id": 33920455,
"__version__": "vFMDEBaPxSixQVvYbk9uwh",
"formhub/uuid": "f8fc6dbda2554447ba3e9711de5a9718"
}
If you want you can filter this list by date, or what-have-you, to decide which submission(s) you want to delete. The thing you are looking for is the unique submission id, eg above:
"_id": 33920455,
Once you have this, you can perform a REST “DELETE” against that specific submission REST endpoint
curl -X DELETE -v --user tiritea:$PASSWORD $HOST/assets/$ID/submissions/33920455/
...
< HTTP/2 204
which should return an HTTP status code of 204 (No Content) which is typically used to indicate the associated resource was successfully deleted. You can confirm by trying to GET it again
curl -X GET -v --user tiritea:$PASSWORD $HOST/assets/$ID/submissions/33920455/
...
< HTTP/2 404
...
{
"detail": "Not found."
}
which should return an HTTP 404 (No Found)
Basically, to delete a submission:
- GET list all forms using
$HOST/assets/
- determine the target formid (if you dont already know it)
- GET list the form’s submissions:
$HOST/assets/{formid}/submissions/
- determine the target submission id
- DELETE the submission:
$HOST/assets/{formid}/submissions/{submissionid}/
If you go back into the Kobo console you should find that submission is gone.