> 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 Fetching in the console. Please check the user info introduction document first.
{% endhint %}

### User information retrieval (`getConsentedUserData`)

`getConsentedUserData`is a function that requests user-consented data. If consent is required, it opens the terms WebView, and once consent is completed, it returns the data queried 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`

  These are the options used when requesting user-consented data.

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

    This is the key used by the server to find the user data consent statement and data bundle. Example: `cud_delivery`
  * **options.shouldRequestAgreementWhenUserDeclined** · `boolean`

    `USER_DECLINED` Whether to show the terms WebView again in the same state. The default is `false`It is.

**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`may contain only the keys corresponding to the requested items.

| Key                | Description                             | Notes                                                                                                              |
| ------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `USER_NAME`        | User name                               |                                                                                                                    |
| `USER_GENDER`      | User gender                             |                                                                                                                    |
| `USER_NATIONALITY` | Whether the user is domestic or foreign |                                                                                                                    |
| `USER_BIRTHDAY`    | User date of birth                      |                                                                                                                    |
| `USER_PHONE`       | User mobile phone number                |                                                                                                                    |
| `USER_ADDRESS`     | User home address                       | Since it is not required when signing up for Toss, it may not have a value, and in that case it is passed as null. |
| `USER_EMAIL`       | User email address                      | Since it is not required when signing up for Toss, it may not have a value, and in that case it is passed as null. |

**Error code**

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

| Error code                             | Description                                                                                                                               |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `USER_DECLINED`                        | This is the case when the user explicitly declined and there is no re-request option, or when they declined consent 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 user data consent statement is not set in the mini app.                                                         |
| `INVALID_REQUEST`                      | `consentedUserDataKey`is empty, or `termsUrl`is missing, or is not an HTTPS company domain.                                               |
| `CANCELED`                             | This is the case when the terms WebView is closed before it sends a result.                                                               |
| `CONSENTED_USER_DATA_AGREEMENT_FAILED` | This is the case when an error occurs while handling the terms WebView.                                                                   |
| `CONSENTED_USER_DATA_INVALID_DATA`     | `PROVIDED`but `data`is missing, or the re-query result after consent success 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 it with Toss `null`it is passed as null. Please make 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.
