Sync Rest API jobs with pagination

Recipe ToolsMarketingDeveloper ToolAPI Integration

What it does

When the clock triggers on a 5-minute schedule, this automation fetches all jobs from the Rest API in batches. It loops through paginated results and builds a complete jobs list with each request offset.

Who it's for

Engineering teams who need to retrieve all paginated jobs from an API into a single list for monitoring or reporting.

How teams use this

Monitor all jobs in one place

Fetch every job from the Rest API every 5 minutes and store them in a list for dashboards or alerts. The team sees the full job inventory without querying the API manually each time.

Track job performance across batches

Use the complete jobs list to analyze execution times, failure rates, or status trends across all batches. Only the downstream analysis changes while the sync stays the same.

Filter jobs by status or ID

Add a condition after the list is built to only keep jobs matching a specific status or ID. The pagination logic stays intact and only the final list is filtered based on your criteria.

How it works

  1. Trigger every 5 minutes. The Clock app runs this automation on a 5-minute schedule to keep the jobs list current and synchronized with the API.
  2. Request the first batch of jobs. Send a request via Rest to fetch the first 1,000 jobs and retrieve the total job count so the automation knows how many batches to retrieve in subsequent loops.
  3. Loop through remaining job batches. For each batch needed based on the total count, send a request via Rest with an updated offset to fetch the next set of jobs and add them to the jobs list.
  4. Build the complete jobs list. Combine all batches into a single jobs list that contains every job from the Rest API, with the offset variable updated after each loop iteration so pagination continues correctly.