# API lấy thông tin user

### Trước khi bắt đầu

Một số lưu ý trước khi bắt đầu với các API liên quan tới webhook:

* Một tài khoản [Casso](https://my.casso.vn) đã liên kết một tài khoản ngân hàng. Để test với API này **có thể** sử dụng [tài khoản demo.](broken://pages/-McjWDNXLnazsGil8Lw0)
* Bạn cần có [API Key](/casso-api/chung-thuc/tao-api-key-thu-cong.md) để thiết lập ở trường Authorization HTTP Header.

## Lấy thông tin user

<mark style="color:blue;">`GET`</mark> `https://oauth.casso.vn/v2/userInfo`

Lấy chi tiết thông tin tài khoản như: email, thông tin doanh nghiệp và thông tin tài khoản ngân hàng liên kết.

#### Headers

| Name          | Type   | Description                                                           |
| ------------- | ------ | --------------------------------------------------------------------- |
| Authorization | string | `Bearer <access token từ Oauth2>` **hoặc** `Apikey <API key của bạn>` |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{
    "error": 0,
    "message": "success",
    "data": {
        "user": {
            "id": 1553,
            "email": "haonh@magik.vn"
        },
        "business": {
            "id": 1540,
            "name": "Hữu Hảo"
        },
        "bankAccs": [
            {
                "id": 69,
                "bank": {
                    "bin": 970416,
                    "codeName": "acb_digi"
                },
                "bankAccountName": null,
                "bankSubAccId": "17271687",
                "connectStatus": 1,
                "planStatus": 1
            },
            {
                "id": 63,
                "bank": {
                    "bin": 970454,
                    "codeName": "timoplus"
                },
                "bankAccountName": null,
                "bankSubAccId": "8007041023848",
                "connectStatus": 1,
                "planStatus": 0
            }
        ]
    }
}
```

{% endtab %}

{% tab title="401 Could not find a cake matching this query." %}

```
{
    "error": 401,
    "message": "Unauthorized Access",
    "data": null
}
```

{% endtab %}
{% endtabs %}

#### Ví dụ:&#x20;

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

```bash
curl --location --request GET 'https://oauth.casso.vn/v2/userInfo' \
--header 'Authorization: Apikey <API Key của bạn> hoặc Bearer <access token từ OAuth2>'
```

{% endtab %}

{% tab title="PHP" %}

```php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://oauth.casso.vn/v2/userInfo",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Apikey <"API Key của bạn"> hoặc Bearer <"access token từ OAuth2">",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);
```

{% endtab %}

{% tab title="JAVA" %}

```java
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://oauth.casso.vn/v2/userInfo")
  .get()
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Apikey <"API Key của bạn"> hoặc Bearer <"access token từ OAuth2">")
  .build();

Response response = client.newCall(request).execute();
```

{% endtab %}
{% endtabs %}

Ví dụ mẫu

```bash
curl --location --request GET 'https://oauth.casso.vn/v2/userInfo' \
--header 'Authorization: Apikey AK_CS.0cf673d0406711ecb6579fe89ca48437.WT2EHXBpzTFpA2XBBJzuBJSGkIPJxtM8ShgSe059Wh2SDKmAkoueFdkqnjZJrUnEXj2F2CX2'
```

Kết quả trả về

```json
{
    "error": 0,
    "message": "success",
    "data": {
        "user": {
            "id": 1,
            "email": "demo@casso.vn"
        },
        "business": {
            "id": 1009,
            "name": "VinDemo"
        },
        "bankAccs": [
            {
                "id": 87,
                "bank": {
                    "bin": 970436,
                    "codeName": "vietcombank"
                },
                "bankAccountName": null,
                "bankSubAccId": "123456789",
                "balance": 64875755,
                "memo": "VCB NGUYEN VAN A23",
                "connectStatus": 1,
                "planStatus": 2
            }
            //... các tài khác tiếp theo
        ]
    }
}
```

{% hint style="success" %}
Mẹo: Bạn có thể sử dụng thông tin phản hồi của API này trong trường **`bankAccs`** để có thể tạo cho mình các mã [VietQR code ](https://www.vietqr.io/)tương ứng với các thông tin phản hồi này.
{% endhint %}


---

# 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://developer.casso.vn/casso-api/api/lay-thong-tin-user.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.
