🎁
Founder Deals
Get 20% bonus credits and lifetime API discounts.
View Deals
P
Product Hunt
Leave us a review on Product Hunt.
Visit on Product Hunt

Extracting Document Data with the DoxTract API

Last updated Jul 22, 2026, 6:55 AM
DoxTractAPI TutorialREST APIDevelopersDocument AISoceTonAI

This tutorial covers the DoxTract workflow entirely through the REST API — generating credentials, submitting documents for extraction, polling job status, and pulling down structured results. No dashboard clicking required beyond the one-time steps of generating keys and building a template.

Note: Templates themselves are still built visually — the Template Editor is the only way to define fields, and it works without signup if you want to try it first. Once a template exists, everything below can be automated.

Extracting Document Data using SoceTonAI DoxTract API
Extracting Document Data using API

Prerequisites

  • A DoxTract account with at least one saved template

  • Your template_id (grab it from the Doxtract page, or list your templates via the API — see Step 3)

  • curl or any HTTP client

Step 1: Generate API Credentials

From your dashboard, click Generate New Key, name it, and click Create. Copy the API Key and API Secret immediately — they're shown once.

Every request below needs both, sent as headers:

x-api-key: YOUR_API_KEY
x-api-secret: YOUR_API_SECRET

Treat these like any other production credential — don't hardcode them in client-side code or commit them to a repo.

Step 2: Submit a Document for Extraction

bash
curl -X POST "https://api.soceton.com/doxtract/api/read" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-secret: YOUR_API_SECRET" \
  -F "files=@invoice.pdf" \
  -F 'data={"template_id":"123"}'
Request
json
{
    "success": true,
    "job_id": "string",
    "result": {}
}
Response
  • Single file: result is populated immediately — no polling needed.

  • Multiple files: the response returns a job_id for an async job; result will be empty until you poll it (Step 3).

To send several files in one batch, repeat the files field:

bash
curl -X POST "https://api.soceton.com/doxtract/api/read" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-secret: YOUR_API_SECRET" \
  -F "files=@invoice1.pdf" \
  -F "files=@invoice2.pdf" \
  -F "files=@invoice3.pdf" \
  -F 'data={"template_id":"123"}'
Request

Step 3: Poll Job Status (Batch Jobs Only)

bash
curl -X GET "https://api.soceton.com/doxtract/api/jobs/JOB_ID" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-secret: YOUR_API_SECRET"
Request
json
{
    "processed_pages": 4,
    "total_pages": 10,
    "status": "processing"
}
Response

Poll on an interval (a few seconds is reasonable) until status reports completion. A minimal polling loop:

python
import time
import requests

headers = {
    "x-api-key": "YOUR_API_KEY",
    "x-api-secret": "YOUR_API_SECRET",
}

job_id = "JOB_ID"
url = f"https://api.soceton.com/doxtract/api/jobs/{job_id}"

while True:
    resp = requests.get(url, headers=headers).json()
    if resp["status"] == "completed":
        break
    print(f"{resp['processed_pages']}/{resp['total_pages']} pages processed")
    time.sleep(5)

Step 4: Download the Results

Once the job is complete, request a download link. It's signed and expires after 5 minutes, so fetch the file right away.

bash
curl -X GET "https://api.soceton.com/doxtract/api/download/JOB_ID" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-secret: YOUR_API_SECRET"
Request
json
{
    "url": "https://..."
}
Response

Then download the actual CSV:

bash
curl -o results.csv "SIGNED_URL_FROM_ABOVE"
Download Extracted CSV

Step 5: List Your Templates Programmatically

If you're managing multiple templates and don't want to hardcode IDs, list them via the API:

bash
curl -X GET "https://api.soceton.com/doxtract/api/templates?skip=0&limit=10" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-secret: YOUR_API_SECRET"
Request
json
{
    "total": 42,
    "skip": 0,
    "limit": 10,
    "data": []
}
Response

Use skip and limit to paginate if you have more than a handful.

Putting It Together

A typical automated pipeline looks like this:

  1. New document lands in a watched folder, inbox, or storage bucket.

  2. Your script POSTs it to /doxtract/api/read with the right template_id.

  3. For batches, poll /doxtract/api/jobs/{job_id} until complete.

  4. Fetch the signed URL from /doxtract/api/download/{job_id} and pull the CSV (or read result directly for single-file calls).

  5. Load the structured data into your database, accounting system, or spreadsheet.

That's the entire extraction workflow without opening the dashboard once you're past the initial key generation and template setup. If a template needs changes later, that part still goes through the Template Editor — but everyday extraction runs entirely on these four endpoints.

DoxTract API Tutorial: Extract Document Data via REST API | SoceTonAI