> For the complete documentation index, see [llms.txt](https://rocket-networking.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rocket-networking.gitbook.io/docs/api/database.md).

# Database

##

## Introduction

The Rocket Networking API allows users to interact with their database, which is backed by Firebase Firestore. To access the API, use the following base URL:

```
https://apps.rocketnetworking.net/api
```

## Authentication

For authentication, include your `serverId` in the Authorization header for all requests. No additional authentication parameters, such as Bearer tokens, are required.

#### Example

```http
GET /database/:collection/:document
Authorization: YOUR_SERVER_ID
```

## Endpoints

### Retrieve Document (GET)

Retrieve a document from the specified collection and document ID.

**Request**

```http
GET /database/:collection/:document
Authorization: YOUR_SERVER_ID
```

**Response**

The API will return the requested document in the response body and 200 status code.

### Create or Overwrite Document (POST)

Create or overwrite a document in the specified collection. Include the data to be stored in the request body.

They request body is key for key replicated in the document fields.

**Request**

```http
POST /database/:collection/:document
Authorization: YOUR_SERVER_ID
Content-Type: application/json

{
  "x": "value_x",
  "y": "value_y"
}
```

**Response**

The API will return 201 success code.

### Append Document (PATCH)

Patch a document in the specified collection. Include the data to be patched in the request body.&#x20;

This takes the keys which are not there in the original document and adds them, and for the keys which are there in the document on the database, it overwrites the values with the value you provided in the request body

They request body is key for key replicated in the document fields.

**Request**

```http
PATCH /database/:collection/:document
Authorization: YOUR_SERVER_ID
Content-Type: application/json

{
  "x": "value_x",
  "y": "value_y"
}
```

**Response**

The API will return 201 success code.

### Delete Document (DELETE)

Delete a document from the specified collection.

**Request**

```http
DELETE /database/:collection/:document
Authorization: YOUR_SERVER_ID
```

**Response**

The API will return a status 204 for successful deletion.

## Example Usage

#### Retrieve Document

```http
GET /database/users/johndoe
Authorization: YOUR_SERVER_ID
```

#### Create or Overwrite Document

```http
POST /database/users/johndoe
Authorization: YOUR_SERVER_ID
Content-Type: application/json

{
  "name": "John Doe",
  "email": "john@example.com"
}
```

#### Patch Document

```http
Patch/database/users/johndoe
Authorization: YOUR_SERVER_ID
Content-Type: application/json

{
  "age" : 34
}
```

#### Delete Document

```http
DELETE /database/users/johndoe
Authorization: YOUR_SERVER_ID
```

###


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://rocket-networking.gitbook.io/docs/api/database.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
