# API

## Fetch a project user

<mark style="color:blue;">`GET`</mark> `https://sharemint.xyz/api/external/user`

#### Query Parameters

| Name                                      | Type   | Description                                     |
| ----------------------------------------- | ------ | ----------------------------------------------- |
| slug<mark style="color:red;">\*</mark>    | String | Project slug                                    |
| address<mark style="color:red;">\*</mark> | String | User address or email                           |
| chain<mark style="color:red;">\*</mark>   | String | Blockchain name                                 |
| apiSecret                                 | String | Your secret API key from the project admin page |

{% tabs %}
{% tab title="200: OK Returns the user" %}

{% endtab %}
{% endtabs %}

## Get user address from invite code

<mark style="color:blue;">`GET`</mark> `https://sharemint.xyz/api/external/address-from-invite-code`

#### Query Parameters

| Name                                   | Type   | Description          |
| -------------------------------------- | ------ | -------------------- |
| code<mark style="color:red;">\*</mark> | String | User's referral code |
| slug<mark style="color:red;">\*</mark> | String | Project slug         |

{% tabs %}
{% tab title="200: OK Returns the user" %}

{% endtab %}
{% endtabs %}

## Get affiliate details

<mark style="color:blue;">`GET`</mark> `https://sharemint.xyz/api/external/affiliate`

One of address, projectUserId, or referralCode is required.

#### Query Parameters

| Name                                   | Type   | Description                                     |
| -------------------------------------- | ------ | ----------------------------------------------- |
| address                                | String | Affiliate's wallet address                      |
| projectUserId                          | String | Affiliate's id in project                       |
| referralCode                           | String | Affiliate's referral code                       |
| slug<mark style="color:red;">\*</mark> | String | Project slug                                    |
| apiSecret                              | String | Your secret API key from the project admin page |

{% tabs %}
{% tab title="200: OK Returns the affiliate details" %}

{% endtab %}
{% endtabs %}

## Get invite code

<mark style="color:green;">`POST`</mark> `https://sharemint.xyz/api/external/get-or-create-invite-code`

Get an affiliate's invite code. Create it if it doesn't exist.

#### Request Body

| Name                                      | Type   | Description     |
| ----------------------------------------- | ------ | --------------- |
| address<mark style="color:red;">\*</mark> | String | User's address  |
| chain<mark style="color:red;">\*</mark>   | String | Blockchain name |
| slug<mark style="color:red;">\*</mark>    | String | Project slug    |

{% tabs %}
{% tab title="200: OK Returns the affiliate" %}

{% endtab %}
{% endtabs %}

## Save a referral via referral id or wallet address

<mark style="color:green;">`POST`</mark> `https://sharemint.xyz/api/external/save`

One of address, email, or transactionHash is required.

#### Request Body

| Name                                   | Type    | Description                                                                                                                                                               |
| -------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark> | String  | Project slug                                                                                                                                                              |
| invitedById                            | String  | The invite code of the referrer that invited the user                                                                                                                     |
| invitedByAddress                       | String  | The address of the referrer that invited the user                                                                                                                         |
| address                                | String  | User's wallet address                                                                                                                                                     |
| email                                  | String  | User's email                                                                                                                                                              |
| transactionHash                        | String  | Transaction hash                                                                                                                                                          |
| chain                                  | String  | Chain                                                                                                                                                                     |
| minter                                 | String  | One of "payer" or "receiver"                                                                                                                                              |
| apiSecret                              | String  | Your secret API key from the project admin page                                                                                                                           |
| verified                               | Boolean | If the referral is verified. Can only be set when providing an apiSecret                                                                                                  |
| disqualifiedAsReferee                  | Boolean | If the user is disqualified from being a referee. Can only be set when providing an apiSecret. This field has no impact if the user has already been referred by someone. |

{% tabs %}
{% tab title="200: OK Returns the information about the referral" %}

{% endtab %}
{% endtabs %}

## Save a referral via a transaction hash

<mark style="color:green;">`POST`</mark> `https://sharemint.xyz/api/external/save-transaction`

This saves both the referral and the payment made in the transaction.

#### Request Body

| Name                                              | Type    | Description                                           |
| ------------------------------------------------- | ------- | ----------------------------------------------------- |
| slug<mark style="color:red;">\*</mark>            | String  | Project slug                                          |
| email                                             | String  | User's email                                          |
| minter<mark style="color:red;">\*</mark>          | String  | One of "payer" or "receiver"                          |
| transactionHash<mark style="color:red;">\*</mark> | String  | Transaction hash                                      |
| chain                                             | String  | Chain                                                 |
| invitedById<mark style="color:red;">\*</mark>     | String  | The invite code of the referrer that invited the user |
| invitedByAddress                                  | String  | The address of the referrer that invited the user     |
| apiSecret                                         | String  | Your secret API key from the project admin page       |
| verified                                          | Boolean | Is the user verified?                                 |

{% tabs %}
{% tab title="200: OK Returns the information about the referral" %}

{% endtab %}
{% endtabs %}

## Save an event

<mark style="color:green;">`POST`</mark> `https://sharemint.xyz/api/external/save-event`

One of address, email, or projectUserId is required.

#### Request Body

| Name                                        | Type   | Description                                            |
| ------------------------------------------- | ------ | ------------------------------------------------------ |
| slug<mark style="color:red;">\*</mark>      | String | Project slug                                           |
| apiSecret<mark style="color:red;">\*</mark> | String | Your secret API key from the project admin page        |
| name<mark style="color:red;">\*</mark>      | String | Name of the event that you set in the project settings |
| value                                       | Number | Value of the event                                     |
| address                                     | String | User's address                                         |
| email                                       | String | User's email                                           |
| projectUserId                               | String | User's id on ShareMint for this project                |
| referredByCode                              | String | The invite code of the referrer that invited the user  |
| referredByAddress                           | String | The address of the referrer that invited the user      |

{% tabs %}
{% tab title="200: OK Returns the created event" %}

{% endtab %}
{% endtabs %}

## Save payment

<mark style="color:green;">`POST`</mark> `https://sharemint.xyz/api/external/save-payment`

One of address or email is required.

#### Request Body

| Name                                          | Type   | Description                                                                                                  |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| slug<mark style="color:red;">\*</mark>        | String | Project slug                                                                                                 |
| apiSecret<mark style="color:red;">\*</mark>   | String | Your secret API key from the project admin page                                                              |
| invitedById<mark style="color:red;">\*</mark> | String | Referrer's id                                                                                                |
| value<mark style="color:red;">\*</mark>       | String | Payment value. Must be bigger than 0                                                                         |
| invitedByAddress                              | String | Referrer's address                                                                                           |
| quantity                                      | String | Amount of purchases                                                                                          |
| chain                                         | String | Blockchain name. Can be "FIAT", "ETHEREUM", "POLYGON", "ARBITRUM", "OPTIMISM", "SOLANA", "GOERLI", "SEPOLIA" |
| address                                       | String | User's address                                                                                               |
| email                                         | String | User's email                                                                                                 |

{% tabs %}
{% tab title="200: OK Returns the id of the user" %}

{% 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.sharemint.xyz/fundamentals/api.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.
