> For the complete documentation index, see [llms.txt](https://docs.pandium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pandium.com/getting-started/integration-patterns/batch-and-api-triggered-syncs.md).

# Batch and API-Triggered Syncs

Batch and API-triggered syncs on Pandium: scheduled, manual, and API-driven integration runs that pull, transform, and push data between systems.

Batch is the pattern behind most integrations on Pandium. A job runs, kicked off by a schedule, a user clicking "Sync now," or an API call, and each run pulls whatever changed on one side and pushes it to the other. Data can move in both directions in the same run.

It is also the oldest pattern on the platform, and still the one most integrations use, because it has the fewest ways to fail. It is not only for nightly jobs. Schedules go down to the minute, so a batch integration with fast logic is a solid semi-real-time pattern without any of the infrastructure a webhook endpoint or broker needs.

<figure><img src="https://4017407078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfJn-9R_dn6dvcGNcdk%2Fuploads%2Fgit-blob-281eda1746d01e9565c10df33d1975f9ba0ab1e6%2F01-batch.png?alt=media" alt="A cron schedule, a Sync now button, and an API trigger all start an integration run, which exchanges data with the platform API and your API"><figcaption></figcaption></figure>

## How it works on Pandium

An integration script is a [POSIX-compliant CLI application](https://docs.pandium.com/getting-started/anatomy-of-an-integration.md) that reads tenant configuration and connector secrets from [environment variables](https://docs.pandium.com/getting-started/anatomy-of-an-integration/environment-variables.md), and can pass state forward to its next run through its [context](https://docs.pandium.com/getting-started/anatomy-of-an-integration/environment-variables/stdout.md). Pandium supports four ways to kick that script off, described in full on [Run Triggers](https://docs.pandium.com/getting-started/anatomy-of-an-integration/run-triggers.md):

* **Cron.** Runs on a schedule you set, per integration or per tenant, anywhere from once a minute to once a month. Cron runs are queued separately from manual, webhook, and API runs and are given priority, so scheduled syncs do not fall behind on-demand activity.
* **Manual.** A user clicks a sync button in the Integration Hub or the In-App Marketplace.
* **API.** You trigger a run yourself from the [Pandium API](https://docs.pandium.com/reference/pandium-api.md), as part of a workflow you design. An API trigger can carry a payload that your script reads from the run triggers.
* **Webhook.** Covered separately, since it is its own pattern. See [Webhooks](https://docs.pandium.com/getting-started/integration-patterns/webhooks.md).

Runs are debounced per tenant. If a new trigger comes in while that tenant is already mid-run, Pandium bundles it into a new run that starts when the current one finishes, rather than starting a second, overlapping run.

Each run starts with a fresh container, does its work, writes its context, and exits. There is no long-lived process to keep healthy between runs.

## Strengths and trade-offs

Batch is simple to build and reason about. Runs are retryable and easy to make idempotent, and backfilling history is just another run with a wider window. There is no always-on infrastructure sitting in the critical path.

The trade-off is latency. Data is only as fresh as the last run. With a one-minute schedule and lean logic that is close enough to real time for most purposes. It is still the wrong pattern for anything where a user is actively waiting on the result, like a checkout page.

To get the most out of batch, make each run idempotent: running it twice over the same window should produce the same result. That is what makes retries, reruns, and backfills safe, and it is what lets you run on a tight schedule without worrying about overlapping work.

## When to use it

Use batch when a delay of a minute or more is good enough, and you want a pattern that scales cleanly across any number of tenants without added infrastructure. It works across any tool and any industry. Sync schedules are configured per integration or per tenant, as described in the [FAQ](https://docs.pandium.com/reference/faq.md#does-pandium-support-batch-polling-style-integrations).

## Real-world examples

* An ecommerce store syncing the day's orders into a tax or accounting platform overnight
* A B2B app pushing new CRM contacts into a marketing tool every minute
* A support tool mirroring ticket status changes into a CRM every few minutes, fast enough that nobody notices the gap
* A retailer reconciling inventory counts between a warehouse system and its storefront
* Loading a customer's full history the day they connect, before switching to incremental runs

## Related reading

* [Run Triggers](https://docs.pandium.com/getting-started/anatomy-of-an-integration/run-triggers.md)
* [Pandium API](https://docs.pandium.com/reference/pandium-api.md)
* [Webhooks](https://docs.pandium.com/getting-started/integration-patterns/webhooks.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pandium.com/getting-started/integration-patterns/batch-and-api-triggered-syncs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
