> ## AI Agent Context > Get the complete documentation index at: https://aistudio.google.com/llms.txt > Use this file to discover all available pages. > For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt # Importing a file {% mark class="http-post" %}{% icon name="north_east" /%}`POST`{% /mark %} `https://generativelanguage.googleapis.com/v1beta/fileSearchStores/{fileSearchStore}:importFile` Imports a `File` from File Service to a [`FileSearchStore`](/api-reference/file-search/file-search-stores#Resource:FileSearchStore). {% two-column-layout %} {% left-column %} ## Parameters {% class="hide-from-toc" id="parameters" %} {% section class="api-ref-property-list" %} **fileSearchStore**: {% mark %}required{% /mark %} `string` The file search store ID. Forms the resource name `fileSearchStores/{fileSearchStore}`. {% /section %} ## Request Body {% class="hide-from-toc" id="request-body" %} {% section class="api-ref-property-list" %} **fileName**: {% mark %}required{% /mark %} `string` The name of the `File` to import. Example: `files/abc-123` {% hr /%} {% details %} {% summary %} **customMetadata**: `CustomMetadata array` Custom metadata to be associated with the file. {% /summary %} **key**: {% mark %}required{% /mark %} `string` The key of the metadata to store. {% details %} {% summary %} **value**: `Union type` {% /summary %} Union field `value` can be only one of the following: **stringValue**: `string` The string value of the metadata to store. {% details %} {% summary %} **stringListValue**: `StringList` The StringList value of the metadata to store. {% /summary %} **values**: `string array` The string values of the metadata to store. {% /details %} **numericValue**: `number` The numeric value of the metadata to store. {% /details %} {% /details %} {% hr /%} {% details %} {% summary %} **chunkingConfig**: `ChunkingConfig` Optional. Config for telling the service how to chunk the file. If not provided, the service will use default parameters. {% /summary %} {% details %} {% summary %} **config**: `Union type` The chunking configuration to use. {% /summary %} Union field `config` can be only one of the following: {% details %} {% summary %} **whiteSpaceConfig**: `WhiteSpaceConfig` White space chunking configuration. {% /summary %} **maxTokensPerChunk**: `integer` Maximum number of tokens per chunk. Tokens are defined as words for this chunking algorithm. Note: we are defining tokens as words split by whitespace as opposed to the output of a tokenizer. The context window of the latest gemini embedding model as of 2025-04-17 is currently 8192 tokens. We assume that the average word is 5 characters. Therefore, we set the upper limit to 2**9, which is 512 words, or 2560 tokens, assuming worst case a character per token. This is a conservative estimate meant to prevent context window overflow. **maxOverlapTokens**: `integer` Maximum number of overlapping tokens between two adjacent chunks. {% /details %} {% /details %} {% /details %} {% /section %} {% /left-column %} {% right-column class="sticky" %} **Example request** {% class="example-heading" %} {% tabs %} {% tab label="REST" %} ```sh curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/$FILE_SEARCH_STORE_ID:importFile" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "fileName": "string" }' ``` {% /tab %} {% /tabs %} {% /right-column %} {% /two-column-layout %} {% two-column-layout %} {% left-column %} ## Response {% class="hide-from-toc" id="response" %} {% section class="api-ref-property-list" %} {% details %} {% summary %} **error**: `Status` The error result of the operation in case of failure or cancellation. {% /summary %} **code**: `integer` The status code, which should be an enum value of google.rpc.Code. **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. **details**: `object array` A list of messages that carry the error details. There is a common set of message types for APIs to use. {% /details %} {% hr /%} {% details %} {% summary %} **response**: `ImportFileResponse` {% /summary %} **parent**: `string` The name of the [`FileSearchStore`](/api-reference/file-search/file-search-stores#Resource:FileSearchStore) containing `Document`s. Example: `fileSearchStores/my-file-search-store-123` **documentName**: `string` Immutable. Identifier. The identifier for the `Document` imported. Example: `fileSearchStores/my-file-search-store-123/documents/my-awesome-doc-123a456b789c` {% /details %} {% hr /%} **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}`. {% hr /%} {% details %} {% summary %} **metadata**: `ImportFileMetadata` {% /summary %} {% /details %} {% hr /%} **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. {% /section %} {% /left-column %} {% right-column class="sticky" %} **Example response** {% class="example-heading" %} ```json { "error": { "code": 0, "message": "string", "details": [ {} ] }, "response": { "parent": "string", "documentName": "string" }, "name": "string", "metadata": {}, "done": true } ``` {% /right-column %} {% /two-column-layout %}