- [HTTP request](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#body.aspect)
- [Try it!](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.knowledgeBases.documents/import#try-it)

Creates documents by importing data from external sources. Dialogflow supports up to 350 documents in each request. If you try to import more, Dialogflow will return an error.

This method is a [long-running operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). The returned `Operation` type has the following method-specific fields:

- `metadata`: `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/KnowledgeOperationMetadata`
- `response`: `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/ImportDocumentsResponse`

### HTTP request

Choose an endpoint:
global   
`POST https://dialogflow.googleapis.com/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents:import`

<br />

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

**OR**

`POST https://{endpoint}/v2/{parent=projects/*/locations/*/knowledgeBases/*}/documents:import`

Where `{endpoint}` is one of the [supported service endpoints](https://docs.cloud.google.com/dialogflow/es/docs/reference/rest#rest_endpoints).

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

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The knowledge base to import documents into. Format: `projects/<Project ID>/locations/<Location ID>/knowledgeBases/<Knowledge Base ID>`. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `parent`: - `dialogflow.documents.create` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "documentTemplate": { object (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/ImportDocumentTemplate`) }, "importGcsCustomMetadata": boolean, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "gcsSource": { object (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.conversationDatasets#ConversationDataset.GcsSources`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `documentTemplate` | ``object (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/ImportDocumentTemplate`)`` Required. Document template used for importing all the documents. |
| `importGcsCustomMetadata` | `boolean` Whether to import custom metadata from Google Cloud Storage. Only valid when the document source is Google Cloud Storage URI. |
| Required. The source to use for importing documents. If the source captures multiple objects, then multiple documents will be created, one corresponding to each object, and all of these documents will be created using the same document template. Dialogflow supports up to 350 documents in each request. If you try to import more, Dialogflow will return an error. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `gcsSource` | ``object (`https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.conversationDatasets#ConversationDataset.GcsSources`)`` Optional. The Google Cloud Storage location for the documents. The path can include a wildcard. These URIs may have the forms `gs://<bucket-name>/<object-name>`. `gs://<bucket-name>/<object-path>/*.<extension>`. |
| End of mutually exclusive fields. ||

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.locations.operations#Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

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

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