Skip to main content
FileSlap

FileSlap API Quick Start

Convert HTML to a PDF in a single request. All requests require a valid API key. Only html is required; everything else is optional.

cURL

curl -X POST https://api.fileslap.com/api/convert \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: YOUR_API_KEY" \
  -d '{"html": "<h1>Hello World</h1>"}' \
  --output hello.pdf

Example with layout, margins, a short post-load wait (for client-rendered content), and a suggested filename:

curl -X POST https://api.fileslap.com/api/convert \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: YOUR_API_KEY" \
  -d '{
    "html": "<html><body><h1>Report</h1></body></html>",
    "format": "Letter",
    "landscape": true,
    "marginTop": "0.4in",
    "marginRight": "0.4in",
    "marginBottom": "0.4in",
    "marginLeft": "0.4in",
    "delayMs": 500,
    "filename": "monthly-report"
  }' \
  --output report.pdf

Node.js

import fetch from "node-fetch";
import fs from "fs";

const res = await fetch("https://api.fileslap.com/api/convert", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-KEY": "YOUR_API_KEY"
  },
  body: JSON.stringify({ html: "<h1>Hello World</h1>" })
});

if (!res.ok) {
  throw new Error(`HTTP ${res.status}`);
}

const buffer = await res.arrayBuffer();
fs.writeFileSync("hello.pdf", Buffer.from(buffer));

Python

import requests

response = requests.post(
    "https://api.fileslap.com/api/convert",
    headers={
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
    },
    json={"html": "<h1>Hello World</h1>"}
)

if response.status_code == 200:
    with open("hello.pdf", "wb") as f:
        f.write(response.content)
else:
    print(f"Error: {response.status_code}")

JavaScript (Browser)

const response = await fetch("https://api.fileslap.com/api/convert", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-KEY": "YOUR_API_KEY"
  },
  body: JSON.stringify({ html: "<h1>Hello World</h1>" })
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}`);
}

const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "hello.pdf";
a.click();
window.URL.revokeObjectURL(url);

API Reference

Endpoint: POST https://api.fileslap.com/api/convert
Required Headers:
  • • Content-Type: application/json
  • • X-API-KEY: Your API key
Request body (JSON)

All fields below are optional except html. Invalid values return 400 with a short error message.

  • html (string, required) — HTML document to render.
  • format (string, optional) — Paper size name understood by the renderer (for example A4, Letter). Default when omitted is A4.
  • landscape (boolean, optional) — When true, renders in landscape orientation.
  • marginTop, marginRight, marginBottom, marginLeft (number or string, optional) — Per-side margin. Numbers are interpreted as pixels; strings can include units (for example "0.5in"). If you omit margins, the service uses its default margin preset.
  • delayMs (number, optional) — Milliseconds to wait after load before generating the PDF (useful for JS-rendered content). Capped at 10 000.
  • filename (string, optional) — Base name for the generated file; non-alphanumeric characters are stripped server-side.

Background colors and images are included in the PDF using print-style rendering. There is no separate request flag for backgrounds.

Response: PDF file (application/pdf)

Common use cases

  • Invoices and receipts — Fixed margins and A4 or Letter for print-ready customer PDFs.
  • Reports — Landscape tables and explicit margins for dense data.
  • Dashboards — A short delayMs so charts and client-rendered widgets finish before capture.
  • Print-ready documents — Format, orientation, and margins aligned with how the document will be printed or archived.

Developer Tools

OpenAPI Specification:
Postman Collection:

Complete Integration Guides

Step-by-step guides for every major platform. From Node.js to no-code tools, we've got you covered with production-ready code examples.

The Ultimate Guide

Get the complete overview of all integration options and choose the perfect platform for your needs.

Read Ultimate Guide