---
title: "POST /v1/projects/{projectsId}/files:asyncBatchAnnotate"
method: POST
path: "/v1/projects/{projectsId}/files:asyncBatchAnnotate"
tags: ["projects"]
---

# POST /v1/projects/{projectsId}/files:asyncBatchAnnotate

`POST /v1/projects/{projectsId}/files:asyncBatchAnnotate`

## Request

- Base URL: `https://vision.googleapis.com`
- URL: `https://vision.googleapis.com/v1/projects/{projectsId}/files:asyncBatchAnnotate`
- Auth: one of:
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/cloud-platform`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/cloud-platform`
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/cloud-vision`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/cloud-vision`

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

## Path parameters

- `projectsId` string, required

## Query parameters

- `$.xgafv` '1' | '2'
- `access_token` string
- `alt` 'json' | 'media' | 'proto'
- `callback` string
- `fields` string
- `key` string
- `oauth_token` string
- `prettyPrint` boolean
- `quotaUser` string
- `uploadType` string
- `upload_protocol` string

## Request body

- AsyncBatchAnnotateFilesRequest: Multiple async file annotation requests are batched into a single service call.
  - `labels` object: Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.
  - `parent` string: Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
  - `requests` AsyncAnnotateFileRequest[]: Required. Individual async file annotation requests for this batch.
    - `features` Feature[]: Required. Requested features.
      - `maxResults` integer: Maximum number of results of this type. Does not apply to `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`.
      - `model` string: Model to use for the feature. Supported values: "builtin/stable" (the default if unset) and "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also support "builtin/rc" for the latest release candidate.
      - `type` 'TYPE_UNSPECIFIED' | 'FACE_DETECTION' | 'LANDMARK_DETECTION' | 'LOGO_DETECTION' | 'LABEL_DETECTION' | 'TEXT_DETECTION' | 'DOCUMENT_TEXT_DETECTION' | 'SAFE_SEARCH_DETECTION' | 'IMAGE_PROPERTIES' | 'CROP_HINTS' | 'WEB_DETECTION' | 'PRODUCT_SEARCH' | 'OBJECT_LOCALIZATION': The feature type.
    - `imageContext` ImageContext: Image context and/or feature-specific parameters.
      - `cropHintsParams` CropHintsParams: Parameters for crop hints annotation request.
        - `aspectRatios` number[]: Aspect ratios in floats, representing the ratio of the width to the height of the image. For example, if the desired aspect ratio is 4/3, the corresponding float value should be 1.33333. If not specified, the best possible crop is returned. The number of provided aspect ratios is limited to a maximum of 16; any aspect ratios provided after the 16th are ignored.
      - `languageHints` string[]: List of languages to use for TEXT_DETECTION. In most cases, an empty value yields the best results since it enables automatic language detection. For languages based on the Latin alphabet, setting `language_hints` is not needed. In rare cases, when the language of the text in the image is known, setting a hint will help get better results (although it will be a significant hindrance if the hint is wrong). Text detection returns an error if one or more of the specified languages is not one of the [supported languages](https://cloud.google.com/vision/docs/languages).
      - `latLongRect` LatLongRect: Rectangle determined by min and max `LatLng` pairs.
        - `maxLatLng` LatLng: An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
          - `latitude` number, double: The latitude in degrees. It must be in the range [-90.0, +90.0].
          - `longitude` number, double: The longitude in degrees. It must be in the range [-180.0, +180.0].
        - `minLatLng` LatLng: An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
          - `latitude` number, double: The latitude in degrees. It must be in the range [-90.0, +90.0].
          - `longitude` number, double: The longitude in degrees. It must be in the range [-180.0, +180.0].
      - `productSearchParams` ProductSearchParams: Parameters for a product search request.
        - `boundingPoly` BoundingPoly: A bounding polygon for the detected image annotation.
          - `normalizedVertices` NormalizedVertex[]: The bounding polygon normalized vertices.
            - `x` number, float: X coordinate.
            - `y` number, float: Y coordinate.
          - `vertices` Vertex[]: The bounding polygon vertices.
            - `x` integer: X coordinate.
            - `y` integer: Y coordinate.
        - `filter` string: The filtering expression. This can be used to restrict search results based on Product labels. We currently support an AND of OR of key-value expressions, where each expression within an OR must have the same key. An '=' should be used to connect the key and value. For example, "(color = red OR color = blue) AND brand = Google" is acceptable, but "(color = red OR brand = Google)" is not acceptable. "color: red" is not acceptable because it uses a ':' instead of an '='.
        - `productCategories` string[]: The list of product categories to search in. Currently, we only consider the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1", or "general-v1" should be specified. The legacy categories "homegoods", "apparel", and "toys" are still supported but will be deprecated. For new products, please use "homegoods-v2", "apparel-v2", or "toys-v2" for better product search accuracy. It is recommended to migrate existing products to these categories as well.
        - `productSet` string: The resource name of a ProductSet to be searched for similar images. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
      - `textDetectionParams` TextDetectionParams: Parameters for text detections. This is used to control TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
        - `advancedOcrOptions` string[]: A list of advanced OCR options to further fine-tune OCR behavior. Current valid values are: - `legacy_layout`: a heuristics layout detection algorithm, which serves as an alternative to the current ML-based layout detection algorithm. Customers can choose the best suitable layout algorithm based on their situation.
        - `enableTextDetectionConfidenceScore` boolean: By default, Cloud Vision API only includes confidence score for DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence score for TEXT_DETECTION as well.
      - `webDetectionParams` WebDetectionParams: Parameters for web detection request.
        - `includeGeoResults` boolean: This field has no effect on results.
    - `inputConfig` InputConfig: The desired input location and metadata.
      - `content` string, byte: File content, represented as a stream of bytes. Note: As with all `bytes` fields, protobuffers use a pure binary representation, whereas JSON representations use base64. Currently, this field only works for BatchAnnotateFiles requests. It does not work for AsyncBatchAnnotateFiles requests.
      - `gcsSource` GcsSource: The Google Cloud Storage location where the input will be read from.
        - `uri` string: Google Cloud Storage URI for the input file. This must only be a Google Cloud Storage object. Wildcards are not currently supported.
      - `mimeType` string: The type of the file. Currently only "application/pdf", "image/tiff" and "image/gif" are supported. Wildcards are not supported.
    - `outputConfig` OutputConfig: The desired output location and metadata.
      - `batchSize` integer: 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 `batch_size` = 20, then 5 json files each containing 20 response protos will be written under the prefix `gcs_destination`.`uri`. Currently, batch_size only applies to GcsDestination, with potential future support for other output configurations.
      - `gcsDestination` GcsDestination: The Google Cloud Storage location where the output will be written to.
        - `uri` string: Google Cloud Storage URI prefix where the results will be stored. Results will be in JSON format and preceded by its corresponding input URI prefix. This field can either represent a gcs file prefix or gcs directory. In either case, the uri should be unique because in order to get all of the output files, you will need to do a wildcard gcs search on the uri prefix you provide. Examples: * File Prefix: gs://bucket-name/here/filenameprefix The output files will be created in gs://bucket-name/here/ and the names of the output files will begin with "filenameprefix". * Directory Prefix: gs://bucket-name/some/location/ The output files will be created in gs://bucket-name/some/location/ and the names of the output files could be anything because there was no filename prefix specified. 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.

## Response `200`

Successful response

- Operation: This resource represents a long-running operation that is the result of a network API call.
  - `done` boolean: If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
  - `error` Status: The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
    - `code` integer: The status code, which should be an enum value of google.rpc.Code.
    - `details` object[]: A list of messages that carry the error details. There is a common set of message types for APIs to use.
    - `message` string: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
  - `metadata` object: Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
  - `name` string: The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
  - `response` object: The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.

---

[API](https://skmtc.dev/google/apis/vision.md) - [All operations](https://skmtc.dev/google/apis/vision/llms.txt) - [OpenAPI document](https://skmtc.dev/google/apis/vision/revisions/de4bfcc729b8?raw)
