# CreateCredentialRequest

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest "View this page in Java")

<br />

```
abstract class CreateCredentialRequest
```

<br />

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

|------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [CreateCustomCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCustomCredentialRequest)       | Base custom create request class for registering a credential.                       |
| [CreateDigitalCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateDigitalCredentialRequest)     | A request to save a digital credential to a holder application of the user's choice. |
| [CreatePasswordRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePasswordRequest)                       | A request to save the user password credential with their password provider.         |
| [CreatePublicKeyCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePublicKeyCredentialRequest) | A request to register a passkey from the user's public key credential provider.      |
| [CreateRestoreCredentialRequest](https://developer.android.com/reference/kotlin/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[CredentialManager.createCredential](https://developer.android.com/reference/kotlin/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                                                                                                                           |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[CreateCredentialRequest.DisplayInfo](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest.DisplayInfo) Information that may be used for display purposes when rendering UIs to collect the user consent and choice. |

|                                             ### Public companion functions                                             |
|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CreateCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest) | `@`[RequiresApi](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi)`(value = 34)` [createFrom](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#createFrom(android.credentials.CreateCredentialRequest))`(request: `[CreateCredentialRequest](https://developer.android.com/reference/android/credentials/CreateCredentialRequest.html)`)` Parses the[request](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest.Companion#createFrom(android.credentials.CreateCredentialRequest))into an instance of[CreateCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [CreateCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest) | `@`[RequiresApi](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi)`(value = 23)` [createFrom](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#createFrom(kotlin.String,android.os.Bundle,android.os.Bundle,kotlin.Boolean,kotlin.String))`(` ` type: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` credentialData: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`,` ` candidateQueryData: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`,` ` requireSystemProvider: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` origin: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` `)` Attempts to parse the raw data into one of[CreatePasswordRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePasswordRequest),[CreatePublicKeyCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePublicKeyCredentialRequest), and[CreateCustomCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCustomCredentialRequest). |

|                                                             ### Public properties                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                       | [candidateQueryData](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#candidateQueryData()) the partial request data in the[Bundle](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)                                                                                                                                                                                                                                                                                                                   |
| [Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                       | [credentialData](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#credentialData()) the request data in the[Bundle](https://developer.android.com/reference/android/os/Bundle.html)format                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [CreateCredentialRequest.DisplayInfo](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest.DisplayInfo) | [displayInfo](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#displayInfo()) the information to be displayed on the screen                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                            | [isAutoSelectAllowed](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#isAutoSelectAllowed()) whether a create option will be automatically chosen if it is the only one available to the user                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                            | [isSystemProviderRequired](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#isSystemProviderRequired()) true if must only be fulfilled by a system provider and false otherwise                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                           | [origin](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#origin()) 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)                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                            | [preferImmediatelyAvailableCredentials](https://developer.android.com/reference/kotlin/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                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                              | [type](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#type()) the credential type determined by the credential-type-specific subclass (e.g. the type for[CreatePasswordRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePasswordRequest)is[PasswordCredential.TYPE_PASSWORD_CREDENTIAL](https://developer.android.com/reference/kotlin/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL())and for[CreatePublicKeyCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePublicKeyCredentialRequest)is[PublicKeyCredential.TYPE_PUBLIC_KEY_CREDENTIAL](https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL())) |

## Public companion functions

### createFrom

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

```
@RequiresApi(value = 34)
fun createFrom(request: CreateCredentialRequest): CreateCredentialRequest
```

Parses the[request](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest.Companion#createFrom(android.credentials.CreateCredentialRequest))into an instance of[CreateCredentialRequest](https://developer.android.com/reference/kotlin/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                                                           |
|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| `request: `[CreateCredentialRequest](https://developer.android.com/reference/android/credentials/CreateCredentialRequest.html) | the framework CreateCredentialRequest object |

### createFrom

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

```
@RequiresApi(value = 23)
fun createFrom(
    type: String,
    credentialData: Bundle,
    candidateQueryData: Bundle,
    requireSystemProvider: Boolean,
    origin: String? = null
): CreateCredentialRequest
```

Attempts to parse the raw data into one of[CreatePasswordRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePasswordRequest),[CreatePublicKeyCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreatePublicKeyCredentialRequest), and[CreateCustomCredentialRequest](https://developer.android.com/reference/kotlin/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                                                  |
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                    | matches[CreateCredentialRequest.type](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#type())                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `credentialData: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                   | matches[CreateCredentialRequest.credentialData](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#credentialData()), the request data in the[Bundle](https://developer.android.com/reference/android/os/Bundle.html)format; this should be constructed and retrieved from the a given[CreateCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest)itself and never be created from scratch                                                                                            |
| `candidateQueryData: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)               | matches[CreateCredentialRequest.candidateQueryData](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest#candidateQueryData()), the partial request data in the[Bundle](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[CreateCredentialRequest](https://developer.android.com/reference/kotlin/androidx/credentials/CreateCredentialRequest)itself and never be created from scratch |
| `requireSystemProvider: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | whether the request must only be fulfilled by a system provider                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `origin: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`? = null`        | the origin of a different application if the request is being made on behalf of that application                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

## Public properties

### candidateQueryData

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

```
val candidateQueryData: Bundle
```

the partial request data in the[Bundle](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)  

### credentialData

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

```
val credentialData: Bundle
```

the request data in the[Bundle](https://developer.android.com/reference/android/os/Bundle.html)format  

### displayInfo

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

```
val displayInfo: CreateCredentialRequest.DisplayInfo
```

the information to be displayed on the screen  

### isAutoSelectAllowed

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

```
val isAutoSelectAllowed: Boolean
```

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)  

```
val isSystemProviderRequired: Boolean
```

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

### origin

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

```
val origin: String?
```

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)  

### preferImmediatelyAvailableCredentials

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

```
val preferImmediatelyAvailableCredentials: Boolean
```

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  

### type

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

```
val type: String
```

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