3. Update extraction

PATCH /updateExtraction

Updates an existing document extraction process by modifying specified parameters within the extraction details.

Only the parameters included in the extractionDetails will be updated; any parameters not included will remain unchanged. Use this to efficiently adjust specific aspects of an extraction process without altering its overall configuration.

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

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Body

NameTypeRequiredDescriptionDedicated page

extractionId

string

true

The extraction Id

name

string

false

A descriptive name for the extraction.

description

string

false

A description for the extraction.

language

string

false

Document's language for accurate extraction.

options

object

false

Additional processing options.

fields

object

false

An array of objects, each specifying a field to extract.

To fully customize your data extraction request, understanding the fields parameter is crucial. This parameter allows you to specify exactly what information you want to extract, with options for string, object, and array types to match your data structure needs.

📋Fields

Customize your extraction process with additional options such as table analysis and handwritten text recognition.

⚙ī¸Options

Body Example

{
    "extractionId": "extractionId",
    "extractionDetails": {
        "name": "CV - English",
        "description": "test",
        "language": "English",
        "options": {
            "hasTable": false,
            "handwrittenTextRecognition": true
        },
        "fields": [
            {
                "key": "name",
                "description": "the name of the person",
                "example": "John"
            },
            {
                "key": "email",
                "description": "the email of the person",
                "example": "john@email.com"
            }
        ]
    }
}

Code Example

const axios = require('axios');

/**
 * Updates an existing document extraction with the provided details.
 * 
 * @param {string} token - The authorization token for API access.
 * @param {string} extractionId - The ID of the extraction to update.
 * @param {Object} extractionDetails - The new details of the extraction to update.
 * @returns {Promise<Object>} The promise that resolves to the API response with the updated extraction details.
 */
async function updateExtraction(token, extractionId, extractionDetails) {
    const url = "https://api.extracta.ai/api/v1/updateExtraction";

    try {
        const response = await axios.patch(url, {
            extractionId,
            extractionDetails
        }, {
            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 extractionId = 'extractiondId'; // Placeholder for actual extraction ID
    const extractionDetails = {
        "name": "CV - English",
        "description": "...",
        "language": "English",
        "options": {
            "hasTable": false,
            "handwrittenTextRecognition": true
        },
        "fields": [
            {
                "key": "name",
                "description": "the name of the person",
                "example": "John"
            },
            {
                "key": "email",
                "description": "the email of the person",
                "example": "john@email.com"
            }
        ]
    };

    try {
        const response = await updateExtraction(token, extractionId, extractionDetails);
        console.log("Extraction Updated:", response);
    } catch (error) {
        console.error("Failed to update extraction:", error);
    }
}

main();

Responses

{
    "status": "updated",
    "updatedAt": 1712547789609,
    "extractionId": "extractionId"
}

Last updated