1. Create extraction

POST /createExtraction

Initiates a new document extraction process. This endpoint allows you to define an extraction with specific fields, options, and configurations. Once created, you can use the returned extractionId to upload files for processing.

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
Dedicated page

name

string

true

A descriptive name for the extraction.

description

string

false

A description for the extraction.

language

string

true

Document's language for accurate extraction.

options

object

false

Additional processing options.

fields

object

true

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.

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

Body Example

{
    "extractionDetails": { 
        "name": "CVs Extraction",
        "description": "...",
        "language": "English",
        "options": {
            "hasTable": false,
            "handwrittenTextRecognition": false,
            "checkboxRecognition": false
        },
        "fields": [
            {
                "description": "",
                "example": "",
                "key": "name"
            },
            {
                "description": "",
                "example": "",
                "key": "surname"
            },
            {
                "description": "",
                "example": "",
                "key": "phone_number"
            },
            {
                "description": "last job title name",
                "example": "Programmer",
                "key": "last_job_position"
            },
            {
                "description": "the number of years in numbers",
                "example": "6",
                "key": "years_of_experience"
            }
        ]
    }
}

Code Example

const axios = require('axios');

/**
 * Initiates a new document extraction process with the provided details.
 * 
 * @param {string} token - The authorization token for API access.
 * @param {Object} extractionDetails - The details of the extraction to be created.
 * @returns {Promise<Object>} The promise that resolves to the API response with the new extraction ID.
 */
async function createExtraction(token, extractionDetails) {
    const url = "https://api.extracta.ai/api/v1/createExtraction";

    try {
        const response = await axios.post(url, {
            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 extractionDetails = {
        "name": "CVs Extraction",
        "description": "...",
        "language": "English",
        "options": {
            "hasTable": false,
            "handwrittenTextRecognition": false
        },
        "fields": [
            { "description": "", "example": "", "key": "name" },
            { "description": "", "example": "", "key": "surname" },
            { "description": "", "example": "", "key": "phone_number" },
            { "description": "last job title name", "example": "Programmer", "key": "last_job_position" },
            { "description": "the number of years in numbers", "example": "6", "key": "years_of_experience" }
        ]
    };

    try {
        const response = await createExtraction(token, extractionDetails);
        console.log("New Extraction Created:", response);
    } catch (error) {
        console.error("Failed to create new extraction:", error);
    }
}

main();

Responses

{
    "status": "created",
    "createdAt": 1712547789609,
    "extractionId": "extractionId"
}

Last updated