Quickstart
Make your first authenticated call and hold a processed PDF in under five minutes.
The fastest path from zero to a processed PDF: get a key, make one call, save the result. No SDK, no setup beyond an API key and a PDF on disk.
Sign in to the dashboard and create an API key. Copy it somewhere safe — you send it on every request. See Authentication for how keys work and how to keep them secure.
Put a PDF named input.pdf in your working directory, swap your_api_key for
your key, and run one of these. Each stamps a watermark on the document and
writes the result to watermarked.pdf.
curl https://api.pdfblocks.com/v1/add_text_watermark \
-H 'X-API-Key: your_api_key' \
-F file=@input.pdf \
-F line_1='CONFIDENTIAL' \
-o watermarked.pdf# pip install requests
import requests
with open('input.pdf', 'rb') as file:
response = requests.post(
'https://api.pdfblocks.com/v1/add_text_watermark',
headers={'X-API-Key': 'your_api_key'},
files={'file': file},
data={'line_1': 'CONFIDENTIAL'},
)
response.raise_for_status()
with open('watermarked.pdf', 'wb') as output:
output.write(response.content)// Node.js 18+
import { readFile, writeFile } from 'node:fs/promises';
const body = new FormData();
body.set('file', new Blob([await readFile('input.pdf')]), 'input.pdf');
body.set('line_1', 'CONFIDENTIAL');
const response = await fetch('https://api.pdfblocks.com/v1/add_text_watermark', {
method: 'POST',
headers: { 'X-API-Key': 'your_api_key' },
body,
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
await writeFile('watermarked.pdf', Buffer.from(await response.arrayBuffer()));<?php
$ch = curl_init('https://api.pdfblocks.com/v1/add_text_watermark');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: your_api_key'],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'file' => new CURLFile('input.pdf', 'application/pdf'),
'line_1' => 'CONFIDENTIAL',
],
]);
$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
file_put_contents('watermarked.pdf', $pdf);
}# gem install http
require 'http'
response = HTTP
.headers('X-API-Key' => 'your_api_key')
.post('https://api.pdfblocks.com/v1/add_text_watermark', form: {
file: HTTP::FormData::File.new('input.pdf'),
line_1: 'CONFIDENTIAL',
})
File.write('watermarked.pdf', response.body) if response.status.success?package main
import (
"bytes"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
var buf bytes.Buffer
form := multipart.NewWriter(&buf)
file, _ := os.Open("input.pdf")
defer file.Close()
part, _ := form.CreateFormFile("file", "input.pdf")
io.Copy(part, file)
form.WriteField("line_1", "CONFIDENTIAL")
form.Close()
req, _ := http.NewRequest("POST", "https://api.pdfblocks.com/v1/add_text_watermark", &buf)
req.Header.Set("Content-Type", form.FormDataContentType())
req.Header.Set("X-API-Key", "your_api_key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
out, _ := os.Create("watermarked.pdf")
defer out.Close()
io.Copy(out, res.Body)
}using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "your_api_key");
using var form = new MultipartFormDataContent
{
{ new ByteArrayContent(File.ReadAllBytes("input.pdf")), "file", "input.pdf" },
{ new StringContent("CONFIDENTIAL"), "line_1" },
};
var response = await client.PostAsync(
"https://api.pdfblocks.com/v1/add_text_watermark", form);
response.EnsureSuccessStatusCode();
await File.WriteAllBytesAsync(
"watermarked.pdf", await response.Content.ReadAsByteArrayAsync());On success the API responds with 200 OK and the watermarked document as the
body:
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 48213Open watermarked.pdf — it is your input with CONFIDENTIAL stamped across
every page. That is the whole contract: a PDF went in, a PDF came out, and
nothing was stored on our side.
No 200? A missing or wrong key returns 401, and an unreadable file
returns 400 — both as application/problem+json. See
Errors for the full status catalog.