Document AI

AI-powered field detection, template-based data extraction, and intelligent document processing

2 endpoints in this category. All require X-API-Key header.


AI Field Detection

POST /api/AnalyzeDocument 5 tokens

Sends a PDF through multiple AI engines (Azure Document Intelligence, GPT-4o Vision, and PII regex) to detect all meaningful fields with bounding box coordinates. Returns labeled fields with types, confidence scores, and page positions. Use this to build templates for repeated extraction.

Uses 3 detection engines in sequence for maximum coverage. Cold start may take 15-30 seconds on first call. Subsequent calls are much faster.
Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
prebuiltModel string optional Document Intelligence model: prebuilt-invoice, prebuilt-receipt, prebuilt-layout, prebuilt-idDocument, prebuilt-businessCard (default: prebuilt-invoice)
Request Example
JSON
{"pdf": "<base64-pdf>", "prebuiltModel": "prebuilt-invoice"}
Response Example
JSON
{"success": true, "engines": ["DocIntelligence", "Vision", "PiiRegex"], "model": "prebuilt-invoice", "fieldCount": 12, "tableCount": 1, "fields": [{"id": 0, "label": "VendorName", "value": "Acme Corp", "type": "text", "confidence": 0.95, "page": 1, "boundingBox": {"x": 72.0, "y": 680.5, "width": 180.0, "height": 14.0}, "source": "DocIntelligence"}], "tables": [{"id": 0, "label": "LineItems", "page": 1, "boundingBox": {"x": 50, "y": 300, "width": 500, "height": 150}, "columns": ["Description", "Qty", "Amount"], "rows": [["Monthly License", "1", "$400.00"]]}], "pageSizes": [{"width": 612, "height": 792}], "timing": {"totalMs": 8500, "docIntelligenceMs": 4200, "visionMs": 3800, "piiRegexMs": 120}}
Code Examples
curl -X POST "https://docbutterfly.com/api/AnalyzeDocument" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "prebuiltModel": "prebuilt-invoice"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""prebuiltModel"": ""prebuilt-invoice""}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

var response = await client.PostAsync("https://docbutterfly.com/api/AnalyzeDocument", content);
response.EnsureSuccessStatusCode();

var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
import requests
import json

url = "https://docbutterfly.com/api/AnalyzeDocument"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "prebuiltModel": "prebuilt-invoice"}')

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()

data = response.json()
print(json.dumps(data, indent=2))
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/AnalyzeDocument
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "prebuiltModel": "prebuilt-invoice"
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/AnalyzeDocument"
4. Add the headers shown above
5. Paste the Body JSON into the Body field
6. Replace placeholder values with dynamic content as needed
Try in Testbed

Extract Data with Template

POST /api/ExtractWithTemplate 5 tokens

Applies a saved template or inline template definition to a PDF document and extracts structured JSON data. Optionally redacts specified fields and returns a flattened redacted PDF. Use templateId to reference a saved template by UUID (scoped to your client account), or pass the full template object inline.

Provide either templateId (to use a saved template) or a template object with fields array. Templates are scoped per client — each API key can only access its own templates. When includeBoundingBoxes is false (default), field results contain only value, type, and confidence — ideal for Power Automate.
Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
templateId string optional UUID of a saved template (alternative to inline template). Scoped to the calling client's account via API key.
template object optional Inline template definition (alternative to templateId). Required if templateId is not provided.
template.prebuiltModel string optional Document Intelligence model to use (default: prebuilt-invoice)
template.fields array optional Field definitions: [{fieldKey, label, type, page, x, y, width, height}]
redactFields array optional Field keys to redact in the output PDF
returnRedactedPdf boolean optional Include a securely redacted PDF in the response (default: false)
includeBoundingBoxes boolean optional Include bounding box coordinates in field results (default: false)
Request Example
JSON
{"pdf": "<base64-pdf>", "templateId": "3fdf7d3a-43e6-4f9f-a98f-bd1b77b15a41"}
Response Example
JSON
{"success": true, "fields": {"vendorName": {"value": "Acme Corp", "type": "text", "confidence": 0.95}, "invoiceTotal": {"value": 582.62, "type": "currency", "confidence": 0.97}, "invoiceDate": {"value": "2024-01-15", "type": "date", "confidence": 0.92}}, "tables": {"lineItems": {"columns": ["Description", "Qty", "Amount"], "rows": [["Monthly License", "1", "$400.00"]]}}, "redactedPdf": "JVBERi0xLjcK..."}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractWithTemplate" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "templateId": "3fdf7d3a-43e6-4f9f-a98f-bd1b77b15a41"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""templateId"": ""3fdf7d3a-43e6-4f9f-a98f-bd1b77b15a41""}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

var response = await client.PostAsync("https://docbutterfly.com/api/ExtractWithTemplate", content);
response.EnsureSuccessStatusCode();

var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
import requests
import json

url = "https://docbutterfly.com/api/ExtractWithTemplate"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "templateId": "3fdf7d3a-43e6-4f9f-a98f-bd1b77b15a41"}')

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()

data = response.json()
print(json.dumps(data, indent=2))
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/ExtractWithTemplate
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "templateId": "3fdf7d3a-43e6-4f9f-a98f-bd1b77b15a41"
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/ExtractWithTemplate"
4. Add the headers shown above
5. Paste the Body JSON into the Body field
6. Replace placeholder values with dynamic content as needed
Try in Testbed