# Users

## Generating a new token

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/user/genToken`

Generate a new token.

#### Request Body

| Name                                     | Type   | Description                          |
| ---------------------------------------- | ------ | ------------------------------------ |
| email<mark style="color:red;">\*</mark>  | string | Registered email address of the user |
| passwd<mark style="color:red;">\*</mark> | string | Password of the registered account   |

{% tabs %}
{% tab title="200 Token successfully generated" %}

```json
{
    "code": 200,
    "msg": "success",
    "token": "eyJhbGciOiJMUzI1NiIsInP5cCI6IkpXVCJ9.eyJDbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNjYxNjh9.lrJKrtpUokcRXbE1XgZDHk5xuv4k92b4_ppY5rYpgEk"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know:** The token is valid for 60 minutes. The token is invalid after expiration, so it needs to be regenerated.
{% endhint %}

The usage of curl and golang sdk is as follows:&#x20;

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

```bash
curl --location 'https://www.phoenix.global/sdk/computation/user/genToken' \
--header 'Content-Type: application/json' \
--data-raw '{
  "email": "xxxxxx@xxx.com",
  "passwd": "xxxxxxxxxxxx"
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
// import sdk package
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	reqBody := common.ReqGenToken{
		Email:  "xxxxxx@gmail.com",
		Passwd: "xxxxxxxx",
	}
	result, err := controllers.GenToken(reqBody)
	......
}
```

{% endtab %}
{% endtabs %}

## Querying user information

<mark style="color:blue;">`GET`</mark> `https://www.phoenix.global/sdk/computation/user/userInfo`

Use the generated token to query wallet address, balance and other information of the user.

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

{% tabs %}
{% tab title="200: OK Return user information" %}

```json
{
    "code": 200,
    "msg": "success",
    "email": "111@gmail.com",
    "address": "0x832b3773C1c0Fff22f5F25f3DeB5849DcbB1F794",
    "balancePHB": "1.3",
    "balanceCCD": "18.636113"
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

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

```bash
curl --location 'https://www.phoenix.global/sdk/computation/user/userInfo' \
--header 'token: xxxxxxxxxxxxxxxxxxxxxxxx'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxxxxxxxxxxx"
	result, err := controllers.UserInfo(token)
	......
}
```

{% 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://computation-sdk.phoenix.global/reference/api-reference/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.
