> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/common/user-info.md).

# User Information

{% hint style="info" %}
**Console setup is required**

`getConsentedUserData`To use it, you must first register User Info Fetch in the console. Please check the user info introduction document first.
{% endhint %}

### User information retrieval (`getConsentedUserData`)

`getConsentedUserData`It is a function that requests consent-based user data. If consent is required, it opens the terms webview, and when consent is completed, returns the data retrieved from the server.

**Signature**

```typescript
function getConsentedUserData(options: GetConsentedUserDataOptions): Promise<ConsentedUserData | undefined>;
```

**Type**

```typescript
type GetConsentedUserDataErrorCode =
  | 'USER_DECLINED'
  | 'UNAVAILABLE'
  | 'TERMS_NOT_SET'
  | 'INVALID_REQUEST'
  | 'CANCELED'
  | 'CONSENTED_USER_DATA_AGREEMENT_FAILED'
  | 'CONSENTED_USER_DATA_INVALID_DATA';

interface GetConsentedUserDataOptions {
  consentedUserDataKey: string;
  shouldRequestAgreementWhenUserDeclined?: boolean;
}

type ConsentedUserDataKey =
  | 'USER_NAME'
  | 'USER_GENDER'
  | 'USER_NATIONALITY'
  | 'USER_BIRTHDAY'
  | 'USER_PHONE'
  | 'USER_ADDRESS'
  | 'USER_EMAIL'
  | 'USER_CONSUMPTION_HISTORY';

type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;
```

**Parameters**

* **options** · Required · `GetConsentedUserDataOptions`

  The options used when requesting consent-based user data.

  * **options.consentedUserDataKey** · Required · `string`

    The key used by the server to find the user data consent text and data bundle. For example: `cud_delivery`
  * **options.shouldRequestAgreementWhenUserDeclined** · `boolean`

    `USER_DECLINED` Whether to show the terms webview again in the USER\_DECLINED state. The default is `false`.

**Return value**

* `Promise<ConsentedUserData | undefined>`

  Returns the user data provided by the server. If the Toss app version is `5.264.0` less than `undefined`is returned.

`ConsentedUserData`only the keys corresponding to the requested items may be included.

| Key                | Description                 | Notes                                                                                                             |
| ------------------ | --------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `USER_NAME`        | User name                   |                                                                                                                   |
| `USER_GENDER`      | User gender                 |                                                                                                                   |
| `USER_NATIONALITY` | Whether domestic or foreign |                                                                                                                   |
| `USER_BIRTHDAY`    | User date of birth          |                                                                                                                   |
| `USER_PHONE`       | User mobile phone number    |                                                                                                                   |
| `USER_ADDRESS`     | User home address           | Because it isn't required when signing up for Toss, there may be no value, and in that case it is passed as null. |
| `USER_EMAIL`       | User email address          | Because it isn't required when signing up for Toss, there may be no value, and in that case it is passed as null. |

**Error code**

`getConsentedUserData` If the call fails, the error codes below may be returned.

| Error code                             | Description                                                                                                                          |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `USER_DECLINED`                        | This is the case when the user explicitly declined and there is no retry request option, or when they declined in the terms webview. |
| `UNAVAILABLE`                          | This is the case when the server cannot determine whether the user has consented.                                                    |
| `TERMS_NOT_SET`                        | This is the case when the mini app does not have the user data provision consent text set.                                           |
| `INVALID_REQUEST`                      | `consentedUserDataKey`is empty, or `termsUrl`is missing, or it is not an HTTPS company domain.                                       |
| `CANCELED`                             | This is the case when the terms webview is closed before sending the result.                                                         |
| `CONSENTED_USER_DATA_AGREEMENT_FAILED` | An error occurred while processing the terms webview.                                                                                |
| `CONSENTED_USER_DATA_INVALID_DATA`     | `PROVIDED`but `data`is missing, or after successful consent the re-query result is `PROVIDED`not                                     |

**Example**

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

```tsx
import { getConsentedUserData } from '@apps-in-toss/web-framework';

async function fetchDeliveryUserData() {
  try {
    const data = await getConsentedUserData({
      consentedUserDataKey: 'cud_delivery',
    });

    console.log('User name:', data?.USER_NAME);
    console.log('Phone number:', data?.USER_PHONE);
  } catch (error) {
    console.error('Failed to fetch consent data:', error);
  }
}
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { getConsentedUserData } from '@apps-in-toss/framework';

async function fetchDeliveryUserData() {
  try {
    const data = await getConsentedUserData({
      consentedUserDataKey: 'cud_delivery',
    });

    console.log('User name:', data?.USER_NAME);
    console.log('Phone number:', data?.USER_PHONE);
  } catch (error) {
    console.error('Failed to fetch consent data:', error);
  }
}
```

{% endtab %}
{% endtabs %}

### Notes

* `USER_ADDRESS`, `USER_EMAIL`If the user has not registered with Toss, `null`it is passed as null. Please be sure to handle null.
* If the user wants to withdraw consent, **Toss app → Settings → Terms and Privacy Policy Consent → mini app name**you can withdraw each item individually.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/common/user-info.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
