> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pdf.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Understanding Sync and Async Modes

export const CTAButton = ({href, text, download}) => {
  return <a href={href} download={download} target="_blank" rel="noopener noreferrer" className="text-[20px] font-medium p-5 bg-[#ff4848] text-white rounded-[5px] block w-fit mb-4">
      <span>{text}</span>
    </a>;
};

When you use APIs, the mode you choose Synchronous (Sync) or Asynchronous (Async) can significantly affect both performance and cost. This article explains the differences between these modes, highlights why Async is superior, and shows how switching can benefit you.

## What are Sync and Async Modes?

### Synchronous (Sync) Mode

In **Sync** mode, your API request is processed immediately, and the result is returned within a limit of 30 seconds. Here are a few disadvantages:

* **API Response**: You receive your results when the processing is complete.
* **No Job ID**: There’s no `jobId` provided by [job/check](/api-reference/job-check) for further status checks.
* **Time Limit**: If processing takes longer than 30 seconds, your request will fail.
* **Higher Costs**: Credits are calculated as:

```javascript theme={null}
Total Credits Used = Endpoint Credits × Number of Pages
```

For precise credit calculations, please refer to the [Credits per Function](https://app.pdf.co/subscriptions#credits-calculator) page.

### Asynchronous (Async) Mode

<Warning>
  To retrieve results, you must poll the [Background Job Check](/api-reference/job-check) endpoint using the `jobId` returned in the initial response. Once the job status is marked as `success`, the output file will be available at the provided URL.
</Warning>

**Async** mode processes your request in the background, providing the option to track progress which gives you:

* **Immediate API Response**: You receive a `jobId` and an output URL right away.
* **Background Processing**: Handles larger tasks without immediate timeouts.
* **Extended Time Limit**: Can process tasks for up to 45 minutes, reducing timeouts.
* **Status Checks**: Use the `jobId` to monitor progress via the [job/check](/api-reference/job-check) endpoint.
* **Webhook Support**: Supports callback to notify you when your job is done on a specified webhook URL.
* **Lower Cost**: Credits are calculated as:

```javascript theme={null}
Total Credits Used = Endpoint Credits + ("Job/Check" Credits × Number of "Job/Check" Calls until status is "working")
```

## Why Async Mode is Superior

1. **Handles Bigger Tasks Efficiently**: Designed for larger files or complex tasks that exceed Sync mode’s 30-second limit, reducing failures and saving time.

2. **More Cost-Effective**: Although Async mode includes a small cost for each [job/check](/api-reference/job-check) call (credits charged per check until status is “working”), it often results in overall savings by minimizing failed requests and unnecessary retries.

3. **Better Control and Transparency**: The `jobId` allows you to check your job’s status, giving you more control and clear insight into the process.

4. **Fewer Timeouts and Failures**: Extended time limits decrease the likelihood of failures.

5. **Automates Workflow with Webhooks**: [Webhooks](/api-reference/webhooks) notify you automatically when your job is complete, reducing the need for manual checks and further saving on [job/check](/api-reference/job-check) credits.

## How to Switch to Async Mode

1. **Modify Your API Request**:

   * Specify that you want to use Async mode in your API call, often by setting an `async` parameter to `true`.

2. **Receive the** `jobId` **and Output URL**:
   * After submitting your request, you’ll get a `jobId` and an output URL where results will be available once processing is complete.

3. **Implement Status Checks (Optional)**:
   * Use the [job/check](/api-reference/job-check) endpoint with your `jobId` to monitor progress.
   * Remember, each [job/check](/api-reference/job-check) call costs credits until status is “working”.

4. **Set Up Webhooks (Recommended)**:
   * Configure [Webhooks & Callbacks](/api-reference/webhooks) to receive automatic notifications when your job is finished (costs 2 credits).
   * This reduces the need for manual status checks and saves on [job/check](/api-reference/job-check) credits.

## Conclusion

Async mode offers a superior approach for API interactions by providing efficiency, cost-effectiveness, and enhanced control. By switching from Sync to Async mode, you optimize resource usage and unlock features like webhooks and extended processing times.

## Addressing Common Concerns

### What About the Cost of Multiple Status Checks?

Async mode is designed to reduce the need for frequent status checks. By setting up [webhooks](/api-reference/webhooks), you receive automatic updates when your job is complete, which minimizes the number of [job/check](/api-reference/job-check) calls and optimizes credit usage.

### Is Switching to Async Mode Complicated?

No, it’s straightforward. You handle the `jobId` and output URL provided after your initial request. Implementing [webhooks](/api-reference/webhooks) can make the process even smoother by automating notifications.
