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 extractionId results in the deletion of the entire extraction process along with all associated batches and files.

  • Specifying both extractionId and batchId deletes the specified batch and all files within it from the extraction.

  • Including extractionId, batchId, and fileId leads 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/v1

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Required
Description

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();

Responses

{
    "status": "deleted",
    "deletedAt": 1712547789609
}

Last updated