Extracta.ai
DashboardJoin Discord
  • extracta.ai
    • Introduction
    • Overview
  • API Reference
    • 🔓Authentication
    • 📁Supported File Types
  • Data Extraction - API
    • đŸ’ģAPI Endpoints - Data Extraction
      • 1. Create extraction
      • 2. View extraction
      • 3. Update extraction
      • 4. Delete extraction
      • 5. Upload Files
      • 6. Get results
    • Extraction Details
      • 🌎Supported Languages
      • âš™ī¸Options
      • 📋Fields
    • Receiving Batch Results
      • Polling vs Webhook
      • How to use the Webhook
    • đŸ•šī¸Postman Integration
  • Document Classification - API
    • đŸ’ģAPI Endpoints - Document Classification
      • 1. Create classification
      • 2. View classification
      • 3. Update classification
      • 4. Delete data
        • 4.1 Delete classification
        • 4.2 Delete batch
        • 4.3 Delete files
      • 5. Upload Files
      • 6. Get results
    • Classification Details
      • 📄Document Types
  • Documents
    • Custom Document
    • Resume / CV
    • Contract
    • Business Card
    • Email
    • Invoice
    • Receipt
    • Bank Statement
  • Support
    • 💁Tutorials
    • đŸŸĸAPI Status
  • Contact
    • 📧Contact Us
    • ❓FAQ
Powered by GitBook
On this page
  • Postman Collection
  • Server URL
  • Headers
  • Body
  • Body Example
  • Code Example
  • Responses

Was this helpful?

  1. Data Extraction - API
  2. API Endpoints - Data Extraction

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();
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"
}
Previous3. Update extractionNext5. Upload Files

Last updated 11 months ago

Was this helpful?

đŸ’ģ