REST API · Available on all paid plans

Convert DOCX to PDF from your code

Learn how to integrate the HelloDocxToPdf API into your application.

Quick Start

Convert a DOCX file to PDF with a single API call. Include your API key in the Authorization header.

curl -X POST https://www.hellodocxtopdf.com/api/convert \
  -H "Authorization: Bearer hpdf_your_api_key" \
  -F "file=@document.docx" \
  -o output.pdf

Authentication

All API requests require authentication using an API key. Include your key in the Authorization header:

Authorization: Bearer hpdf_your_api_key

Tip: You can create and manage your API keys in the Credentials section.

Convert Endpoint

POST/api/convert

Convert a DOCX file to PDF format.

Request

Send a multipart/form-data request with the file:

ParameterTypeDescription
fileFileThe DOCX file to convert (required)

Response

Returns the converted PDF file as binary data with the following headers:

HeaderDescription
Content-Typeapplication/pdf
X-Credits-UsedNumber of credits consumed
X-Credits-RemainingRemaining credits for the month
X-Credits-LimitTotal monthly credit limit

Code Examples

JavaScript / TypeScript

const formData = new FormData();
formData.append('file', docxFile);

const response = await fetch('https://www.hellodocxtopdf.com/api/convert', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer hpdf_your_api_key'
  },
  body: formData
});

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.message);
}

const pdfBlob = await response.blob();
const pdfUrl = URL.createObjectURL(pdfBlob);

// Download the PDF
const link = document.createElement('a');
link.href = pdfUrl;
link.download = 'document.pdf';
link.click();

Python

import requests

url = "https://www.hellodocxtopdf.com/api/convert"
headers = {"Authorization": "Bearer hpdf_your_api_key"}

with open("document.docx", "rb") as f:
    files = {"file": ("document.docx", f, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")}
    response = requests.post(url, headers=headers, files=files)

if response.status_code == 200:
    with open("output.pdf", "wb") as pdf:
        pdf.write(response.content)
    print("PDF saved successfully!")
else:
    print(f"Error: {response.json()}")

Node.js

const fs = require('fs');
const FormData = require('form-data');

const form = new FormData();
form.append('file', fs.createReadStream('document.docx'));

const response = await fetch('https://www.hellodocxtopdf.com/api/convert', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer hpdf_your_api_key',
    ...form.getHeaders()
  },
  body: form
});

const buffer = await response.arrayBuffer();
fs.writeFileSync('output.pdf', Buffer.from(buffer));
console.log('PDF saved successfully!');

Error Handling

The API returns standard HTTP status codes. Errors include a JSON body with details:

StatusDescription
200Success - PDF returned
400Bad request - Invalid file or missing parameters
401Unauthorized - Invalid or missing API key
429Rate limited - Not enough credits
500Server error - Conversion failed

Error Response Example

{
  "error": "Not enough credits",
  "creditsNeeded": 3,
  "creditsRemaining": 1,
  "creditsLimit": 100,
  "resetAt": "2025-02-01T00:00:00.000Z"
}

Credit System

Credits are calculated based on file size:

1 credit = 5MB of file size (rounded up)

File SizeCredits Used
0 - 5 MB1 credit
5 - 10 MB2 credits
10 - 15 MB3 credits
And so on...ceil(size / 5MB)

Need Help?

If you have any questions or run into issues, contact us at support@hellodocxtopdf.com

API Documentation - DOCX to PDF Conversion API | HelloDocxToPdf