- [Resource: Document](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents#Document)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents#Document.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents#METHODS_SUMMARY)

## Resource: Document

A knowledge document to be used by a `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases#KnowledgeBase`.

For more information, see the [knowledge base guide](https://cloud.google.com/dialogflow/docs/how/knowledge-bases).

Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use `projects.knowledgeBases.documents`.

| JSON representation |
|---|
| ``` { "name": string, "displayName": string, "mimeType": string, "knowledgeTypes": [ enum (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases.documents#Document.KnowledgeType`) ], "enableAutoReload": boolean, "latestReloadStatus": { object (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases.documents#Document.ReloadStatus`) }, "metadata": { string: string, ... }, "state": enum (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases.documents#Document.State`), // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "contentUri": string, "content": string, "rawContent": string // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `name` | `string` Optional. The document resource name. The name must be empty when creating a document. Format: `projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`. |
| `displayName` | `string` Required. The display name of the document. The name must be 1024 bytes or less; otherwise, the creation request fails. |
| `mimeType` | `string` Required. The MIME type of this document. |
| `knowledgeTypes[]` | ``enum (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases.documents#Document.KnowledgeType`)`` Required. The knowledge type of document content. |
| `enableAutoReload` | `boolean` Optional. If true, we try to automatically reload the document every day (at a time picked by the system). If false or unspecified, we don't try to automatically reload the document. Currently you can only enable automatic reload for documents sourced from a public url, see `source` field for the source types. Reload status can be tracked in `latestReloadStatus`. If a reload fails, we will keep the document unchanged. If a reload fails with internal errors, the system will try to reload the document on the next day. If a reload fails with non-retriable errors (e.g. PERMISSION_DENIED), the system will not try to reload the document anymore. You need to manually reload the document successfully by calling `documents.reload` and clear the errors. |
| `latestReloadStatus` | ``object (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases.documents#Document.ReloadStatus`)`` Output only. The time and status of the latest reload. This reload may have been triggered automatically or manually and may not have succeeded. |
| `metadata` | `map (key: string, value: string)` Optional. Metadata for the document. The metadata supports arbitrary key-value pairs. Suggested use cases include storing a document's title, an external URL distinct from the document's contentUri, etc. The max size of a `key` or a `value` of the metadata is 1024 bytes. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `state` | ``enum (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.agent.knowledgeBases.documents#Document.State`)`` Output only. The current state of the document. |
| The source of this document. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `contentUri` | `string` The URI where the file content is located. For documents stored in Google Cloud Storage, these URIs must have the form `gs://<bucket-name>/<object-name>`. NOTE: External URLs must correspond to public webpages, i.e., they must be indexed by Google Search. In particular, URLs for showing documents in Google Cloud Storage (i.e. the URL in your browser) are not supported. Instead use the `gs://` format URI described above. |
| `content (deprecated)` | `string` > [!WARNING] > This item is deprecated! The raw content of the document. This field is only permitted for EXTRACTIVE_QA and FAQ knowledge types. Note: This field is in the process of being deprecated, please use rawContent instead. |
| `rawContent` | `string (https://developers.google.com/discovery/v1/type-format format)` The raw content of the document. This field is only permitted for EXTRACTIVE_QA and FAQ knowledge types. A base64-encoded string. |
| End of mutually exclusive fields. ||

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/create` | Creates a new document. |
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/delete` | Deletes the specified document. |
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/get` | Retrieves the specified document. |
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/import` | Create documents by importing data from external sources. |
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/list` | Returns the list of all documents of the knowledge base. |
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/patch` | Updates the specified document. |
| ### `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/projects.knowledgeBases.documents/reload` | Reloads the specified document from its specified source, content_uri or content. |