PDF Operations

Create, merge, split, watermark, and manipulate PDF documents

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


Merge PDFs

POST /api/MergePdfs 1 token

Combines multiple PDF documents into a single PDF.

Parameters
NameTypeRequiredDescription
pdfs array required Array of base64-encoded PDF strings
returnBase64 boolean optional Return base64 JSON (default: true)
Request Example
JSON
{"pdfs": ["<base64-pdf-1>", "<base64-pdf-2>"], "returnBase64": true}
Response Example
PDF
{"pdf": "JVBERi0xLjcK...", "pageCount": 4}
Code Examples
curl -X POST "https://docbutterfly.com/api/MergePdfs" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdfs": ["<base64-pdf-1>", "<base64-pdf-2>"], "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdfs"": [""<base64-pdf-1>"", ""<base64-pdf-2>""], ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/MergePdfs"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdfs": ["<base64-pdf-1>", "<base64-pdf-2>"], "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/MergePdfs
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdfs": [
│        "\u003Cbase64-pdf-1\u003E",
│        "\u003Cbase64-pdf-2\u003E"
│      ],
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Split PDF

POST /api/SplitPdf 1 token

Extracts specific pages from a PDF. Pages are 1-indexed.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
pages string required Page spec: "1-3,5,7-9"
returnBase64 boolean optional Return base64 JSON (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "pages": "1-3,5", "returnBase64": true}
Response Example
PDF
{"pdf": "JVBERi0xLjcK...", "pageCount": 4}
Code Examples
curl -X POST "https://docbutterfly.com/api/SplitPdf" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "pages": "1-3,5", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""pages"": ""1-3,5"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/SplitPdf"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "pages": "1-3,5", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/SplitPdf
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "pages": "1-3,5",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Watermark PDF

POST /api/WatermarkPdf 1 token

Adds a text or image watermark to PDF pages.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
watermark.text string optional Watermark text
watermark.fontSize number optional Font size (default: 60)
watermark.opacity number optional Opacity 0-1 (default: 0.3)
watermark.rotation number optional Degrees (default: -45)
watermark.position string optional center, top-left, top-right, etc
pages string optional "all" or "1-3,5" (default: all)
Request Example
JSON
{"pdf": "<base64-pdf>", "watermark": {"text": "CONFIDENTIAL", "fontSize": 60, "opacity": 0.3}, "returnBase64": true}
Response Example
PDF
{"pdf": "JVBERi0xLjcK..."}
Code Examples
curl -X POST "https://docbutterfly.com/api/WatermarkPdf" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "watermark": {"text": "CONFIDENTIAL", "fontSize": 60, "opacity": 0.3}, "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""watermark"": {""text"": ""CONFIDENTIAL"", ""fontSize"": 60, ""opacity"": 0.3}, ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/WatermarkPdf"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "watermark": {"text": "CONFIDENTIAL", "fontSize": 60, "opacity": 0.3}, "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/WatermarkPdf
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "watermark": {
│        "text": "CONFIDENTIAL",
│        "fontSize": 60,
│        "opacity": 0.3
│      },
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Stamp PDF

POST /api/StampPdf 1 token

Draws text and/or images at arbitrary (x,y) regions onto a PDF that has no form fields. Coordinates use a top-left origin (y measured down from the top of the page), in PDF points.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
stamps array required Array of stamp objects. Each: type ("text"|"image"), page (1-based), x, y (top-left origin, points). Text: text, size, color {r,g,b} 0-1, font (Helvetica/HelveticaBold/TimesRoman/Courier), rotation, opacity. Image: image (base64 png/jpg), width, height, opacity
returnBase64 boolean optional Return base64 JSON (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "stamps": [{"type": "text", "page": 1, "x": 100, "y": 200, "text": "Jamie Miley", "size": 12}, {"type": "image", "page": 1, "x": 50, "y": 400, "image": "<base64-png>", "width": 120, "height": 60}], "returnBase64": true}
Response Example
PDF
{"success": true, "pdf": "JVBERi0xLjcK...", "pageCount": 1, "stampsApplied": 2, "errors": []}
Code Examples
curl -X POST "https://docbutterfly.com/api/StampPdf" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "stamps": [{"type": "text", "page": 1, "x": 100, "y": 200, "text": "Jamie Miley", "size": 12}, {"type": "image", "page": 1, "x": 50, "y": 400, "image": "<base64-png>", "width": 120, "height": 60}], "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""stamps"": [{""type"": ""text"", ""page"": 1, ""x"": 100, ""y"": 200, ""text"": ""Jamie Miley"", ""size"": 12}, {""type"": ""image"", ""page"": 1, ""x"": 50, ""y"": 400, ""image"": ""<base64-png>"", ""width"": 120, ""height"": 60}], ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/StampPdf"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "stamps": [{"type": "text", "page": 1, "x": 100, "y": 200, "text": "Jamie Miley", "size": 12}, {"type": "image", "page": 1, "x": 50, "y": 400, "image": "<base64-png>", "width": 120, "height": 60}], "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/StampPdf
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "stamps": [
│        {
│          "type": "text",
│          "page": 1,
│          "x": 100,
│          "y": 200,
│          "text": "Jamie Miley",
│          "size": 12
│        },
│        {
│          "type": "image",
│          "page": 1,
│          "x": 50,
│          "y": 400,
│          "image": "\u003Cbase64-png\u003E",
│          "width": 120,
│          "height": 60
│        }
│      ],
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Add PDF Page Numbers

POST /api/AddPdfPageNumbers 1 token

Add page numbers to every page of a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
format string optional Format: "Page {n} of {total}"
position string optional Position on page (default: bottom-center)
fontSize number optional Font size (default: 12)
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "format": "Page {n} of {total}", "position": "bottom-center", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/AddPdfPageNumbers" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "format": "Page {n} of {total}", "position": "bottom-center", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""format"": ""Page {n} of {total}"", ""position"": ""bottom-center"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/AddPdfPageNumbers"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "format": "Page {n} of {total}", "position": "bottom-center", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/AddPdfPageNumbers
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "format": "Page {n} of {total}",
│      "position": "bottom-center",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Add PDF Text Header/Footer

POST /api/AddPdfTextHeaderFooter 1 token

Add text headers and/or footers to PDF pages.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
header string optional Header text
footer string optional Footer text
fontSize number optional Font size (default: 10)
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "header": "CONFIDENTIAL", "footer": "Company Name", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/AddPdfTextHeaderFooter" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "header": "CONFIDENTIAL", "footer": "Company Name", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""header"": ""CONFIDENTIAL"", ""footer"": ""Company Name"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/AddPdfTextHeaderFooter"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "header": "CONFIDENTIAL", "footer": "Company Name", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/AddPdfTextHeaderFooter
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "header": "CONFIDENTIAL",
│      "footer": "Company Name",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Rotate PDF Pages

POST /api/RotatePdfPages 1 token

Rotate specific pages by 90, 180, or 270 degrees.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
rotation number required 90, 180, or 270
pages string optional Pages to rotate (default: all)
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "rotation": 90, "pages": "all", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/RotatePdfPages" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "rotation": 90, "pages": "all", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""rotation"": 90, ""pages"": ""all"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/RotatePdfPages"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "rotation": 90, "pages": "all", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/RotatePdfPages
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "rotation": 90,
│      "pages": "all",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Delete PDF Pages

POST /api/DeletePdfPages 1 token

Remove specific pages from a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
pages array required Array of page numbers to delete (1-indexed)
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "pages": [2, 4], "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/DeletePdfPages" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "pages": [2, 4], "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""pages"": [2, 4], ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/DeletePdfPages"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "pages": [2, 4], "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/DeletePdfPages
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "pages": [
│        2,
│        4
│      ],
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Delete Blank PDF Pages

POST /api/DeleteBlankPdfPages 1 token

Detect and remove blank pages from a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
threshold number optional Blank detection threshold 0-1 (default: 0.02)
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "threshold": 0.02, "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/DeleteBlankPdfPages" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "threshold": 0.02, "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""threshold"": 0.02, ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/DeleteBlankPdfPages"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "threshold": 0.02, "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/DeleteBlankPdfPages
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "threshold": 0.02,
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Resize PDF Pages

POST /api/ResizePdfPages 1 token

Resize all PDF pages to a target format.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
size string required A4, Letter, Legal, or {width,height}
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "size": "A4", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/ResizePdfPages" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "size": "A4", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""size"": ""A4"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/ResizePdfPages"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "size": "A4", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/ResizePdfPages
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "size": "A4",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Flatten PDF

POST /api/FlattenPdf 1 token

Flatten all annotations into page content.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/FlattenPdf" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

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

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/FlattenPdf
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Flatten PDF Forms

POST /api/FlattenPdfForms 1 token

Flatten form fields, embedding values into page content.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/FlattenPdfForms" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

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

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/FlattenPdfForms
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Fill PDF Form

POST /api/FillPdfForm 1 token

Fill PDF form fields with provided values.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
fields object required Object mapping field names to values
flatten boolean optional Flatten after filling (default: false)
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "fields": {"name": "John Doe", "email": "john@example.com"}, "flatten": false, "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/FillPdfForm" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "fields": {"name": "John Doe", "email": "john@example.com"}, "flatten": false, "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""fields"": {""name"": ""John Doe"", ""email"": ""john@example.com""}, ""flatten"": false, ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/FillPdfForm"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "fields": {"name": "John Doe", "email": "john@example.com"}, "flatten": false, "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/FillPdfForm
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "fields": {
│        "name": "John Doe",
│        "email": "john@example.com"
│      },
│      "flatten": false,
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Secure PDF

POST /api/SecurePdf 1 token

Add password protection to a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
userPassword string required Password to open
ownerPassword string optional Owner password
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "userPassword": "secret123", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/SecurePdf" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "userPassword": "secret123", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""userPassword"": ""secret123"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/SecurePdf"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "userPassword": "secret123", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/SecurePdf
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "userPassword": "secret123",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Unlock PDF

POST /api/UnlockPdf 1 token

Remove password protection from a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
password string required Current password
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "password": "secret123", "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/UnlockPdf" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "password": "secret123", "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""password"": ""secret123"", ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/UnlockPdf"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "password": "secret123", "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/UnlockPdf
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "password": "secret123",
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Set PDF Metadata

POST /api/SetPdfMetadata 1 token

Set PDF document metadata.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
metadata.title string optional Document title
metadata.author string optional Author
metadata.subject string optional Subject
metadata.keywords string optional Keywords
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "metadata": {"title": "My Document", "author": "DocFlow"}, "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/SetPdfMetadata" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "metadata": {"title": "My Document", "author": "DocFlow"}, "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""metadata"": {""title"": ""My Document"", ""author"": ""DocFlow""}, ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/SetPdfMetadata"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "metadata": {"title": "My Document", "author": "DocFlow"}, "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/SetPdfMetadata
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "metadata": {
│        "title": "My Document",
│        "author": "DocFlow"
│      },
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed

Get PDF Metadata

POST /api/GetPdfMetadata 1 token

Extract PDF document metadata.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
Request Example
JSON
{"pdf": "<base64-pdf>"}
Response Example
JSON
{"title": "Document", "author": "DocFlow", "pageCount": 5, "creator": "pdf-lib"}
Code Examples
curl -X POST "https://docbutterfly.com/api/GetPdfMetadata" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

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

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/GetPdfMetadata
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

POST /api/ExtractPdfText 1 token

Extract all text content from a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
Request Example
JSON
{"pdf": "<base64-pdf>"}
Response Example
JSON
{"text": "Full document text...", "pageCount": 5}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractPdfText" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

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

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/ExtractPdfText
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

POST /api/ExtractPdfTextByPage 1 token

Extract text from specific pages.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
pages string optional Page numbers: "1-3,5"
Request Example
JSON
{"pdf": "<base64-pdf>", "pages": "1-3"}
Response Example
JSON
{"pages": [{"page": 1, "text": "Page 1 text..."}]}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractPdfTextByPage" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "pages": "1-3"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

url = "https://docbutterfly.com/api/ExtractPdfTextByPage"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "pages": "1-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/ExtractPdfTextByPage
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "pages": "1-3"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

POST /api/ExtractPdfFormData 1 token

Extract form field names and values.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
Request Example
JSON
{"pdf": "<base64-pdf>"}
Response Example
JSON
{"fields": [{"name": "firstName", "type": "text", "value": "John"}]}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractPdfFormData" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

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

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/ExtractPdfFormData
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

POST /api/ExtractPdfImages 1 token

Extract embedded images from a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
format string optional png or jpeg (default: png)
Request Example
JSON
{"pdf": "<base64-pdf>", "format": "png"}
Response Example
JSON
{"images": [{"page": 1, "width": 200, "height": 100, "data": "iVBORw0..."}]}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractPdfImages" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "format": "png"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

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

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/ExtractPdfImages
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "format": "png"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

POST /api/ExtractPdfPages 1 token

Extract pages as individual PDF files.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
pages string required Pages: "1-3,5"
Request Example
JSON
{"pdf": "<base64-pdf>", "pages": "1-3"}
Response Example
JSON
{"pages": [{"page": 1, "pdf": "JVBERi0..."}]}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractPdfPages" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "pages": "1-3"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

url = "https://docbutterfly.com/api/ExtractPdfPages"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "pages": "1-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/ExtractPdfPages
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "pages": "1-3"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

POST /api/ExtractPdfPagesByText 2 tokens

Extract pages containing specific text.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
searchText string required Text to search for
caseSensitive boolean optional Case-sensitive (default: false)
Request Example
JSON
{"pdf": "<base64-pdf>", "searchText": "invoice", "caseSensitive": false}
Response Example
JSON
{"matchingPages": [1, 3], "pages": [{"page": 1, "pdf": "JVBERi0..."}]}
Code Examples
curl -X POST "https://docbutterfly.com/api/ExtractPdfPagesByText" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "searchText": "invoice", "caseSensitive": false}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

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

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/ExtractPdfPagesByText
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "searchText": "invoice",
│      "caseSensitive": false
│    }
│                                             │
└─────────────────────────────────────────────┘

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

Check PDF Password

POST /api/CheckPdfPassword 1 token

Check if a PDF is password-protected.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
password string optional Password to verify
Request Example
JSON
{"pdf": "<base64-pdf>"}
Response Example
JSON
{"isProtected": true, "passwordValid": null}
Code Examples
curl -X POST "https://docbutterfly.com/api/CheckPdfPassword" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>"}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

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

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

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

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

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/CheckPdfPassword
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E"
│    }
│                                             │
└─────────────────────────────────────────────┘

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

Add PDF Attachments

POST /api/AddPdfAttachments 1 token

Embed file attachments into a PDF.

Parameters
NameTypeRequiredDescription
pdf string required Base64-encoded PDF
attachments array required Array of {name, content, mimeType}
returnBase64 boolean optional Return base64 (default: true)
Request Example
JSON
{"pdf": "<base64-pdf>", "attachments": [{"name": "data.csv", "content": "<base64>", "mimeType": "text/csv"}], "returnBase64": true}
Code Examples
curl -X POST "https://docbutterfly.com/api/AddPdfAttachments" \
  -H "X-API-Key: df_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "<base64-pdf>", "attachments": [{"name": "data.csv", "content": "<base64>", "mimeType": "text/csv"}], "returnBase64": true}'
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "df_your_api_key_here");

var json = @"{""pdf"": ""<base64-pdf>"", ""attachments"": [{""name"": ""data.csv"", ""content"": ""<base64>"", ""mimeType"": ""text/csv""}], ""returnBase64"": true}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

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

// The response contains a base64-encoded file in the JSON body
var result = await response.Content.ReadAsStringAsync();
using var doc = System.Text.Json.JsonDocument.Parse(result);
var base64 = doc.RootElement.GetProperty("pdf").GetString();
var bytes = Convert.FromBase64String(base64!);
await File.WriteAllBytesAsync("output.pdf", bytes);
import requests
import json
import base64

url = "https://docbutterfly.com/api/AddPdfAttachments"
headers = {
    "X-API-Key": "df_your_api_key_here",
    "Content-Type": "application/json"
}
payload = json.loads('{"pdf": "<base64-pdf>", "attachments": [{"name": "data.csv", "content": "<base64>", "mimeType": "text/csv"}], "returnBase64": true}')

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

# Decode the base64 PDF and save to file
data = response.json()
pdf_bytes = base64.b64decode(data["pdf"])
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)
print("Saved to output.pdf")
┌─────────────────────────────────────────────┐
│  Power Automate - HTTP Action               │
├─────────────────────────────────────────────┤
│                                             │
│  Method:  POST                              │
│  URI:     https://docbutterfly.com/api/AddPdfAttachments
│                                             │
│  Headers:                                   │
│    X-API-Key:    df_your_api_key_here       │
│    Content-Type: application/json           │
│                                             │
│  Body:                                      │
│    {
│      "pdf": "\u003Cbase64-pdf\u003E",
│      "attachments": [
│        {
│          "name": "data.csv",
│          "content": "\u003Cbase64\u003E",
│          "mimeType": "text/csv"
│        }
│      ],
│      "returnBase64": true
│    }
│                                             │
└─────────────────────────────────────────────┘

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

To save the output file:
7. Add a "Parse JSON" action on the HTTP response body
8. Use base64ToBinary(body('Parse_JSON')?['pdf']) to convert
9. Pass the result to a "Create file" action (SharePoint, OneDrive, etc.)
Try in Testbed