Compress
Compress PDF
Compress a single PDF and get back a public download URL. The call is synchronous — the file is already compressed and stored by the time you get the response.
Overview
Send a Base64-encoded PDF as JSON; receive an R2 download URL for the compressed file, valid for 24 hours. This endpoint is on the free-try path — call it with no credentials to evaluate it (anonymous calls are metered at 0 credits and rate-limited by IP).
https://api.bytefuse.in/api/v1/compression/singleRequest
Content type application/json. The body is a CompressionRequest:
file_datastringrequireddata: prefix). Must be at least 100 characters; invalid Base64 returns 400.filenamestringrequired.pdf (case-insensitive) or the request is rejected with 422.optionsobjectoptionalCompressionOptions object (preserve_metadata, preserve_annotations, preserve_forms). Currently accepted but ignored by this endpoint.Default: nulloptions is not yet wired up
Theoptions object is validated but has no effect on the output today. Don’t rely on it to preserve metadata, annotations or forms.Compression level
You don’t choose the strength — your plan tier does. The endpoint maps your account type to an engine level:
basic~45%medium~65%maximum~80–85%Anonymous calls (no account type) default to medium. Quality preservation is always on.
Response
200 OK, application/json — a CompressionResponse:
{
"compression_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"original_size": 10485760,
"compressed_size": 4194304,
"compression_ratio": 0.4,
"quality_score": 0.95,
"processing_time_ms": 2500,
"download_url": "https://<r2-host>/compressed/....pdf",
"expires_at": "2026-07-05T10:00:00+00:00",
"tier_power_used": 0.8,
"could_compress_more": true
}compression_idstringoptionalstatusstringoptional"completed" (the call is synchronous).original_sizeintoptionalcompressed_sizeintoptionalcompression_ratiofloatoptionalquality_scorefloatoptional0.9 if the engine omits it.processing_time_msintoptionaldownload_urlstringoptionalexpires_atstringoptionaltier_power_usedfloatoptional0.6 / 0.8 / 1.0 for basic / medium / maximum.could_compress_morebooloptionaltrue unless the level was maximum (i.e. true for everyone below Enterprise).The response header X-Credits-Charged reports the credits billed — 20 for an authenticated call, 0 for anonymous.
Examples
curl -X POST https://api.bytefuse.in/api/v1/compression/single \
-H "Content-Type: application/json" \
-H "X-API-Key: dt_live_your_key" \
-d '{
"file_data": "JVBERi0xLjQK...BASE64_PDF...",
"filename": "report.pdf"
}'
# Omit the X-API-Key header to use the anonymous free-try path.Errors
file_data isn’t valid Base64.filename doesn’t end in .pdf, or file_data is under 100 characters.Retry-After header.Batch compression is not available yet
/compression/batch exists in the API but is currently a stub — it accepts files, does no compression and charges nothing. Use /single per file for now. Full error semantics are on the Errors page.