> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/how-to/logic-and-flow/build-a-resumable-batch-flow.md). Agents can also search and read this documentation through its [MCP server](https://docs.appfarm.io/~gitbook/mcp).

# Build a resumable batch Flow

A batch job that stops halfway, for example because of a timeout or an error in an external system, should continue where it stopped when you run it again, without repeating work. This example sends a reminder email to a list of customers from a [Flow](https://docs.appfarm.io/reference/flows.md) action.

1. On the object class you process, add a marker property, for example `Reminder sent` (Datetime), and a `Reminder error` (String) property.
2. In the Flow action, use Read Objects with the filter `Reminder sent` has no value and `Reminder error` has no value, and set **Limit result**, for example 500.
3. Add a Foreach over the objects read.
4. Inside the Foreach, send the email. Then use Update Object to set `Reminder sent` to now, and Persist Objects for that object in the same iteration.
5. Add a Catch Exception as the last node inside the Foreach, below the steps it should guard, and select **Catch all** (or the exception types you expect). When a step in the iteration fails, the steps after it are skipped and the Catch Exception runs. Inside it, map the `message` key of the error to an action variable with **Result mapping**, set `Reminder error` on the object to that value, and persist it. The Foreach then continues with the next customer, so one failing customer doesn't stop the run.
6. Run the Flow again, or on a schedule, until the read returns no objects.

Because each customer is marked as soon as the email is sent, a run that stops halfway can be started again safely: it picks up only the customers that haven't been handled. Customers with `Reminder error` set are left out of later runs. Check them, then clear `Reminder error` to retry them.

{% hint style="info" %}
**Good to know**

A Catch Exception only handles errors from nodes above it in the same block. If it is placed before the send step, a failed send isn't caught there, and the error goes up to the enclosing block.
{% endhint %}


---

# 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.appfarm.io/how-to/logic-and-flow/build-a-resumable-batch-flow.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.
