// Repository SDK 0.5.0; npm publication is a separate release step.
// npm install @dislify/sdk (use 0.5.0 once it is published)
import { readFile, writeFile } from "node:fs/promises"import { DislifyClient } from "@dislify/sdk"const client = newDislifyClient({ apiKey: process.env.DISLIFY_API_KEY! })
const source = await client.files.upload(
newBlob([awaitreadFile("proposal.docx")]),
{
fileName: "proposal.docx",
contentType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
}
)
const submitted = await client.files.convert(source.id, { format: "pdf" })
const result = await client.processing.wait(submitted.id)
for (const output of result.generatedFiles) {
const bytes = await client.files.download(output.id)
await writeFile(output.name, Buffer.from(await bytes.arrayBuffer()))
}
const history = await client.files.get(result.generatedFiles[0].id)
console.log(history.parents.map((file) => file.id))
Running this from the CLI? Use node --env-file=.env app.mjs, or load dotenv/config.
For upload limits, use client.processing.compressPdf(fileId, { targetSizeBytes: 2 * 1024 ** 2, idempotencyKey: "pdf-limit-1" }) or compressImage for JPG/PNG. Choose a target or preset; unreachable targets fail without output.
Office batches return independent child job IDs. Split PDF and PDF-to-images can return multiple generated Files. Sources remain unchanged and retention follows the account plan or connected bucket.
01
Authenticate
POST /api/v1/developers/token with your API key, then keep the returned Bearer token server-side.
02
Create a source File
Prepare a signed upload with POST /api/v1/uploads, upload the bytes, then finalize it with POST /api/v1/files.
03
Submit an operation
Send owned File IDs to POST /api/v1/processing/jobs with one supported operation. The response includes job IDs and an optional batch ID.
04
Read the result
Poll GET /api/v1/processing/jobs/:id or receive a signed job event. Generated Files are durable outputs with source lineage.
05
Download safely
Read File metadata with GET /api/v1/files/:id, then request a short-lived download URL from the File download endpoint.
Processing operations
Browser tools, REST jobs, and SDK helpers share the same operation model.
42 operations
Password Protect PDF
protect_pdf
Unencrypted static PDF → Independently verified AES-256 encrypted PDF
Options
Opening password, optional distinct owner password, and advisory reader restrictions
Independent batches sharing one password. 20 MiB, 200 pages per file, up to five files per batch.
One owned UTF-8 CSV or one visible XLSX worksheet per item → One verified cleaned CSV or XLSX File per input
Options
Ordered column-scoped cleanup rules, explicit source settings, output format and optional preview digests
Independent batch, failed-only retry, ZIP and compatible deterministic workflows. 20 MiB per file, 20,000 rows, 64 columns, 200,000 cells and 20 rules within existing plan limits..
2–8 owned UTF-8 CSV or XLSX Files in submission order → One verified CSV or XLSX File
Options
Per-file worksheet, delimiter and header row, explicit column mapping, append or separate worksheets, optional provenance
One multi-source job with all inputs recorded. Resubmit failed merges as a new job.. 20 MiB combined, up to 20,000 data rows, 64 columns and 200,000 cells, subject to existing plan limits. Workflows are excluded in V1..
Owned Files in submission order, including mixed formats → One byte-verified renamed copy per File, with original extension and MIME type
Options
Ordered literal rules and templates, numbering, manual stem overrides, reject or suffix collisions
Independent batch, stable failed-only retry, individual downloads and ZIP. Up to 100 sources within existing plan limits, 250 MiB aggregate, 180 UTF-8 filename bytes. Batch-only in V1..
One MP4/MOV/WebM/MKV progressive SDR video, optionally one mono/stereo audio track → Selected MP4/MOV/MKV H.264/AAC or WebM VP9/Opus
Options
format; resolution original/1080/720/480 short-edge cap without upscaling; quality balanced/high/small; frameRate original/24/25/30; audio keep/remove
Independent batch/retry/ZIP and compatible video workflows. 30 minutes; 250 MiB and plan caps; even square-pixel dimensions up to 1920×1080 including portrait; 10–60 fps; no extra tracks or HDR.
One MP3, PCM WAV, M4A/AAC, FLAC, OGG/Vorbis or Ogg/Opus; mono/stereo 8–48 kHz, no artwork or video → Selected MP3, PCM16 WAV, M4A/AAC, FLAC16, OGG/Vorbis or Ogg/Opus
One MP4/MOV/WebM/MKV video, including silent video → One H.264/yuv420p MP4 with first audio track encoded as AAC/48 kHz when present
Options
Required startSeconds and endSeconds: finite seconds, up to 3 decimal places, minimum 0.1 second range within native duration
Independent batch/retry/ZIP; MP4 workflow output. 30 minutes; 250 MiB plus plan cap; even square pixels up to 1920×1080 including portrait; 10–60 fps; mono/stereo 8–48 kHz; decoded cuts, not frame-exact.
One MP4/MOV/WebM/MKV video with a supported mono/stereo audio track → One MP3 audio File
Options
bitrate: 128 | 192 | 256 | 320 kbps (192)
Independent batch/retry/ZIP; terminal workflow step. 30 minutes; 250 MiB source/output plus plan cap; first audio stream; 8–48 kHz; original unchanged.
One MP4/MOV/WebM/MKV video with a supported mono/stereo audio track → One MP3, M4A or WAV audio File
Options
format: mp3 (default) | m4a | wav; bitrate: 128 | 192 | 256 | 320 for MP3 only (192). M4A copies compatible AAC-LC or transcodes AAC at 192 kbps; WAV is PCM 16-bit/48 kHz
Independent batch/retry/ZIP; terminal workflow step. 30 minutes; 250 MiB source/output plus plan cap; first audio stream; 8–48 kHz; original unchanged.
One still JPG / PNG → One same-format cropped/rotated File
Options
rotation: 0 | 90 | 180 | 270 clockwise; optional x, y, width, height integer pixels after orientation normalization and rotation; omit all crop fields for full image
Independent batch/retry/ZIP; workflow. Same pixel rectangle per image; out-of-bounds items fail individually. 50 MiB source/output plus plan limits; 8192px side; 20M pixels; no private metadata copied; JPG re-encoded at quality 95.
preset: best_quality | balanced | smaller_file OR targetSizeBytes: integer maximum output bytes; mutually exclusive
Independent jobs for ordered sources; one File per source. Static PDF; 2,000 pages; target 16 KiB minimum and 5–95% of source; plan byte caps; strict target or safe error.
Independent jobs for ordered sources; one File per source. 50 MiB + plan cap; 20M pixels; 8,192 px side; target 16 KiB minimum and 5–95% of source; image queue.
Submit {"fileIds":["source-id"],"operations":[{"type":"compress_pdf","targetSizeBytes":2097152}]}, or use compress_image for JPG/PNG. Choose exactly one of integer targetSizeBytes or preset (best_quality, balanced, smaller_file). Targets are at least 16 KB, 5–95% of the source and within plan/output limits. 1 MB = 1,048,576 bytes. Completion means independently verified stored bytes are at or below the target. An unreachable target or no-savings error creates no output File or output storage charge; try a larger target or preset.
Generic signed events include sanitized target/preset options, source IDs and actual generated File sizes. Failed targets have no successful output. Guests have no account webhook endpoints. SDK 0.5.0 is prepared in the repository; npm publication is a separate release step.
Limits + errors
Developer tokens require Unlimited and the correct scopes. Expect standard 4xx responses for invalid options, ownership, limits, quota, and unsupported formats. Native dispatch failures may transition an accepted job to error.
Idempotency
CSV→XLSX, XLSX→CSV, HEIC→image, Compress PDF and Compress image support Idempotency-Key. Reuse a key only for the same owner, source, and options. Other processing submissions are not retried automatically.
Signed events
Subscribe to job.queued, job.completed, and job.failed. Verify HMAC-SHA256 against the exact raw body and deduplicate by event ID. Delivery is currently best effort without automatic replay.
Current API quotas are 60 job submissions per hour and 10,000 per month for eligible accounts; operation-specific caps and normal storage retention still apply.
02
Reference
Existing media-compression SDK
The official JavaScript/TypeScript SDK v0.2.0 wraps API-key exchange, signed uploads, retries, job and batch polling, typed results, and protected downloads. Use it for image optimization or image, video, and audio batches; the REST endpoints below remain available for lower-level control.
Request a short-lived upload URL, PUT the media directly to private R2 storage, then create the asynchronous compression job with the returned upload ID.
Use one of eight named presets, or select custom compression and provide an approximate target in bytes or as a percentage of the original file.
gentle~15% smaller
Light optimization for files that are already close to the size you want. Prioritizes visual and audio fidelity.
web~25% smaller
A quality-first preset for websites, portfolios, product pages, and everyday sharing.
balanced~35% smaller
A practical balance between output quality and file-size reduction for general use.
discord
Targets a Discord-friendly output while still keeping the result smaller than the original file.
strong~45% smaller
More aggressive compression for uploads where a noticeably smaller file matters more than perfect fidelity.
maximum~60% smaller
Prioritizes a substantially smaller result while keeping the media usable for normal playback and sharing.
tiny~70% smaller
Pushes hard for a compact result when transfer size is the main concern.
ultra~78% smaller
The most aggressive preset. Best when getting the file as small as practical matters more than fidelity.
Custom target
Set compression: "custom" and send either targetSizeBytes or targetSizePercent. The percentage is the desired output size relative to the source — for example, 55 targets an output around 55% of the original size. Targets must be between 5% and 95% of the source size.
Check the job while processing or use webhooks to receive completion and failure events automatically. Completed Unlimited jobs also expose the automatic public share URL and its expiration.
job-status
const jobId = "job_123"constres = awaitfetch(`https://api.dislify.com/v1/jobs/${jobId}`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
})
constjob = awaitres.json()
console.log(job.id)
console.log(job.status)
console.log(job.downloadUrl)
// Tip:
// You do not need to keep polling this endpoint.
// Register a webhook to receive job.completed and job.failed events automatically.
07
Reference
Download a completed output
The download URL is protected. Send the same temporary Bearer token when requesting the file; the route verifies job ownership before streaming bytes from private R2 storage.