# Method: files.asyncBatchAnnotate

- [HTTP request](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#body.HTTP_TEMPLATE)
- [Request body](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#body.response_body)
- [Authorization Scopes](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#body.aspect)
- [AsyncAnnotateFileRequest](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#AsyncAnnotateFileRequest)
  - [JSON representation](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#AsyncAnnotateFileRequest.SCHEMA_REPRESENTATION)
- [InputConfig](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#InputConfig)
  - [JSON representation](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#InputConfig.SCHEMA_REPRESENTATION)
- [GcsSource](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsSource)
  - [JSON representation](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsSource.SCHEMA_REPRESENTATION)
- [OutputConfig](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#OutputConfig)
  - [JSON representation](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#OutputConfig.SCHEMA_REPRESENTATION)
- [GcsDestination](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsDestination)
  - [JSON representation](https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsDestination.SCHEMA_REPRESENTATION)

Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).

### HTTP request

`POST https://vision.googleapis.com/v1p3beta1/files:asyncBatchAnnotate`

The URL uses [gRPC Transcoding](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation ||
|---|---|
| ``` { "requests": [ { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#AsyncAnnotateFileRequest`) } ] } ``` |

| Fields ||
|---|---|
| `requests[]` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#AsyncAnnotateFileRequest`)`` Individual async file annotation requests for this batch. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/vision/product-search/docs/reference/rest/Shared.Types/Operation`.

### Authorization Scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-platform`
- `https://www.googleapis.com/auth/cloud-vision`

For more information, see the [Authentication Overview](https://cloud.google.com/docs/authentication/).

## AsyncAnnotateFileRequest

An offline file annotation request.

| JSON representation ||
|---|---|
| ``` { "inputConfig": { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#InputConfig`) }, "features": [ { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/Feature`) } ], "imageContext": { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/ImageContext`) }, "outputConfig": { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#OutputConfig`) } } ``` |

| Fields ||
|---|---|
| `inputConfig` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#InputConfig`)`` Required. Information about the input file. |
| `features[]` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/Feature`)`` Required. Requested features. |
| `imageContext` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/ImageContext`)`` Additional context that may accompany the image(s) in the file. |
| `outputConfig` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#OutputConfig`)`` Required. The desired output location and metadata (e.g. format). |

## InputConfig

The desired input location and metadata.

| JSON representation ||
|---|---|
| ``` { "gcsSource": { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsSource`) }, "mimeType": string } ``` |

| Fields ||
|---|---|
| `gcsSource` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsSource`)`` The Google Cloud Storage location to read the input from. |
| `mimeType` | `string` The type of the file. Currently only "application/pdf" and "image/tiff" are supported. Wildcards are not supported. |

## GcsSource

The Google Cloud Storage location where the input will be read from.

| JSON representation ||
|---|---|
| ``` { "uri": string } ``` |

| Fields ||
|---|---|
| `uri` | `string` Google Cloud Storage URI for the input file. This must only be a Google Cloud Storage object. Wildcards are not currently supported. |

## OutputConfig

The desired output location and metadata.

| JSON representation ||
|---|---|
| ``` { "gcsDestination": { object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsDestination`) }, "batchSize": number } ``` |

| Fields ||
|---|---|
| `gcsDestination` | ``object(`https://docs.cloud.google.com/vision/product-search/docs/reference/rest/v1p3beta1/files/asyncBatchAnnotate#GcsDestination`)`` The Google Cloud Storage location to write the output(s) to. |
| `batchSize` | `number` The max number of response protos to put into each output JSON file on Google Cloud Storage. The valid range is \[1, 100\]. If not specified, the default value is 20. For example, for one pdf file with 100 pages, 100 response protos will be generated. If `batchSize` = 20, then 5 json files each containing 20 response protos will be written under the prefix `gcsDestination`.`uri`. Currently, batchSize only applies to GcsDestination, with potential future support for other output configurations. <br /> |

## GcsDestination

The Google Cloud Storage location where the output will be written to.

| JSON representation ||
|---|---|
| ``` { "uri": string } ``` |

| Fields ||
|---|---|
| `uri` | `string` Google Cloud Storage URI where the results will be stored. Results will be in JSON format and preceded by its corresponding input URI. This field can either represent a single file, or a prefix for multiple outputs. Prefixes must end in a `/`. Examples: - File: <gs://bucket-name/filename.json> - Prefix: <gs://bucket-name/prefix/here/> - File: <gs://bucket-name/prefix/here> If multiple outputs, each response is still AnnotateFileResponse, each of which contains some subset of the full list of AnnotateImageResponse. Multiple outputs can happen if, for example, the output JSON is too large and overflows into multiple sharded files. <br /> |