# Users

## Verifying and/or retrieving user

<mark style="color:green;">`GET`</mark> `/`api/tg/users/me

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | initData from TG   |

**Body**

**Response**

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

```json
{
    "isNew": false,
    "user": {
        "id": 2,
        "created_at": "2024-07-13T16:36:40.334Z",
        "updated_at": "2024-07-13T16:52:48.867Z",
        "deleted_at": null,
        "telegram_id": 783973627,
        "address": "Second",
        "name": "Second",
        "score": 800,
        "invitation_number": 3,
        "referral_code": "5CW0x5TJ9",
        "wallets": [
            {
                "id": "259838ce-35d4-4ab2-9567-29cd59cf5f96",
                "created_at": "2024-07-13T16:47:27.373Z",
                "updated_at": "2024-07-13T16:47:27.403Z",
                "deleted_at": null,
                "name": "Second wallet",
                "address": "0x45ro3efn3efe300f3e0f3efe0feifffe30f2",
                "owner_id": 2
            },
            {
                "id": "ae4f77af-acc2-4aad-a343-726b7e076083",
                "created_at": "2024-07-13T16:47:16.481Z",
                "updated_at": "2024-07-13T16:47:16.517Z",
                "deleted_at": null,
                "name": "Ton Space wallet",
                "address": "0x45ro3efn3efe300f3e0f3efe0feifffe30fi",
                "owner_id": 2
            }
        ],
        "referrer": {
            "id": 1,
            "created_at": "2024-07-13T16:35:05.511Z",
            "updated_at": "2024-07-13T16:42:49.503Z",
            "deleted_at": null,
            "address": "First",
            "name": "firzt",
            "score": 200,
            "telegram_id": 75771603,
            "invitation_number": 1,
            "referral_code": "4N6f7FCXKa",
            "wallets": []
        },
        "referrals": [
            {
                "id": 3,
                "created_at": "2024-07-13T16:45:04.596Z",
                "updated_at": "2024-07-13T16:50:48.590Z",
                "deleted_at": null,
                "telegram_id": 1783973627,
                "address": "Third",
                "name": "Third",
                "score": 200,
                "referral_code": "2IGZhR"
            },
            {
                "id": 4,
                "created_at": "2024-07-13T16:51:15.995Z",
                "updated_at": "2024-07-13T16:51:59.845Z",
                "deleted_at": null,
                "telegram_id": 1883973627,
                "address": "Third",
                "name": "Third",
                "score": 200,
                "referral_code": "cOLfGH0y"
            },
            {
                "id": 5,
                "created_at": "2024-07-13T16:52:48.786Z",
                "updated_at": "2024-07-13T16:52:48.852Z",
                "deleted_at": null,
                "telegram_id": 783973628,
                "address": "Third",
                "name": "Third",
                "score": 200,
                "referral_code": "HxNFL0DY0"
            }
        ]
    }
}
```

{% endtab %}

{% tab title="200 (not exists)" %}

```json
{
    "isNew": true
}
```

{% endtab %}
{% endtabs %}

## Create user

<mark style="color:green;">`POST`</mark> `/`api/tg/users

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | initData from TG   |

**Body**

| Name            | Type   | Required |
| --------------- | ------ | -------- |
| `address`       | string | +        |
| `name`          | string | +        |
| `referral_code` | string | -        |

**Response**

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

```json
{
    "result": true,
    "message": "User has been already created",
    "user": {
        "id": 2,
        "created_at": "2024-07-13T16:36:40.334Z",
        "updated_at": "2024-07-13T16:45:11.015Z",
        "deleted_at": null,
        "address": "Second",
        "name": "Second",
        "score": 400,
        "invitation_number": 1,
        "referral_code": "5CW0x5TJ9",
        "wallets": [],
        "referrer": {
            "id": 1,
            "created_at": "2024-07-13T16:35:05.511Z",
            "updated_at": "2024-07-13T16:42:49.503Z",
            "deleted_at": null,
            "address": "First",
            "name": "firzt",
            "score": 200,
            "invitation_number": 1,
            "referral_code": "4N6f7FCXKa",
            "wallets": []
        },
        "referrals": [
            {
                "id": 3,
                "created_at": "2024-07-13T16:45:04.596Z",
                "updated_at": "2024-07-13T16:45:04.648Z",
                "deleted_at": null,
                "address": "Third",
                "name": "Third",
                "score": 200,
                "referral_code": "2IGZhR"
            }
        ]
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "result": false,
    "message": {
        "address": [
            "This field is required."
        ]
    }
}
```

{% endtab %}
{% endtabs %}

## Update user

<mark style="color:green;">`POST`</mark> `/`api/tg/users/profile

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | initData from TG   |

**Body**

| Name      | Type   | Required |
| --------- | ------ | -------- |
| `address` | string | -        |
| `name`    | string | -        |

**Response**

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

```json
{
    "result": true,
    "message": "User profile updated",
    "user": {
        "id": 11,
        "created_at": "2024-07-06T13:36:43.213Z",
        "updated_at": "2024-07-06T13:37:01.931Z",
        "deleted_at": null,
        "address": "This is my new address",
        "name": "Ilia",
        "score": 0,
        "invitation_number": 0,
        "referral_code": "Cqyqg0av",
        "wallets": [
            {
                "id": "c9080346-dd64-4eb4-8868-48c9e190aaa9",
                "created_at": "2024-07-13T13:34:22.771Z",
                "updated_at": "2024-07-13T13:36:55.434Z",
                "deleted_at": null,
                "name": "wallet_name2",
                "address": "wallet_address222",
                "owner_id": 11
            }
        ],
        "referrer": null,
        "referrals": []
    }
}
```

{% 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.autoproof.dev/telegram-mini-apps-api/users.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.
