# User Profile API

## GET Profile data

This endpoint is used to retrieve user profile details. It requires a valid access token in the authorization header to retrieve the profile.

## HTTP Request

<mark style="color:blue;">`GET`</mark> `https://api.stagemeta.dev/auth/profile`

#### Headers

| Name                                             | Type   | Description                                                                             |
| ------------------------------------------------ | ------ | --------------------------------------------------------------------------------------- |
| Authorization:<mark style="color:red;">\*</mark> | string | <p>The user's access token in the format</p><p><code>Bearer \<token></code></p><p>.</p> |

{% tabs %}
{% tab title="200: OK The request was successful and the response body contains the user profile details." %}

```json
{
  "id": 22,
  "createdAt": "2022-09-20T12:21:48.995Z",
  "updatedAt": "2023-04-18T16:09:29.327Z",
  "deletedAt": null,
  "email": "email@gmail.com",
  "username": "my-username",
  "image": "https://cdn.stagetry.dev/images/a6bbff20-3.....",
  "walletAddress": "0xf5ad068.....cc05c44c91",
  "receiveEmail": true,
  "canGetDeltaEnergy": false,
  "emailVerify": true,
  "emailVerificationCodeExpireTime": "2023-04-14T11:24:16.008Z",
  "access": [],
  "stripeCustomerId": "cus_...51V4..YyH",
  "totalEnergyReceived": 0,
  "totalPings": 0,
  "isStageWallet": false
}
```

{% endtab %}

{% tab title="401: Unauthorized  The request is not authorized because the provided access token is invalid or expired." %}

{% endtab %}
{% endtabs %}

## Example Request

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

```bash
curl -X 'GET' \
  'https://api.stagemeta.dev/auth/profile' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <access_token>'
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
fetch('https://api.stagemeta.dev/auth/profile', {
  headers: {
    'Authorization': 'Bearer <access_token>',
    'Accept': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```

{% endtab %}
{% endtabs %}

## Post Profile data

This endpoint allows users to update their profile information.

## HTTP Post Request

<mark style="color:green;">`POST`</mark> `https://api.stagemeta.dev/auth/profile`

#### Headers

| Name                                            | Type   | Description                                                                             |
| ----------------------------------------------- | ------ | --------------------------------------------------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | <p>The user's access token in the format</p><p><code>Bearer \<token></code></p><p>.</p> |

#### Request Body

| Name        | Type   | Description               |
| ----------- | ------ | ------------------------- |
| image       | file   | The user's profile image. |
| username    | string | The user's username       |
| password    | string | The user's password.      |
| phoneNumber | string | The user's phone number.  |

{% tabs %}
{% tab title="201: Created " %}

```
{
  "user": {
    "id": 22,
    "createdAt": "2022-09-20T12:21:48.995Z",
    "updatedAt": "2023-04-18T16:09:29.327Z",
    "deletedAt": null,
    "email": "...@gmail.com",
    "username": "...",
    "image": "https://cdn.stagetry.dev/images/....png",
    "walletAddress": "0xf5ad068d....f37965cc05c44c91",
    "receiveEmail": true,
    "canGetDeltaEnergy": false,
    "emailVerify": true,
    "emailVerificationCodeExpireTime": "2023-04-14T11:24:16.008Z",
    "access": [],
    "stripeCustomerId": "cus_ND...V4cmYyH",
    "totalEnergyReceived": 0,
    "totalPings": 0,
    "isStageWallet": false
  },
  "token": "user-token"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="401: Unauthorized The request was not authorized." %}

{% endtab %}
{% endtabs %}

## Example Requests

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

```bash
curl -X 'POST' \
  'https://api.stagemeta.dev/auth/profile' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer <access_token>' \
  -H 'Content-Type: multipart/form-data' \
  -F 'username=newName' \
  -F 'password=password' \
  -F 'phoneNumber=1234567890' \
  -F 'image=base64 encoded image'
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
fetch('https://api.stagemeta.dev/auth/profile', {
  method: 'POST',
  headers: {
    'accept': '*/*',
    'Authorization': 'Bearer <access_token>',
    'Content-Type': 'multipart/form-data'
  },
  body: JSON.stringify({
    username: 'newName',
    password: 'password',
    phoneNumber: '1234567890',
    image: 'base64 encoded image'
  })
})
.then(response => {
  console.log(response.json());
})
.catch(err => {
  console.error(err);
});
```

{% 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.thetpa.ai/api-docs/reference/api-reference/user-profile-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.
