> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usebracket.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting Firestore

> Follow these steps to sync an existing Firebase Cloud Firestore collection

<Warning>Firestore is currently only available on Bracket's [legacy app](https://legacy.app.usebracket.com/)</Warning>

## Getting your Firestore project ID

There are three different ways to get your Firestore project ID:

1. **Using the Firebase console**: Click settings Project settings. The project ID is displayed in the top pane.
2. **Using the Firebase CLI**: Run `firebase projects:list`. The project ID is displayed along with all the Firebase projects associated with your account.
3. **Using the Firebase Management REST API**: Call `projects.list`. The response body contains the project ID in the `FirebaseProject` object.

## Generating private keys for a service account

1. Navigate to your project's console

2. Go to Project Settings by clicking the icon

<Example>
  <img class="rounded-md h-32" src="https://mintcdn.com/bracket/1whZePpi8DloDf7s/img/firebase-1.png?fit=max&auto=format&n=1whZePpi8DloDf7s&q=85&s=f64d51efae0d21fbbae5ef50ef48c6a6" width="518" height="312" data-path="img/firebase-1.png" />
</Example>

3. Click `Service accounts`

4. Generate a new private key by clicking on `Generate new private key` and open the newly-created JSON

<Example>
  <img class="rounded-md w-full" src="https://mintcdn.com/bracket/1whZePpi8DloDf7s/img/firebase-2.png?fit=max&auto=format&n=1whZePpi8DloDf7s&q=85&s=a9c8e7164074434d4b39450372615de7" width="3840" height="1884" data-path="img/firebase-2.png" />
</Example>

<Tip>The private key should begin with `-----BEGIN PRIVATE KEY-----` and end with `\\n-----END PRIVATE KEY-----\\n`</Tip>

## Getting the client email for a service account

The JSON that you created by generating a private key (above) will include a `client_email` field. Paste that in the Bracket web app.

<Warning>This is not a personal email address</Warning>

## Getting the collection path

In Firestore, data is organized in an alternating hierarchy of `collection/document/collection/document`. You can read about this hierarchy [here](https://firebase.google.com/docs/firestore/data-model#hierarchical-data).

This means that a collection path should always have an odd number of elements. In the example below, `mycoll` and `mycoll/mydoc/mysubcoll` are both valid collection paths.

<Example>
  <img class="rounded-md w-full" src="https://mintcdn.com/bracket/1whZePpi8DloDf7s/img/firestore_collection_path_example.png?fit=max&auto=format&n=1whZePpi8DloDf7s&q=85&s=28c8f20eb478b8ea80407bde4bc55d1c" width="479" height="291" data-path="img/firestore_collection_path_example.png" />
</Example>

## Collection groups

Firestore collection groups allow you to run queries over multiple related collections at once (you can read more [here](https://firebase.blog/posts/2019/06/understanding-collection-group-queries)). If the collection path refers to collection group, then check this box.
