# Method: documents.annotateText

- [HTTP request](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#body.HTTP_TEMPLATE)
- [Request body](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#body.AnnotateTextResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#body.aspect)
- [Features](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features)
  - [JSON representation](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features.SCHEMA_REPRESENTATION)
- [Try it!](https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#try-it)

A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and analyzeSyntax provide in one call.

### HTTP request

`POST https://language.googleapis.com/v1/documents:annotateText`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "document": { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents#Document`) }, "features": { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features`) }, "encodingType": enum (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/EncodingType`) } ``` |

| Fields ||
|---|---|
| `document` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents#Document`)`` Required. Input document. |
| `features` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features`)`` Required. The enabled features. |
| `encodingType` | ``enum (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/EncodingType`)`` The encoding type used by the API to calculate offsets. |

### Response body

The text annotations response message.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "sentences": [ { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Sentence`) } ], "tokens": [ { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Token`) } ], "entities": [ { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Entity`) } ], "documentSentiment": { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Sentiment`) }, "language": string, "categories": [ { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/ClassificationCategory`) } ], "moderationCategories": [ { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/ClassificationCategory`) } ] } ``` |

| Fields ||
|---|---|
| `sentences[]` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Sentence`)`` Sentences in the input document. Populated if the user enables `https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features.FIELDS.extract_syntax`. |
| `tokens[]` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Token`)`` Tokens, along with their syntactic information, in the input document. Populated if the user enables `https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features.FIELDS.extract_syntax`. |
| `entities[]` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Entity`)`` Entities, along with their semantic information, in the input document. Populated if the user enables `https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features.FIELDS.extract_entities`. |
| `documentSentiment` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/Sentiment`)`` The overall sentiment for the document. Populated if the user enables `https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#Features.FIELDS.extract_document_sentiment`. |
| `language` | `string` The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See `https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/documents#Document.FIELDS.language` field for more details. |
| `categories[]` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/ClassificationCategory`)`` Categories identified in the input document. |
| `moderationCategories[]` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/ClassificationCategory`)`` Harmful and sensitive categories identified in the input document. |

### Authorization scopes

Requires one of the following OAuth scopes:

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

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

## Features

All available features for sentiment, syntax, and semantic analysis. Setting each one to true will enable that specific analysis for the input.

| JSON representation |
|---|
| ``` { "extractSyntax": boolean, "extractEntities": boolean, "extractDocumentSentiment": boolean, "extractEntitySentiment": boolean, "classifyText": boolean, "moderateText": boolean, "classificationModelOptions": { object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/ClassificationModelOptions`) } } ``` |

| Fields ||
|---|---|
| `extractSyntax` | `boolean` Extract syntax information. |
| `extractEntities` | `boolean` Extract entities. |
| `extractDocumentSentiment` | `boolean` Extract document-level sentiment. |
| `extractEntitySentiment` | `boolean` Extract entities and their associated sentiment. |
| `classifyText` | `boolean` Classify the full document into categories. |
| `moderateText` | `boolean` Moderate the document for harmful and sensitive categories. |
| `classificationModelOptions` | ``object (`https://docs.cloud.google.com/natural-language/docs/reference/rest/v1/ClassificationModelOptions`)`` Optional. The model options to use for classification. Defaults to v1 options if not specified. Only used if `classifyText` is set to true. |