Cross-Format

Search/replace across formats, image replacement, and HTTP proxy

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


Search & Replace Text

POST /api/SearchReplaceText 1 token

Find and replace text across document formats (DOCX, XLSX, TXT). Auto-detects format.

Parameters
NameTypeRequiredDescription
file string required Base64-encoded file
replacements array required Array of {find, replace} or object {find: replace}
format string optional docx, xlsx, txt (auto-detect if omitted)
Request Example
JSON
{"file": "<base64-file>", "replacements": [{"find": "old", "replace": "new"}]}
Response Example
JSON
{"file": "UEsDBBQAAAA...", "replacementCount": 3, "format": "docx"}
Code Examples
curl -X POST "https://docbutterfly.com/api/SearchReplaceText" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"file": "<base64-file>", "replacements": [{"find": "old", "replace": "new"}]}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""file"": ""<base64-file>"", ""replacements"": [{""find"": ""old"", ""replace"": ""new""}]}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

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

url = "https://docbutterfly.com/api/SearchReplaceText"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"file": "<base64-file>", "replacements": [{"find": "old", "replace": "new"}]}')

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/SearchReplaceText
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "file": "\u003Cbase64-file\u003E",
│      "replacements": [
│        {
│          "find": "old",
│          "replace": "new"
│        }
│      ]
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/SearchReplaceText"
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

Replace Text with Image

POST /api/ReplaceTextWithImage 2 tokens

Replace a placeholder tag in a DOCX with an inline image.

Parameters
NameTypeRequiredDescription
file string required Base64-encoded DOCX
placeholder string required Text to find e.g. {logo}
image string required Base64-encoded image
width number optional Width in cm (default: 5)
height number optional Height in cm (default: 5)
Request Example
JSON
{"file": "<base64-docx>", "placeholder": "{logo}", "image": "<base64-image>", "width": 5, "height": 3}
Response Example
JSON
{"file": "UEsDBBQAAAA..."}
Code Examples
curl -X POST "https://docbutterfly.com/api/ReplaceTextWithImage" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"file": "<base64-docx>", "placeholder": "{logo}", "image": "<base64-image>", "width": 5, "height": 3}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""file"": ""<base64-docx>"", ""placeholder"": ""{logo}"", ""image"": ""<base64-image>"", ""width"": 5, ""height"": 3}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

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

url = "https://docbutterfly.com/api/ReplaceTextWithImage"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"file": "<base64-docx>", "placeholder": "{logo}", "image": "<base64-image>", "width": 5, "height": 3}')

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/ReplaceTextWithImage
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "file": "\u003Cbase64-docx\u003E",
│      "placeholder": "{logo}",
│      "image": "\u003Cbase64-image\u003E",
│      "width": 5,
│      "height": 3
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/ReplaceTextWithImage"
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

HTTP Request

POST /api/HttpRequest 1 token

Make an HTTP request to an external URL. Blocks private/internal IPs.

Parameters
NameTypeRequiredDescription
url string required Target URL
method string optional GET, POST, PUT, DELETE, PATCH (default: GET)
headers object optional Request headers
body string optional Request body
timeout number optional Timeout in ms (max 30000) (default: 30000)
Request Example
JSON
{"url": "https://httpbin.org/get", "method": "GET"}
Response Example
JSON
{"statusCode": 200, "headers": {"content-type": "application/json"}, "body": "..."}
Code Examples
curl -X POST "https://docbutterfly.com/api/HttpRequest" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://httpbin.org/get", "method": "GET"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""url"": ""https://httpbin.org/get"", ""method"": ""GET""}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

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

url = "https://docbutterfly.com/api/HttpRequest"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"url": "https://httpbin.org/get", "method": "GET"}')

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/HttpRequest
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "url": "https://httpbin.org/get",
│      "method": "GET"
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/HttpRequest"
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

Compose Fill

POST /api/ComposeFill 1 token

Fill a docx/pdf/xlsx/pptx/html template in one call — inline (base64 + kind) or by saved templateId. Returns the filled document plus a dataHash for dedupe.

Saved templates built with the Template Generator are HTML and support repeating sections plus contract-declared formatting (currency/date/number). Add outputFormat:"pdf" to get a rendered PDF. Missing required contract fields return 400 with a missingFields list.
Parameters
NameTypeRequiredDescription
template string optional Base64 template (one-off). Provide this OR templateId
templateId string optional Saved template id — a Template Generator (HTML) template, or a PDF AcroForm template. Provide this OR template
kind string optional docx, pdf, xlsx, pptx, html (required for inline)
data object required Merge data: {key: value}
outputFormat string optional native or pdf (pdf only for html kind, Linux)
flatten boolean optional Flatten PDF form fields (default: false)
filename string optional Output filename (no extension) (default: result)
Request Example
JSON
{"template": "<base64-docx>", "kind": "docx", "data": {"name": "Jamie"}}
Response Example
JSON
{"success": true, "kind": "docx", "file": "UEsDBBQAAAA...", "contentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ext": "docx", "filename": "result.docx", "dataHash": "<sha256>"}
Code Examples
curl -X POST "https://docbutterfly.com/api/ComposeFill" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"template": "<base64-docx>", "kind": "docx", "data": {"name": "Jamie"}}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""template"": ""<base64-docx>"", ""kind"": ""docx"", ""data"": {""name"": ""Jamie""}}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

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

url = "https://docbutterfly.com/api/ComposeFill"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"template": "<base64-docx>", "kind": "docx", "data": {"name": "Jamie"}}')

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/ComposeFill
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "template": "\u003Cbase64-docx\u003E",
│      "kind": "docx",
│      "data": {
│        "name": "Jamie"
│      }
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/ComposeFill"
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

Analyze Template Data

POST /api/AnalyzeTemplateData 1 token

Flatten a sample JSON or XML payload into a field contract: dot-paths, inferred datatypes, sample values, and arrays promoted to repeating tables. No AI, no document required.

Datatypes are inferred from the value plus the key name (a number under a key like total/amount/price becomes currency). XML lists are only detected as repeating tables when the sample contains two or more of the same element — include at least two rows.
Parameters
NameTypeRequiredDescription
data object optional Sample payload as JSON. Provide this OR dataXml
dataXml string optional Sample payload as XML. Provide this OR data
maxDepth number optional Maximum nesting depth to map (default: 6)
Request Example
JSON
{"data": {"invoice": {"number": "INV-1001", "issuedOn": "2026-07-28", "total": 1240.50, "paid": false}, "customer": {"name": "Acme Ltd", "email": "ap@acme.com"}, "lines": [{"description": "Consulting", "qty": 10, "amount": 100.00}, {"description": "License", "qty": 1, "amount": 240.50}]}}
Response Example
JSON
{"success": true, "source": "json", "fields": [{"name": "invoice.number", "label": "Number", "mode": "dynamic", "dataType": "string", "sample": "INV-1001"}, {"name": "invoice.issuedOn", "label": "Issued On", "dataType": "date", "format": {"dateStyle": "medium"}}, {"name": "invoice.total", "label": "Total", "dataType": "currency", "format": {"currency": "USD", "decimals": 2}}, {"name": "invoice.paid", "dataType": "boolean"}, {"name": "customer.email", "dataType": "email"}], "tables": [{"name": "lines", "label": "Lines", "columns": [{"name": "description", "dataType": "string"}, {"name": "qty", "dataType": "number"}, {"name": "amount", "dataType": "currency"}], "sampleRowCount": 2}], "inputContract": {"required": [], "optional": ["invoice.number", "invoice.issuedOn", "invoice.total", "invoice.paid", "customer.name", "customer.email"], "tables": [{"name": "lines", "columns": ["description", "qty", "amount"]}]}, "warnings": []}
Code Examples
curl -X POST "https://docbutterfly.com/api/AnalyzeTemplateData" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"data": {"invoice": {"number": "INV-1001", "issuedOn": "2026-07-28", "total": 1240.50, "paid": false}, "customer": {"name": "Acme Ltd", "email": "ap@acme.com"}, "lines": [{"description": "Consulting", "qty": 10, "amount": 100.00}, {"description": "License", "qty": 1, "amount": 240.50}]}}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""data"": {""invoice"": {""number"": ""INV-1001"", ""issuedOn"": ""2026-07-28"", ""total"": 1240.50, ""paid"": false}, ""customer"": {""name"": ""Acme Ltd"", ""email"": ""ap@acme.com""}, ""lines"": [{""description"": ""Consulting"", ""qty"": 10, ""amount"": 100.00}, {""description"": ""License"", ""qty"": 1, ""amount"": 240.50}]}}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

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

url = "https://docbutterfly.com/api/AnalyzeTemplateData"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"data": {"invoice": {"number": "INV-1001", "issuedOn": "2026-07-28", "total": 1240.50, "paid": false}, "customer": {"name": "Acme Ltd", "email": "ap@acme.com"}, "lines": [{"description": "Consulting", "qty": 10, "amount": 100.00}, {"description": "License", "qty": 1, "amount": 240.50}]}}')

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/AnalyzeTemplateData
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "data": {
│        "invoice": {
│          "number": "INV-1001",
│          "issuedOn": "2026-07-28",
│          "total": 1240.50,
│          "paid": false
│        },
│        "customer": {
│          "name": "Acme Ltd",
│          "email": "ap@acme.com"
│        },
│        "lines": [
│          {
│            "description": "Consulting",
│            "qty": 10,
│            "amount": 100.00
│          },
│          {
│            "description": "License",
│            "qty": 1,
│            "amount": 240.50
│          }
│        ]
│      }
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/AnalyzeTemplateData"
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

Generate Template from Data

POST /api/GenerateTemplateFromData 5 tokens

Turn a sample JSON or XML payload into a ready-to-edit HTML document template with placeholders and repeating sections. AI drafts the layout; falls back to a standard layout if AI is unavailable.

Generated HTML is sanitized before it is returned or stored — scripts, event handlers, external stylesheets/images and unsafe URL schemes are removed. Repeating-section markers are emitted wrapped in HTML comments so they survive inside <table> elements. Save the result with POST /api/manage/templates/{clientId}/compose, then fill it repeatedly with ComposeFill using the returned templateId — you pay this 5-token authoring cost once, and 1 token per document thereafter.
Parameters
NameTypeRequiredDescription
data object optional Sample payload as JSON. Provide this OR dataXml
dataXml string optional Sample payload as XML. Provide this OR data
documentType string optional Hint for the layout, e.g. invoice, purchase order, statement
title string optional Document title
pageSize string optional A4 or Letter (default: A4)
extraFields array optional Custom fields to include: [{name, dataType, mode, required, value}]
useAi boolean optional Set false to skip AI and use the standard layout (default: true)
background object optional Page background: {image (data: or https:), color, opacity 0-1, fit: cover|contain|tile|stretch}
Request Example
JSON
{"dataXml": "<invoice><number>INV-1001</number><issuedOn>2026-07-28</issuedOn><total>1240.50</total><lines><line><description>Consulting</description><qty>10</qty><amount>100.00</amount></line><line><description>License</description><qty>1</qty><amount>240.50</amount></line></lines></invoice>", "documentType": "invoice", "title": "Invoice", "pageSize": "Letter", "extraFields": [{"name": "invoice.dueDate", "dataType": "date", "required": true}, {"name": "company.tagline", "mode": "static", "value": "Precision document automation"}]}
Response Example
JSON
{"success": true, "source": "xml", "engine": "ai", "html": "<!DOCTYPE html><html><head><style>@page{size:Letter;margin:18mm}...</style></head><body><h1>Invoice {{number}}</h1><table><tbody><!--{{#lines.line}}--><tr><td>{{description}}</td><td>{{qty}}</td><td>{{amount}}</td></tr><!--{{/lines.line}}--></tbody></table></body></html>", "fields": [], "tables": [], "inputContract": {"required": ["invoice.dueDate"], "optional": ["number", "issuedOn", "total"], "tables": [{"name": "lines.line", "columns": ["description", "qty", "amount"]}], "example": {}}, "placeholders": {"used": ["number", "total"], "unknown": [], "unused": []}, "warnings": []}
Code Examples
curl -X POST "https://docbutterfly.com/api/GenerateTemplateFromData" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"dataXml": "<invoice><number>INV-1001</number><issuedOn>2026-07-28</issuedOn><total>1240.50</total><lines><line><description>Consulting</description><qty>10</qty><amount>100.00</amount></line><line><description>License</description><qty>1</qty><amount>240.50</amount></line></lines></invoice>", "documentType": "invoice", "title": "Invoice", "pageSize": "Letter", "extraFields": [{"name": "invoice.dueDate", "dataType": "date", "required": true}, {"name": "company.tagline", "mode": "static", "value": "Precision document automation"}]}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""dataXml"": ""<invoice><number>INV-1001</number><issuedOn>2026-07-28</issuedOn><total>1240.50</total><lines><line><description>Consulting</description><qty>10</qty><amount>100.00</amount></line><line><description>License</description><qty>1</qty><amount>240.50</amount></line></lines></invoice>"", ""documentType"": ""invoice"", ""title"": ""Invoice"", ""pageSize"": ""Letter"", ""extraFields"": [{""name"": ""invoice.dueDate"", ""dataType"": ""date"", ""required"": true}, {""name"": ""company.tagline"", ""mode"": ""static"", ""value"": ""Precision document automation""}]}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

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

url = "https://docbutterfly.com/api/GenerateTemplateFromData"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"dataXml": "<invoice><number>INV-1001</number><issuedOn>2026-07-28</issuedOn><total>1240.50</total><lines><line><description>Consulting</description><qty>10</qty><amount>100.00</amount></line><line><description>License</description><qty>1</qty><amount>240.50</amount></line></lines></invoice>", "documentType": "invoice", "title": "Invoice", "pageSize": "Letter", "extraFields": [{"name": "invoice.dueDate", "dataType": "date", "required": true}, {"name": "company.tagline", "mode": "static", "value": "Precision document automation"}]}')

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/GenerateTemplateFromData
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "dataXml": "\u003Cinvoice\u003E\u003Cnumber\u003EINV-1001\u003C/number\u003E\u003CissuedOn\u003E2026-07-28\u003C/issuedOn\u003E\u003Ctotal\u003E1240.50\u003C/total\u003E\u003Clines\u003E\u003Cline\u003E\u003Cdescription\u003EConsulting\u003C/description\u003E\u003Cqty\u003E10\u003C/qty\u003E\u003Camount\u003E100.00\u003C/amount\u003E\u003C/line\u003E\u003Cline\u003E\u003Cdescription\u003ELicense\u003C/description\u003E\u003Cqty\u003E1\u003C/qty\u003E\u003Camount\u003E240.50\u003C/amount\u003E\u003C/line\u003E\u003C/lines\u003E\u003C/invoice\u003E",
│      "documentType": "invoice",
│      "title": "Invoice",
│      "pageSize": "Letter",
│      "extraFields": [
│        {
│          "name": "invoice.dueDate",
│          "dataType": "date",
│          "required": true
│        },
│        {
│          "name": "company.tagline",
│          "mode": "static",
│          "value": "Precision document automation"
│        }
│      ]
│    }
│                                             │
└─────────────────────────────────────────────┘

Steps:
1. Add an HTTP action to your flow
2. Set Method to "POST"
3. Set URI to "https://docbutterfly.com/api/GenerateTemplateFromData"
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