Introduction
Welcome to the DocConvert API documentation. Our API provides a comprehensive set of endpoints for document conversion, manipulation, and processing. This documentation will help you integrate our services into your applications.
The API is RESTful and uses JSON for request and response bodies. All requests must be made over HTTPS and include proper authentication.
File uploads are handled directly in each operation endpoint. When making a request, include the file as a multipart form-data field named file
along with any other required parameters for the specific operation.
Quick Start
To get started with the API, you'll need:
- An API key from your API Settings in the account settings area
- Basic understanding of REST APIs
- Ability to make HTTP requests
curl -X POST https://docconvert.co/api/v1/docx_to_pdf \
-H "X-API-Key: YOUR_API_KEY" \
-F "[email protected]"
Authentication
All API requests require authentication using an API key. Include your API key in the X-API-Key header of each request:
X-API-Key: YOUR_API_KEY
You can find your API key in the API Settings section of your account settings. Keep your API key secure and never share it publicly.
Get Uploaded Files
Retrieve a list of all uploaded files.
Parameters
Name | Type | Description |
---|---|---|
page | Integer | Page number (default: 1) |
per_page | Integer | Number of items per page (default: 10) |
GET /api/v1/uploaded_files
X-API-Key: YOUR_API_KEY
Response
{
"data": [
{
"id": 123,
"processing_type": "docx_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"download_url": "https://storage.docconvert.co/files/123/document.docx"
}
]
}
],
"total": 1,
"page": 1,
"per_page": 10,
"total_pages": 1
}
Get Uploaded File
Retrieve details of a specific uploaded file.
GET /api/v1/uploaded_files/{id}
X-API-Key: YOUR_API_KEY
Response
{
"id": 123,
"processing_type": "docx_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"download_url": "https://storage.docconvert.co/files/123/document.docx"
}
]
}
Merge PDFs
Combine multiple PDF files into a single PDF.
Parameters
Name | Type | Description |
---|---|---|
files | Array[File] | Array of PDF files to merge (in order) |
POST /api/v1/merge_pdfs
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "merge_pdfs",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "merged_document.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/merged_document.pdf"
}
]
}
Split PDF
Split a PDF file into multiple PDFs.
Parameters
Name | Type | Description |
---|---|---|
file | File | The PDF file to split |
split_method | String | Method to split the PDF: 'pages' (split by page ranges) or 'bookmarks' (split by bookmarks) |
ranges | String | Required when split_method is 'pages'. Page ranges to split, e.g. "1-3,4-6,7-9" |
POST /api/v1/split_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
{
"file": "@document.pdf",
"split_method": "pages",
"ranges": "1-3,4-6,7-9"
}
Response
{
"id": 123,
"processing_type": "split_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "document_pages_1-3.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/document_pages_1-3.pdf"
},
{
"filename": "document_pages_4-6.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/document_pages_4-6.pdf"
},
{
"filename": "document_pages_7-9.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/document_pages_7-9.pdf"
}
]
}
Optimize PDFs
Optimize a PDF file to reduce its file size.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to optimize |
POST /api/v1/optimize_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "optimize_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "optimized_document.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/optimized_document.pdf"
}
]
}
Encrypt PDF
Add password protection to a PDF file.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to encrypt |
password | String | Password required to open the PDF |
POST /api/v1/encrypt_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
{
"file": "@document.pdf",
"password": "read123"
}
Response
{
"id": 123,
"processing_type": "encrypt_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "encrypted_document.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/encrypted_document.pdf"
}
]
}
Add Watermark
Add a watermark to a PDF file.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to add watermark to |
watermark | File | PDF file to use as watermark |
POST /api/v1/add_watermark
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "add_watermark",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "watermarked_document.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/watermarked_document.pdf"
}
]
}
PDF Validation
Validate a PDF file and get detailed information about its structure and compliance.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to validate |
POST /api/v1/validate_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "pdf_validation",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "validation_report.json",
"mime_type": "application/json",
"download_url": "https://storage.docconvert.co/files/123/validation_report.json"
}
]
}
Convert PDF to PDF/A
Convert a PDF file to PDF/A format for long-term archival.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to convert to PDF/A |
POST /api/v1/convert_pdf_to_pdfa
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "pdf_to_pdf_a",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "document_pdfa.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/document_pdfa.pdf"
}
]
}
Convert DOCX to PDF
Convert a DOCX file to PDF format.
Parameters
Name | Type | Description |
---|---|---|
file | File | DOCX file to convert to PDF |
POST /api/v1/convert_docx_to_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "docx_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "document.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/document.pdf"
}
]
}
Convert PDF to DOCX
Convert a PDF file to DOCX format.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to convert to DOCX |
POST /api/v1/convert_pdf_to_docx
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "pdf_to_docx",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"download_url": "https://storage.docconvert.co/files/123/document.docx"
}
]
}
Convert XLSX to PDF
Convert an XLSX file to PDF format.
Parameters
Name | Type | Description |
---|---|---|
file | File | XLSX file to convert to PDF |
POST /api/v1/convert_xlsx_to_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "xlsx_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "spreadsheet.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/spreadsheet.pdf"
}
]
}
Convert XLSX to JSON
Convert an XLSX file to JSON format.
Parameters
Name | Type | Description |
---|---|---|
file | File | XLSX file to convert to JSON |
POST /api/v1/convert_xlsx_to_json
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "xlsx_to_json",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "spreadsheet.json",
"mime_type": "application/json",
"download_url": "https://storage.docconvert.co/files/123/spreadsheet.json"
}
]
}
Convert PPTX to PDF
Convert a PPTX file to PDF format.
Parameters
Name | Type | Description |
---|---|---|
file | File | PPTX file to convert to PDF |
POST /api/v1/convert_pptx_to_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "pptx_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "presentation.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/presentation.pdf"
}
]
}
Convert HTML to PDF
Convert a webpage to PDF format.
Parameters
Name | Type | Description |
---|---|---|
url | String | URL of the webpage to convert to PDF |
POST /api/v1/convert_html_to_pdf
X-API-Key: YOUR_API_KEY
Content-Type: application/json
{
"url": "https://example.com"
}
Response
{
"id": 123,
"processing_type": "html_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "webpage.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/webpage.pdf"
}
]
}
Convert Image to PDF
Convert one or more image files to PDF format.
Parameters
Name | Type | Description |
---|---|---|
files | Array[File] | Image files to convert to PDF |
POST /api/v1/convert_image_to_pdf
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "image_to_pdf",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "converted_image.pdf",
"mime_type": "application/pdf",
"download_url": "https://storage.docconvert.co/files/123/converted_image.pdf"
}
]
}
Convert PDF to Image
Convert a PDF file to image format.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to convert to image |
POST /api/v1/convert_pdf_to_image
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "pdf_to_image",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "page_1.png",
"mime_type": "image/png",
"download_url": "https://storage.docconvert.co/files/123/page_1.png"
},
{
"filename": "page_2.png",
"mime_type": "image/png",
"download_url": "https://storage.docconvert.co/files/123/page_2.png"
}
]
}
Extract Images from PDF
Extract all images from a PDF file.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to extract images from |
POST /api/v1/extract_images
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "extract_images",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "image_1.png",
"mime_type": "image/png",
"download_url": "https://storage.docconvert.co/files/123/image_1.png"
},
{
"filename": "image_2.jpg",
"mime_type": "image/jpeg",
"download_url": "https://storage.docconvert.co/files/123/image_2.jpg"
}
]
}
Extract Text from Image
Extract text from an image using OCR.
Parameters
Name | Type | Description |
---|---|---|
file | File | Image file to extract text from |
language | String | Language of the text in the image |
POST /api/v1/extract_text
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "extract_text",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "extracted_text.txt",
"mime_type": "text/plain",
"download_url": "https://storage.docconvert.co/files/123/extracted_text.txt"
}
]
}
Extract Tables from PDF
Extract tables from a PDF file.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to extract tables from |
POST /api/v1/extract_tables
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "extract_tables",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "tables.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"download_url": "https://storage.docconvert.co/files/123/tables.xlsx"
}
]
}
Extract Acroform Fields
Extract form fields from a PDF file.
Parameters
Name | Type | Description |
---|---|---|
file | File | PDF file to extract form fields from |
POST /api/v1/extract_acroform_fields
X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data
Response
{
"id": 123,
"processing_type": "extract_acroform_fields",
"processing_status": "completed",
"created_at": "2024-03-20T12:00:00Z",
"processed_files": [
{
"filename": "acroform_fields.json",
"mime_type": "application/json",
"download_url": "https://storage.docconvert.co/files/123/acroform_fields.json"
}
]
}
Webhooks
Webhooks allow you to receive real-time notifications when your file processing jobs are completed. You can manage your webhooks in the Webhook Settings section of your Account Settings. To set up a webhook:
- Navigate to Account Settings and select Webhook Settings
- Click "Add New Webhook" and enter your webhook URL
- Select which events you want to receive notifications for
- Copy your webhook client secret for signature verification
Events
The following events are available for webhook notifications:
processing
- When document processing startsrequeue
- When document is requeued for processingcompleted
- When document processing completesfailed
- When document processing fails
Payload Format
Each webhook notification includes the following information:
{
"event": "completed",
"object_id": "123",
"timestamp": "2024-03-20T12:00:00Z"
}
Signature Verification
Each webhook request includes a signature in the X-Signature
header.
You should verify this signature to ensure the webhook came from DocConvert.
The signature is generated using HMAC SHA-256 with your webhook's client secret. Here are examples in different languages:
Ruby
require 'openssl'
def verify_signature(payload_body, signature, client_secret)
digest = OpenSSL::Digest::SHA256.new('sha256')
expected_signature = OpenSSL::HMAC.hexdigest(
digest,
client_secret,
payload_body
)
Rack::Utils.secure_compare(expected_signature, signature)
end
# In your webhook handler
signature = request.headers['X-Signature']
is_valid = verify_signature(request.raw_post, signature, webhook_client_secret)
Python
import hmac
import hashlib
def verify_signature(payload_body, signature, client_secret):
expected_signature = hmac.new(
client_secret.encode('utf-8'),
payload_body.encode('utf-8'),
hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected_signature, signature)
# In your webhook handler (using Flask)
signature = request.headers.get('X-Signature')
is_valid = verify_signature(request.get_data().decode('utf-8'), signature, webhook_client_secret)
Node.js
const crypto = require('crypto');
function verifySignature(payloadBody, signature, clientSecret) {
const expectedSignature = crypto
.createHmac('sha256', clientSecret)
.update(payloadBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expectedSignature),
Buffer.from(signature)
);
}
// In your webhook handler (using Express)
const signature = req.headers['x-signature'];
const isValid = verifySignature(
JSON.stringify(req.body),
signature,
webhookClientSecret
);
PHP
function verifySignature($payloadBody, $signature, $clientSecret) {
$expectedSignature = hash_hmac(
'sha256',
$payloadBody,
$clientSecret
);
return hash_equals($expectedSignature, $signature);
}
// In your webhook handler
$signature = $_SERVER['HTTP_X_SIGNATURE'];
$payloadBody = file_get_contents('php://input');
$isValid = verifySignature($payloadBody, $signature, $webhookClientSecret);
Your webhook's client secret is provided when you create a new webhook in the dashboard. Keep this secret secure and never share it publicly.
Rate Limits
API access is available only with paid subscription plans. Rate limits are based on your subscription tier:
- Pro: 1,000 requests per day
- Team: Custom limits
In addition to daily limits, all API requests are limited to 10 requests per second to ensure fair usage and system stability.
Error Handling
The API uses standard HTTP response codes and returns error messages in the response body:
{
"code": 400,
"message": "Bad Request",
"errors": [
"The provided file is not in a supported format",
"File size exceeds maximum limit"
]
}
Common error codes:
- 400 - Bad Request
- 401 - Unauthorized
- 403 - Forbidden
- 404 - Not Found
- 429 - Too Many Requests
- 500 - Internal Server Error