> ## 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.

# GetTask

> Select the highest-priority task at a stage type and lock it with the GetTask method of the ABBYY FlexiCapture Web Services API, returning the task ID.

## What it does

Selects the task with the highest priority and opens it for processing. The selected task is locked (i.e. cannot be opened by other users).

<Note>
  If there is no suitable task, "0" is returned.
</Note>

<Warning>
  A task must be opened before any actions on the task can be performed!
</Warning>

## Definition

```
int GetTask( int sessionId, int projectId, int stageType, bool onlyPreprocessedTask, bool onlyPrivateBatches );
```

## 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>Project ID</p></td></tr><tr><td><p>stageType</p></td><td><p>int</p></td><td><p>The ID of the stage type. See <a href="/flexi-capture/api/structures/t-processing-stage-type">ProcessingStage</a> for possible values.</p></td></tr><tr><td><p>onlyPreprocessedTask</p></td><td><p>bool</p></td><td><p>The flag which determines from which tasks to select. Possible values:</p><ul><li><strong>True</strong> - select only pre-processed tasks;</li><li><strong>False</strong> - select from all tasks.</li></ul></td></tr><tr><td><p>onlyPrivateBatches</p></td><td><p>bool</p></td><td><p>The flag which determines the set of available batches. Possible values:</p><ul><li><strong>True</strong> - only batches that belong the current user or user group are available;</li><li><strong>False</strong> - all batches are available.</li></ul></td></tr></tbody></table>

## Returned value

| **Type** | **Description** |
| -------- | --------------- |
| int      | Task ID         |
