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

# AddNewDocumentEx

> Add a document from an image file to a FlexiCapture batch with the AddNewDocumentEx Web Services API method.

## What it does

Adds a new document from an image file into a batch. This method replaces the [AddNewDocument](/flexi-capture/api/methods/add-new-document) method from the previous version of the Web Services API.

The added documents become accessible only after their images are pre-processed. Use the [ProcessBatch](/flexi-capture/api/methods/process-batch) method to start image pre-processing after you add the documents.

## Definition

```csharp theme={null}
int AddNewDocumentEx(int sessionId, int batchId, DocumentEx document, File file, bool excludeFromAutomaticAssembling);
```

## Parameters

| Name                             | Type                                                    | Description                                                                                                                                                                                                                                                                        |
| -------------------------------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sessionId`                      | `int`                                                   | The ID of the connection to the Application Server                                                                                                                                                                                                                                 |
| `batchId`                        | `int`                                                   | The ID of the batch into which a document is to be added                                                                                                                                                                                                                           |
| `document`                       | [DocumentEx](/flexi-capture/api/structures/document-ex) | A description of the document that is being created                                                                                                                                                                                                                                |
| `file`                           | [File](/flexi-capture/api/structures/file)              | The file that contains the document image. To create an empty document, leave the `file` parameter empty (`file.Name = ""`, `file.Bytes = new bytes [0]`).                                                                                                                         |
| `excludeFromAutomaticAssembling` | `bool`                                                  | A flag that shows whether the document is excluded from document assembly. Possible values: `True` (the document has already been assembled and is not included in document assembly), `False` (the document is assembled according to the settings specified for the batch type). |

## Add a document image with a POST request

You can also use a [POST request](/flexi-capture/api/files/files) to add a document image. Create a document with an empty file using this method (`file.Name = "FileName"`, `file.Bytes = new bytes [0]`).

Then execute a POST request with the following parameters:

* `Action = Save`
* `objectType = 0`
* `objectId = documentId`, where `documentId` is the document ID returned by the `AddNewDocumentEx` method
* `version = 0`
* `streamName = "FileName"`, where `FileName` is the name of the file specified when calling the `AddNewDocumentEx` method

## Returned value

| Type  | Description                    |
| ----- | ------------------------------ |
| `int` | The ID of the created document |
