4. Delete extraction
DELETE /deleteExtraction
This endpoint enables the deletion of an entire extraction process, a specific batch within an extraction, or an individual file, depending on the parameters provided in the request body. The action is permanent and cannot be undone.
Providing only the
extractionIdresults in the deletion of the entire extraction process along with all associated batches and files.Specifying both
extractionIdandbatchIddeletes the specified batch and all files within it from the extraction.Including
extractionId,batchId, andfileIdleads to the deletion of a specific file within a batch.
Postman Collection
For a complete and interactive set of API requests, please refer to our Postman Integrationcollection.
Server URL
https://api.extracta.ai/api/v1Headers
Content-Type
application/json
Authorization
Bearer <token>
Body
extractionId
string
true
The extraction id
batchId
string
false
The batch id
fileId
string
false
The file id
Body Example
{
"extractionId": "extractionId",
"batchId": "batchId",
"fileId": "fileId"
}Code Example
const axios = require('axios');
/**
* Deletes a specific file within a batch of an extraction process.
*
* @param {string} token - The authorization token for API access.
* @param {Object} deletionDetails - The identifiers for the extraction, batch, and file to be deleted.
* @returns {Promise<Object>} The promise that resolves to the API response confirming deletion.
*/
async function deleteExtraction(token, deletionDetails) {
const url = "https://api.extracta.ai/api/v1/deleteExtraction";
try {
const response = await axios.delete(url, deletionDetails, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
// Handling response
return response.data; // Directly return the parsed JSON response
} catch (error) {
// Handling errors
throw error.response ? error.response.data : new Error('An unknown error occurred');
}
}
async function main() {
const token = 'apiKey';
const deletionDetails = {
"extractionId": "yourExtractionId",
"batchId": "yourBatchId",
"fileId": "yourFileId"
};
try {
const response = await deleteExtraction(token, deletionDetails);
console.log(response);
} catch (error) {
console.error(error);
}
}
main();import requests
def delete_extraction(token, deletion_details):
url = "https://api.extracta.ai/api/v1/deleteExtraction"
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {token}"}
try:
response = requests.delete(url, json=deletion_details, headers=headers)
response.raise_for_status() # Raises an HTTPError if the response status code indicates an error
return response.json() # Returns the parsed JSON response
except requests.RequestException as e:
# Handles any requests-related errors
print(e)
return None
# Example usage
if __name__ == "__main__":
token = "apiKey"
deletion_details = {
"extractionId": "yourExtractionId",
"batchId": "yourBatchId",
"fileId": "yourFileId"
}
response = delete_extraction(token, deletion_details)
if response:
print(response)
else:
print("Failed to delete.")<?php
/**
* Deletes an extraction, a specific batch within an extraction, or a specific file within a batch,
* depending on the parameters provided.
*
* @param string $token The authorization token for API access.
* @param array $deletionDetails The identifiers for the extraction, batch, and file to be deleted.
* @return mixed The API response confirming the deletion or an error message.
*/
function deleteExtraction($token, $deletionDetails) {
$url = 'https://api.extracta.ai/api/v1/deleteExtraction';
// Initialize cURL session
$ch = curl_init($url);
// Prepare the payload
$payload = json_encode($deletionDetails);
// Set cURL options
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $token,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
try {
// Execute cURL session
$response = curl_exec($ch);
// Check for cURL errors
if (curl_errno($ch)) {
throw new Exception('Curl error: ' . curl_error($ch));
}
// Optionally, you might want to check the response status code here
// For simplicity, returning the decoded response for now
return $response;
} catch (Exception $e) {
// Handle exceptions or errors here
return 'Error: ' . $e->getMessage();
} finally {
// Always close the cURL session
curl_close($ch);
}
}
// Example usage
$token = 'apiKey';
$deletionDetails = [
"extractionId" => "yourExtractionId",
"batchId" => "yourBatchId", // Optional, depends on the use case
"fileId" => "yourFileId" // Optional, depends on the use case
];
try {
$response = deleteExtraction($token, $deletionDetails);
echo "Deletion Response: " . $response;
} catch (Exception $e) {
echo "Failed to delete: " . $e->getMessage();
}
?>Responses
{
"status": "deleted",
"deletedAt": 1712547789609
}{
"status": "error",
"message": "Extraction id is required"
}{
"status": "error",
"message": "Could not delete extraction"
}Last updated
Was this helpful?