Skip to navigation

Quickstart

Extract data from your first document in under 5 minutes

Prerequisites

Before you begin, you’ll need:

Step 1: Create an Extractor

1

Go to Extractors

Navigate to your project in the Automat Dashboard and click Create Extractor

2

Define Your Schema

Use the visual editor to define what fields you want to extract. For example, for an invoice:

{
"invoice_number": "string",
"date": "string",
"total_amount": "number",
"vendor_name": "string",
"line_items": [{
"description": "string",
"quantity": "number",
"unit_price": "number"
}]
}
3

Test in Playground

Upload a sample document to test your extractor before using the API

4

Copy Extractor ID

Once satisfied, copy the extractor ID (e.g., ext_abc123) for API use

Step 2: Make Your First API Request

Using cURL

curl -X POST https://inference.runautomat.com/api/extract \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "extractorId=YOUR_EXTRACTOR_ID" \
-F "file=@path/to/your/document.pdf"

Using the TypeScript SDK

npm install @automat/sdk
import { AutomatClient } from '@automat/sdk';
import fs from 'fs';
const client = new AutomatClient({
apiKey: process.env.AUTOMAT_API_KEY,
});
async function extractDocument() {
const result = await client.extract({
extractorId: 'ext_abc123',
file: fs.createReadStream('invoice.pdf'),
});
if (result.success) {
console.log('Extracted data:', result.data);
} else {
console.error('Extraction failed:', result.error);
}
}
extractDocument();

Using the Python SDK

pip install automat-sdk
from automat import AutomatClient
import os
client = AutomatClient(api_key=os.environ["AUTOMAT_API_KEY"])
with open("invoice.pdf", "rb") as f:
result = client.extract(
extractor_id="ext_abc123",
file=f,
)
if result.success:
print("Extracted data:", result.data)
else:
print("Extraction failed:", result.error)

Step 3: Handle the Response

A successful response looks like:

{
"success": true,
"data": {
"invoice_number": "INV-2024-001",
"date": "2024-01-15",
"total_amount": 1250.00,
"vendor_name": "Acme Corp",
"line_items": [
{
"description": "Widget A",
"quantity": 10,
"unit_price": 100.00
},
{
"description": "Widget B",
"quantity": 5,
"unit_price": 50.00
}
]
}
}

The data field contains the extracted information matching your extractor’s schema.

Alternative Input Methods

Extract from URL

If your document is publicly accessible, you can pass a URL instead of uploading:

curl -X POST https://inference.runautomat.com/api/extract \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "extractorId=ext_abc123" \
-F "file=https://example.com/invoice.pdf" \
-F "mimeType=application/pdf"

When using a URL, you must also provide the mimeType field.

Extract from Base64

For base64-encoded documents:

const result = await client.extract({
extractorId: 'ext_abc123',
file: base64EncodedDocument,
mimeType: 'application/pdf',
});

Error Handling

Always handle potential errors in your integration:

try {
const result = await client.extract({
extractorId: 'ext_abc123',
file: fs.createReadStream('document.pdf'),
});
if (!result.success) {
// Handle extraction error (e.g., invalid document)
console.error('Extraction error:', result.error);
return;
}
// Process successful extraction
processData(result.data);
} catch (error) {
// Handle network/authentication errors
if (error.statusCode === 401) {
console.error('Invalid API key');
} else if (error.statusCode === 400) {
console.error('Bad request:', error.message);
} else {
console.error('Unexpected error:', error);
}
}

Next Steps