# CreateCredentialRequest

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/CreateCredentialRequest.kt+class:androidx.credentials.CreateCredentialRequest) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***


```
public abstract class CreateCredentialRequest
```

<br />

Known direct subclasses [CreateCustomCredentialRequest](https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialRequest), [CreateDigitalCredentialRequest](https://developer.android.com/reference/androidx/credentials/CreateDigitalCredentialRequest), [CreatePasswordRequest](https://developer.android.com/reference/androidx/credentials/CreatePasswordRequest), [CreatePublicKeyCredentialRequest](https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest), [CreateRestoreCredentialRequest](https://developer.android.com/reference/androidx/credentials/CreateRestoreCredentialRequest)

|---|---|
| `https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialRequest` | Base custom create request class for registering a credential. |
| `https://developer.android.com/reference/androidx/credentials/CreateDigitalCredentialRequest` | A request to save a digital credential to a holder application of the user's choice. |
| `https://developer.android.com/reference/androidx/credentials/CreatePasswordRequest` | A request to save the user password credential with their password provider. |
| `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest` | A request to register a passkey from the user's public key credential provider. |
| `https://developer.android.com/reference/androidx/credentials/CreateRestoreCredentialRequest` | A request to create a restore credential used for app restore purpose. |

*** ** * ** ***

Base request class for registering a credential.

An application can construct a subtype request and call `https://developer.android.com/reference/androidx/credentials/CredentialManager#createCredential(android.content.Context,androidx.credentials.CreateCredentialRequest)` to launch framework UI flows to collect consent and any other metadata needed from the user to register a new user credential.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest.DisplayInfo` Information that may be used for display purposes when rendering UIs to collect the user consent and choice. |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 34) https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#createFrom(android.credentials.CreateCredentialRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/credentials/CreateCredentialRequest.html request)` Parses the `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest.Companion#createFrom(android.credentials.CreateCredentialRequest)` into an instance of `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 23) https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#createFrom(kotlin.String,android.os.Bundle,android.os.Bundle,kotlin.Boolean,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html type, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html credentialData, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html candidateQueryData, boolean requireSystemProvider, https://developer.android.com/reference/java/lang/String.html origin )` Attempts to parse the raw data into one of `https://developer.android.com/reference/androidx/credentials/CreatePasswordRequest`, `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest`, and `https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialRequest`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#getCandidateQueryData()()` the partial request data in the `https://developer.android.com/reference/android/os/Bundle.html` format that will be sent to the provider during the initial candidate query stage, which should not contain sensitive user credential information (note: bundle keys in the form of `androidx.credentials.*` are reserved for internal library use) |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#getCredentialData()()` the request data in the `https://developer.android.com/reference/android/os/Bundle.html` format |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest.DisplayInfo` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#getDisplayInfo()()` the information to be displayed on the screen |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#getOrigin()()` the origin of a different application if the request is being made on behalf of that application (Note: for API level \>=34, setting a non-null value for this parameter will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present) |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#getType()()` the credential type determined by the credential-type-specific subclass (e.g. the type for `https://developer.android.com/reference/androidx/credentials/CreatePasswordRequest` is `https://developer.android.com/reference/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL()` and for `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest` is `https://developer.android.com/reference/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()`) |
| `final boolean` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#isAutoSelectAllowed()()` whether a create option will be automatically chosen if it is the only one available to the user |
| `final boolean` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#isSystemProviderRequired()()` true if must only be fulfilled by a system provider and false otherwise |
| `final boolean` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#preferImmediatelyAvailableCredentials()()` true if you prefer the operation to return immediately when there is no available passkey registration offering instead of falling back to discovering remote options, and false (preferred by default) otherwise |

## Public methods

### createFrom

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.5.0)

```
@RequiresApi(value = 34)
public static final @NonNull CreateCredentialRequest createFrom(@NonNull CreateCredentialRequest request)
```

Parses the `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest.Companion#createFrom(android.credentials.CreateCredentialRequest)` into an instance of `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest`.

It is recommended to construct a CreateCredentialRequest by directly instantiating a CreateCredentialRequest subclass, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object for user interactions such as collecting consents.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/credentials/CreateCredentialRequest.html request` | the framework CreateCredentialRequest object |

### createFrom

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.3.0)

```
@RequiresApi(value = 23)
public static final @NonNull CreateCredentialRequest createFrom(
    @NonNull String type,
    @NonNull Bundle credentialData,
    @NonNull Bundle candidateQueryData,
    boolean requireSystemProvider,
    String origin
)
```

Attempts to parse the raw data into one of `https://developer.android.com/reference/androidx/credentials/CreatePasswordRequest`, `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest`, and `https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialRequest`.

It is recommended to construct a CreateCredentialRequest by directly instantiating a CreateCredentialRequest subclass, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object for user interactions such as collecting consents.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html type` | matches `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#type()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html credentialData` | matches `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#credentialData()`, the request data in the `https://developer.android.com/reference/android/os/Bundle.html` format; this should be constructed and retrieved from the a given `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest` itself and never be created from scratch |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html candidateQueryData` | matches `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest#candidateQueryData()`, the partial request data in the `https://developer.android.com/reference/android/os/Bundle.html` format that will be sent to the provider during the initial candidate query stage; this should be constructed and retrieved from the a given `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest` itself and never be created from scratch |
| `boolean requireSystemProvider` | whether the request must only be fulfilled by a system provider |
| `https://developer.android.com/reference/java/lang/String.html origin` | the origin of a different application if the request is being made on behalf of that application |

### getCandidateQueryData

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final @NonNull Bundle getCandidateQueryData()
```

the partial request data in the `https://developer.android.com/reference/android/os/Bundle.html` format that will be sent to the provider during the initial candidate query stage, which should not contain sensitive user credential information (note: bundle keys in the form of `androidx.credentials.*` are reserved for internal library use)

### getCredentialData

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final @NonNull Bundle getCredentialData()
```

the request data in the `https://developer.android.com/reference/android/os/Bundle.html` format

### getDisplayInfo

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final @NonNull CreateCredentialRequest.DisplayInfo getDisplayInfo()
```

the information to be displayed on the screen

### getOrigin

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final String getOrigin()
```

the origin of a different application if the request is being made on behalf of that application (Note: for API level \>=34, setting a non-null value for this parameter will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present)

### getType

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final @NonNull String getType()
```

the credential type determined by the credential-type-specific subclass (e.g. the type for `https://developer.android.com/reference/androidx/credentials/CreatePasswordRequest` is `https://developer.android.com/reference/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL()` and for `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest` is `https://developer.android.com/reference/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()`)

### isAutoSelectAllowed

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final boolean isAutoSelectAllowed()
```

whether a create option will be automatically chosen if it is the only one available to the user

### isSystemProviderRequired

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final boolean isSystemProviderRequired()
```

true if must only be fulfilled by a system provider and false otherwise

### preferImmediatelyAvailableCredentials

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.5.0)

```
public final boolean preferImmediatelyAvailableCredentials()
```

true if you prefer the operation to return immediately when there is no available passkey registration offering instead of falling back to discovering remote options, and false (preferred by default) otherwise