If your Firestore data is in a different project than your
Agentspace project, go to Set up Firestore
access.
Set up Firestore access from a different project
To give Agentspace access to Firestore data that's
in a different project, follow these steps:
Replace the following PROJECT_NUMBER variable with your
Agentspace project number, and then copy the contents of this
code block. This is your Agentspace service account
identifier:
Specify the project ID, database ID, and collection ID of the data that you
plan to import.
Click Continue.
Choose a region for your data store.
Enter a name for your data store.
Click Create.
To check the status of your ingestion, go to the Data Stores page
and click your data store name to see details about it on its Data page.
When the status column on the Activity tab changes from In progress
to Import completed, the ingestion is complete.
Depending on the size of your data, ingestion can take several
minutes or several hours.
REST
To use the command line to create a data store and ingest data from
Firestore, follow these steps:
DATA_STORE_ID: the ID of the data store. The ID can
contain only lowercase letters, digits, underscores, and hyphens.
FIRESTORE_PROJECT_ID: the ID of your
Firestore project.
DATABASE_ID: the ID of your Firestore
database.
COLLECTION_ID: the ID of your Firestore
collection.
RECONCILIATION_MODE: optional. Values are FULL and
INCREMENTAL. Default is INCREMENTAL. Specifying INCREMENTAL
causes an incremental refresh of data from Firestore to your
data store. This does an upsert operation, which adds new documents and
replaces existing documents with updated documents with the same ID.
Specifying FULL causes a full rebase of the documents in your data store. In other words, new and updated documents are added to your data store, and documents that are not in Firestore are removed
from your data store. The FULL mode is helpful if you want to
automatically delete documents that you no longer need.
AUTO_GENERATE_IDS: optional. Specifies whether to
automatically generate document IDs. If set to true, document IDs
are generated based on a hash of the payload. Note that generated
document IDs might not remain consistent over multiple imports. If
you auto-generate IDs over multiple imports, Google highly
recommends setting reconciliationMode to FULL to maintain
consistent document IDs.
ID_FIELD: optional. Specifies which fields are the
document IDs.
Next steps
To attach your data store to an app, create an app and select your data store
following the steps in
Create a search app.
To preview how your search results appear after your app and data store are
set up, see
Preview search results.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[],[],null,["# Sync from Firestore\n\nTo ingest data from Firestore, use the following steps to create\na data store and ingest data using either the Google Cloud console or the API.\n\nIf your Firestore data is in the same project as\nAgentspace, go to [Import data from\nFirestore](#firestore-procedure).\n\nIf your Firestore data is in a different project than your\nAgentspace project, go to [Set up Firestore\naccess](#set-up-firestore-access).\n\nSet up Firestore access from a different project\n------------------------------------------------\n\nTo give Agentspace access to Firestore data that's\nin a different project, follow these steps:\n\n1. Replace the following \u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e variable with your\n Agentspace project number, and then copy the contents of this\n code block. This is your Agentspace service account\n identifier:\n\n service-\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e@gcp-sa-discoveryengine.iam.gserviceaccount.com\n\n2. Go to the **IAM \\& Admin** page.\n\n [IAM \\& Admin](https://console.cloud.google.com/iam-admin/iam)\n3. Switch to your Firestore project on the **IAM \\& Admin** page\n and click **Grant Access**.\n\n4. For **New principals** , enter the instance's service account identifier and\n select the **Datastore \\\u003e Cloud Datastore Import Export Admin** role.\n\n5. Click **Save**.\n\n6. Switch back to your Agentspace project.\n\nNext, go to [Import data from Firestore](#firestore-procedure).\n\nImport data from Firestore\n--------------------------\n\n### Console\n\nTo use the console to ingest data from Firestore, follow these\nsteps:\n\n1. In the Google Cloud console, go to the **Agentspace** page.\n\n [Agentspace](https://console.cloud.google.com/gen-app-builder/)\n2. Go to the **Data Stores** page.\n\n3. Click **New data store**.\n\n4. On the **Source** page, select **Firestore**.\n\n5. Specify the project ID, database ID, and collection ID of the data that you\n plan to import.\n\n6. Click **Continue**.\n\n7. Choose a region for your data store.\n\n8. Enter a name for your data store.\n\n9. Click **Create**.\n\n10. To check the status of your ingestion, go to the **Data Stores** page\n and click your data store name to see details about it on its **Data** page.\n When the status column on the **Activity** tab changes from **In progress**\n to **Import completed**, the ingestion is complete.\n\n Depending on the size of your data, ingestion can take several\n minutes or several hours.\n\n### REST\n\nTo use the command line to create a data store and ingest data from\nFirestore, follow these steps:\n\n1. Create a data store.\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n -H \"X-Goog-User-Project: \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\" \\\n \"https://discoveryengine.googleapis.com/v1alpha/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/dataStores?dataStoreId=\u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e\" \\\n -d '{\n \"displayName\": \"\u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e\",\n \"industryVertical\": \"GENERIC\",\n \"solutionTypes\": [\"SOLUTION_TYPE_SEARCH\"],\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your project.\n - \u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e: the ID of the data store. The ID can contain only lowercase letters, digits, underscores, and hyphens.\n - \u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e: the display name of the data store. This might be displayed in the Google Cloud console.\n2. Import data from Firestore.\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://discoveryengine.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/dataStores/\u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e/branches/0/documents:import\" \\\n -d '{\n \"firestoreSource\": {\n \"projectId\": \"\u003cvar translate=\"no\"\u003eFIRESTORE_PROJECT_ID\u003c/var\u003e\",\n \"databaseId\": \"\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e\",\n \"collectionId\": \"\u003cvar translate=\"no\"\u003eCOLLECTION_ID\u003c/var\u003e\",\n },\n \"reconciliationMode\": \"\u003cvar translate=\"no\"\u003eRECONCILIATION_MODE\u003c/var\u003e\",\n \"autoGenerateIds\": \"\u003cvar translate=\"no\"\u003eAUTO_GENERATE_IDS\u003c/var\u003e\",\n \"idField\": \"\u003cvar translate=\"no\"\u003eID_FIELD\u003c/var\u003e\",\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Agentspace project.\n - \u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e: the ID of the data store. The ID can contain only lowercase letters, digits, underscores, and hyphens.\n - \u003cvar translate=\"no\"\u003eFIRESTORE_PROJECT_ID\u003c/var\u003e: the ID of your Firestore project.\n - \u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e: the ID of your Firestore database.\n - \u003cvar translate=\"no\"\u003eCOLLECTION_ID\u003c/var\u003e: the ID of your Firestore collection.\n - \u003cvar translate=\"no\"\u003eRECONCILIATION_MODE\u003c/var\u003e: optional. Values are `FULL` and `INCREMENTAL`. Default is `INCREMENTAL`. Specifying `INCREMENTAL` causes an incremental refresh of data from Firestore to your data store. This does an upsert operation, which adds new documents and replaces existing documents with updated documents with the same ID. Specifying `FULL` causes a full rebase of the documents in your data store. In other words, new and updated documents are added to your data store, and documents that are not in Firestore are removed from your data store. The `FULL` mode is helpful if you want to automatically delete documents that you no longer need.\n - \u003cvar translate=\"no\"\u003eAUTO_GENERATE_IDS\u003c/var\u003e: optional. Specifies whether to automatically generate document IDs. If set to `true`, document IDs are generated based on a hash of the payload. Note that generated document IDs might not remain consistent over multiple imports. If you auto-generate IDs over multiple imports, Google highly recommends setting `reconciliationMode` to `FULL` to maintain consistent document IDs.\n - \u003cvar translate=\"no\"\u003eID_FIELD\u003c/var\u003e: optional. Specifies which fields are the document IDs.\n\n\u003cbr /\u003e\n\nNext steps\n----------\n\n- To attach your data store to an app, create an app and select your data store\n following the steps in\n [Create a search app](/agentspace/docs/create-app).\n\n- To preview how your search results appear after your app and data store are\n set up, see\n [Preview search results](/agentspace/docs/preview-search-results)."]]