Skip to content
ComPDF

Request Mode Guide

ComPDF API offers three request modes for different business scenarios: synchronous, asynchronous, and pre-signed URL. This page compares them side by side and provides the full calling flow for each one to help you choose the best integration approach.

Overview of the Three Modes

DimensionSynchronous (Sync)Asynchronous (Async)Pre-signed URL (Pre-signed)
Upload methodDirect upload: send the file to ComPDF in one multipart/form-data requestDirect upload: send the file to ComPDF in one multipart/form-data requestThe client uploads directly to object storage through a pre-signed URL, and the file does not pass through the business API
File countSingle file (except merge endpoints)Single / multiple filesSingle / multiple files
BlockingYes. The server returns only after processing finishesNo. Returns taskId immediatelyNo. Returns taskId and the upload address immediately
How to get resultsThe sync response returns downloadUrl directlyPoll task status / receive Webhook notificationsPoll task status / receive Webhook notifications
Recommended file sizeSmall files up to 10 MB10 MB ~ 50 MBLarge files / batch jobs / browser uploads
Server bandwidth usageHigh (both directions go through the business gateway)High (upload still goes through the business gateway)Low (upload goes through object storage CDN)
Implementation complexity★ Easiest★★ Moderate★★★ Slightly more complex (one extra signature step)
Typical scenariosDemos, small tools, instant-feedback pagesBackground batch jobs, async pipelinesBrowser/mobile uploads, very large files, cross-region uploads

Selection advice

  • If you are unsure, start with synchronous, then upgrade to asynchronous / pre-signed as needed.
  • If the business side should not block and files are relatively large, prefer asynchronous.
  • If files come from browsers or end users, are often larger than 50 MB, or you want to reduce your own server bandwidth pressure, use pre-signed URL.

Pros and Cons

Synchronous (Sync)

Pros

  • One request gets the result, so the logic is the simplest.
  • Easy to debug; good for examples and tutorials.

Cons

  • Processing time equals HTTP wait time, so it is prone to gateway / network timeouts.
  • Larger files are less stable; batch processing is not supported.
  • Client threads stay occupied, which limits throughput.

Asynchronous (Async)

Pros

  • Returns taskId immediately, so the caller is non-blocking.
  • Supports batch processing and can work with Webhook callbacks for higher throughput.
  • Good for backend pipelines and scheduled jobs.

Cons

  • Uploads still go through the business gateway, so single-request body limits still apply.
  • Requires an extra "check status / handle callback" step.

Pre-signed URL (Pre-signed)

Pros

  • Files are uploaded directly to object storage, bypassing the business gateway, so very large files are supported.
  • Greatly reduces inbound bandwidth / forwarding pressure on your own server.
  • Ideal for direct uploads from browsers, mini programs, or mobile apps.

Cons

  • The call chain is longest (get signature → upload → trigger task → query result).
  • The client must handle PUT / POST upload protocols.

Call Flow

1. Synchronous Request Flow

1Client starts POSTmultipart/form-datafile + parameter + x-api-key2Server processingFinish conversion / parsing taskHTTP connection stays open3Sync responseReturns downloadUrlcode / status / taskId4Download resultVia downloadUrlLink has an expiration time

Key points

  • One request completes the full "upload + process + return" flow, so the chain is shortest.
  • Because HTTP long connections are affected by gateway timeouts, we recommend tasks with a single file of 10 MB or less and an expected processing time under 60 seconds.
  • The sync API supports only one file (except merge endpoints).
  • See Complete Example for a full runnable sample.

2. Asynchronous Request Flow

1Submit taskPOST uploads filesmultipart/form-data2Return immediatelytaskIdstatus = TaskWaiting3Server processingAsync queue schedulingClient can do other work in parallel4Polling / callbackQuery task statusor receive Webhook5Download resultdownloadUrl

Key points

  • You get taskId immediately after upload, so the caller is not blocked.
  • Query the status through Get Task List / Get Asset Details; we recommend a polling interval of at least 3 seconds.
  • Pair it with Webhook Events to receive task-completion notifications and avoid useless polling.
  • It is well suited for backend batch jobs, overnight jobs, and products where users return later to check the result.

3. Pre-signed URL Request Flow

1Create taskGet taskId andpre-signed uploadUrl2Upload file directlyPUT to object storageBypasses the business gateway3Execute taskNotify the serverTriggered with taskId4Server processingAsync processingSupports very large files5Polling / callbackQuery task statusor Webhook notifications6Download resultVia downloadUrlLink has an expiration time

Key points

  • The biggest difference from the async flow is steps 1 and 2: you first get a pre-signed URL, and the client uploads directly to object storage.
  • The upload step does not pass through the ComPDF business gateway, so it is not limited by the single-request body size, which makes it ideal for large files / browser uploads.
  • After you get the pre-signed URL, complete the upload within its validity period (usually 15 to 30 minutes).
  • The later steps—"execute → query / callback → download"—are the same as the async mode.

General Notes

  • File download links returned by the API are usually deleted at 24:00 the next day; please download them in time.
  • When calling the API, pay attention to the parameter style (query / form / json) and whether the auth header x-api-key is required.
  • HTTP status 200 means your HTTP request succeeded, not that file processing succeeded; use the code field in the response body as the business result.
  • For mainland China access, replace https://api-server.compdf.com/ with https://api-server.compdf.cn/ in all request URLs.
  • If you want automatic notification when a task finishes, use Webhook Events to avoid high-frequency polling.