# Self-Hosting Shares

As mentioned in the [Tech Overview](/start/about/concepts-overview/wallet-key-management-tech-overview.md) section, you are given the option to host one of the shares on your servers for additional security of user wallets. Do note that if you opting to store shares on your own servers comes with the following risks:

* If data is lost of damaged, users can potentially lose access to their funds.
* If your service is down temporarily, users may not be able to access their wallets during the downtime.
* If the latency of the endpoint is higher than 1000ms, it will result in degraded user experience.

We recommend you to only go for this option once your are familiar with using Metafi's embedded wallet service. If you require further assistance, please book a call using [this link](https://calendly.com/arvindramesh/metafi) or feel free to ask us on our [Discord](https://discord.gg/yaxvxEmuKn) server.

{% hint style="warning" %}
Please note that if you opt to host your own shares, **you cannot change this in the future** and will instead need to create a new project where you can pick Metafi's default share hosting option.
{% endhint %}

### Share Manager Specifications

We require you to implement 2 endpoints to begin self-hosting shares. Once you implement these endpoints, please update the URLs on the Project Settings page of the [developer portal](https://developer-test.usemeta.fi/).

#### 1. Store Share

<mark style="color:green;">`POST`</mark> `https://your-api.com/createShare`

This URL will be invoked whenever a user creates a wallet using your API Key. The request body will contain the `metafiUserId` and the unencrypted share, which you can then store on your database.&#x20;

We recommend that you encrypt your share while saving to the database using a rotating key management system such as AWS KMS.

#### Request Body

| Name                                           | Type   | Description           |
| ---------------------------------------------- | ------ | --------------------- |
| metafiUserId<mark style="color:red;">\*</mark> | String | Metafi user ID        |
| share<mark style="color:red;">\*</mark>        | String | The unencrypted share |

{% tabs %}
{% tab title="204: No Content " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

#### 2. Retrieve Share

<mark style="color:blue;">`GET`</mark> `https://your-api.com/retrieveShare`

This Endpoint will be invoked whenever we are reconstructing the user wallet and require your share. When returning the share, please ensure that it is decrypted.

#### Request Body

| Name         | Type   | Description    |
| ------------ | ------ | -------------- |
| metafiUserId | String | Metafi user ID |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "share": "unencrypted-share"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://docs.usemeta.fi/start/about/self-hosting-shares.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
