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

# GetFilteredBatches

> Request a filtered, paged set of batches with the GetFilteredBatches method of the ABBYY FlexiCapture Web Services API, using stage, date, and SLA filters.

## What it does

Requests a filtered set of batches from a server in groups. For example, you can send a request that looks as follows: "return 100 batches that are at the recognition stage starting from the 500th batch."

## Definition

```
int GetFilteredBatches(int sessionId, int projectId, int batchTypeId, int[] stageTypes, int[] stageExtIds, string name, int batchPurpose, long startDate, long stopDate, long slaDateBeginRange, long slaDateEndRange, int slaStateFlags, int firstRecord, int recordsCount, RegistrationProperty[] filterRegParams, out Batch[] batches)
```

## Parameters

<table width="100%"><tbody><tr><td><p><strong>Name</strong></p></td><td><p><strong>Type</strong></p></td><td><p><strong>Description</strong></p></td></tr><tr><td><p>sessionId</p></td><td><p>int</p></td><td><p>The ID of the connection to the Application Server</p></td></tr><tr><td><p>projectId</p></td><td><p>int</p></td><td><p>The ID of the project that contains the batch types about which information is to be retrieved</p></td></tr><tr><td><p>batchTypeId</p></td><td><p>int</p></td><td><p>The ID of the batch type</p><ul><li>0 - batch by default</li><li>-1 - all batch types</li></ul></td></tr><tr><td><p>stageTypes</p></td><td><p>int \[]</p></td><td><p>The set of stage types (for possible values, see <a href="/flexi-capture/api/structures/processing-stage">ProcessingStage</a>) that have the batches you are looking for</p><ul><li>Empty set - all batches</li><li>0 - batches that are not at any particular stage</li></ul></td></tr><tr><td><p>stageExtIds</p></td><td><p>int \[]</p></td><td><p>The set of stage IDs (the Id field in the <a href="/flexi-capture/api/structures/processing-stage">ProcessingStage</a> structure) that have the batches you are looking for</p><ul><li>Empty set - all batches</li><li>0 - batches that are not at any particular stage</li></ul></td></tr><tr><td><p>name</p></td><td><p>string</p></td><td><p>The prefix of the batch name. An empty line signifies that any names are allowed</p></td></tr><tr><td><p>batchPurpose</p></td><td><p>int</p></td><td><p>The purpose of the batch</p><p>Possible values:</p><ul><li>0 - batches with data</li><li>1 - batches for training Document Definition matching</li><li>2 - batches for training classifiers</li></ul></td></tr><tr><td><p>startDate</p></td><td><p>long</p></td><td><p>Batches that were created later than the specified date, 0 stands for all batches</p><p>For conversion, use the following methods (the example below is in C#):</p><pre><code>DateTime dtTime;
long lTime;
...
// conversion from DataTime to long
dTime = DataTime.FromFileTime(lTime);
...
// conversion from long to DataTime
lTime = dTime.ToFileTime();</code></pre></td></tr><tr><td><p>stopDate</p></td><td><p>long</p></td><td><p>Batches that were created not earlier than the specified date, 0 stands for all batches</p><p>For conversion, use the following methods (the example below is in C#):</p><pre><code>DateTime dtTime;
long lTime;
...
// conversion from DataTime to long
dTime = DataTime.FromFileTime(lTime);
...
// conversion from long to DataTime
lTime = dTime.ToFileTime();</code></pre></td></tr><tr><td><p>slaDateBeginRange</p></td><td><p>long</p></td><td><p>Batches with the processing end date under an SLA not earlier than the specified date, 0 stands for all batches</p><p>For conversion, use the following methods (the example below is in C#):</p><pre><code>DateTime dtTime;
long lTime;
...
// conversion from DataTime to long
dTime = DataTime.FromFileTime(lTime);
...
// conversion from long to DataTime
lTime = dTime.ToFileTime();</code></pre></td></tr><tr><td><p>slaDateEndRange</p></td><td><p>long</p></td><td><p>Batches with the processing end date under an SLA not later than the specified date, 0 stands for all batches</p><p>For conversion, use the following methods (the example below is in C#):</p><pre><code>DateTime dtTime;
long lTime;
...
// conversion from DataTime to long
dTime = DataTime.FromFileTime(lTime);
...
// conversion from long to DataTime
lTime = dTime.ToFileTime();</code></pre></td></tr><tr><td><p>slaStateFlags</p></td><td><p>int</p></td><td><p>Contains a warning about a batch processing deadline</p><p>The following values or their logical sum (OR) is admissible:</p><ul><li>0 - batches are not filtered by this attribute</li><li>1 - batches without a specified processing deadline</li><li>2 - batches with a processing deadline that is neither approaching nor approached</li><li>4 - batches with an approaching processing deadline</li><li>8 - batches with an approached processing deadline</li></ul></td></tr><tr><td><p>firstRecord</p></td><td><p>int</p></td><td><p>The first record in the list</p><p>(Records are numbered starting from the zero element)</p></td></tr><tr><td><p>recordsCount</p></td><td><p>int</p></td><td><p>The number of batches that a user tries to obtain</p></td></tr><tr><td><p>filterRegParams</p></td><td><p><a href="/flexi-capture/api/structures/registration-property">RegistrationProperty</a>\[]</p></td><td><p>The set of "name–value" pairs that is used to filter by registration parameters</p><p>(It is permitted to send only 5 value pairs, other pairs will be ignored)</p></td></tr></tbody></table>

<Note>
  Batches are sorted in the descending order of IDs, meaning that the latest batches are returned at the top of the list.
</Note>

## Returned value

| **Type**                                                       | **Description**                                                                             |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| int                                                            | The number of batches on the server that match the specified filter criteria                |
| [Batch](/flexi-capture/api/structures/batch-api-structures)\[] | The set of completed [Batch](/flexi-capture/api/structures/batch-api-structures) structures |
