Full Reference Docs - PropelAuth Docs
InfoThis documentation is just forPropelAuth Components, an optional library for those who want deeper design control over their UIs. Click here to view our standard documentation
Close banner
Full Reference Documentation
createOrg
Creates a new org and automatically adds the logged in user to it.
Arguments
- Name
name*TypestringDescriptionThe name of the org to be created - Name
allow_users_to_join_by_domain*TypebooleanDescriptionIf a domain is set for the org, allow users to the org if their domain matches the org's domain. - Name
restrict_invites_by_domain*TypebooleanDescriptionIf a domain is set for the org, only allow users with that domain to join.
Success Response
- Name
org_idTypestringDescriptionThe ID of the new org. - Name
first_orgTypebooleanDescriptionIf the new org is the first org the user belongs to.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
cannotCreateOrgsDescriptionThe user does not have permission to create orgs. - Name
cannotUsePersonalDomainDescriptionThe user provided a domain such as "gmail.com", "microsoft.com", etc. - Name
userAlreadyInTooManyOrgsDescriptionUser already belongs to the maximum amount of orgs. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { createOrg } = useAuthFrontendApis()
const response = await createOrg({
name: 'Acme Inc',
allow_users_to_join_by_domain: true,
restrict_invites_by_domain: true,
})
response.handle({
success(data) {
console.log(data)
},
cannotCreateOrgs(error) {
console.log('Cannot create orgs', error.user_facing_error)
},
cannotUsePersonalDomain(error) {
console.log('Cannot use personal domain', error.user_facing_error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
userAlreadyInTooManyOrgs(error) {
console.log('User already in too many orgs', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.log('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"org_id": "1189c444-8a2d-4c41-8b4b-ae43ce79a492",
"first_org": true
}
CopyCopied!
createOrgApiKey
Creates an Org API key for the provided organization.
Arguments
- Name
orgId*TypestringDescriptionThe ID of the org to create an API key for - Name
expirationOption*TypestringDescriptionCan be one of the following: 'TwoWeeks' | 'OneMonth' | 'ThreeMonths' | 'SixMonths' | 'OneYear' | 'Never' - Name
displayNameTypestringDescriptionThe display name of the API key
Success Response
- Name
api_key_idTypestringDescriptionThe ID of the API Key. - Name
api_key_tokenTypestringDescriptionThe API Key.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
invalidExpirationOptionDescriptionIncorrect argument provided for 'expirationOption' - Name
noOrgApiKeyPermissionDescriptionUser does not have permission to create an org API key. - Name
unauthorizedDescriptionThe user is not logged in. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { createOrgApiKey } = useAuthFrontendApis()
const response = await createOrgApiKey(orgId, 'Never', 'My API Key')
await response.handle({
success: async () => {
console.log('success')
},
invalidExpirationOption(error) {
console.error('Invalid expiration option', error.user_facing_error)
},
noOrgApiKeyPermission(error) {
console.error('Forbidden', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error.user_facing_error)
},
badRequest(error) {
console.error(error.user_facing_errors.display_name)
},
})
CopyCopied!
Successful Response
{
"api_key_id": "justAnId",
"api_key_token": "dhopw42..."
}
CopyCopied!
createPersonalApiKey
Creates a Personal API key for the logged in user.
Arguments
- Name
expirationOption*TypestringDescriptionCan be one of the following: 'TwoWeeks' | 'OneMonth' | 'ThreeMonths' | 'SixMonths' | 'OneYear' | 'Never' - Name
displayNameTypestringDescriptionThe display name of the API key
Success Response
- Name
api_key_idTypestringDescriptionThe ID of the API Key. - Name
api_key_tokenTypestringDescriptionThe API Key.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
invalidExpirationOptionDescriptionIncorrect argument provided for 'expirationOption' - Name
noPersonalApiKeyPermissionDescriptionUser does not have permission to create a personal API key. - Name
unauthorizedDescriptionThe user is not logged in. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { createPersonalApiKey } = useAuthFrontendApis()
const response = await createPersonalApiKey('Never', 'My API Key')
await response.handle({
success: async () => {
console.log('success')
},
invalidExpirationOption(error) {
console.error('Invalid expiration option', error.user_facing_error)
},
noPersonalApiKeyPermission(error) {
console.error('Forbidden', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error.user_facing_error)
},
badRequest(error) {
console.error(error.user_facing_errors.display_name)
},
})
CopyCopied!
Successful Response
{
"api_key_id": "justAnId",
"api_key_token": "dhopw42..."
}
CopyCopied!
deleteAccount
Deletes the logged in user's account from your application.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
actionDisabledDescriptionThe 'Users can delete their own accounts' setting in your PropelAuth dashboard is disabled - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { deleteAccount } = useAuthFrontendApis()
const response = await deleteAccount()
await response.handle({
success: async () => {
console.log('Account deleted')
},
actionDisabled(error) {
console.log('Cannot delete account', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.log('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
deleteApiKey
Deletes the provided API Key.
Arguments
- Name
apiKeyId*TypestringDescriptionThe ID of the API Key to be deleted.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
apiKeyNotFoundDescriptionAPI Key ID not associated with an API key that belongs to the user. - Name
noApiKeyPermissionDescriptionUser does not have permission to delete the API key. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { deleteApiKey } = useAuthFrontendApis()
const response = await deleteApiKey("justAnId")
await response.handle({
success: async () => {
console.log('success')
},
apiKeyNotFound(error) {
console.error('API key not found', error.user_facing_error)
},
noApiKeyPermission(error) {
console.error('Forbidden', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
deleteOrg
Deletes the provided organization.
Arguments
- Name
orgId*TypestringDescriptionThe ID of the org to be deleted.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgNotFoundDescriptionThe provided org does not exist. - Name
actionDisabledDescriptionThe 'Users can delete their own orgs' setting is disabled in your PropelAuth dashboard. - Name
noDeletePermissionDescriptionUser does not have permission to delete the org. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { deleteOrg } = useAuthFrontendApis()
const response = await deleteOrg('1189c444-8a2d-4c41-8b4b-ae43ce79a492')
response.handle({
success() {
console.log('Org deleted')
},
orgNotFound(error) {
console.log('Org not found', error.user_facing_error)
},
actionDisabled(error) {
console.log('Cannot delete org', error.user_facing_error)
},
noDeletePermission(error) {
console.log('No delete permission', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.log('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
disableMfa
Disables MFA for the logged in user.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
alreadyDisabledDescriptionMFA not enabled for user. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { disableMfa } = useAuthFrontendApis()
const response = await disableMfa()
await response.handle({
success: async () => {
console.log('MFA successfully disabled.')
},
alreadyDisabled: () => {
console.log('MFA is already disabled.')
},
unexpectedOrUnhandled() {
console.error('An unexpected error occurred')
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
emailPasswordLogin
Accepts a user's email and password to log them in.
Arguments
- Name
email*TypestringDescriptionThe email of the user to log in. - Name
password*TypestringDescriptionThe password of the user to log in.
Success Response
- Name
login_stateTypeLoginStateDescription
Returns one of the following:
- LOGIN_REQUIRED
- TWO_FACTOR_REQUIRED
- EMAIL_NOT_CONFIRMED_YET
- USER_MISSING_REQUIRED_PROPERTIES
- USER_MUST_BE_IN_AT_LEAST_ONE_ORG
- UPDATE_PASSWORD_REQUIRED
- TWO_FACTOR_ENROLLMENT_REQUIRED
- LOGGED_IN
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
passwordLoginDisabledDescriptionPassword login is disabled in the PropelAuth Dashboard. - Name
userAccountDisabledDescriptionUser cannot login due to their account being disabled. - Name
userAccountLockedDescriptionUser cannot login due to their account being locked. - Name
invalidCredentialsDescriptionThe email or password provided is incorrect. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { emailPasswordLogin } = useAuthFrontendApis()
const response = await emailPasswordLogin({
email: "test@example.com",
password: "password"
})
response.handle({
success(data) {
// handle login state
},
passwordLoginDisabled(error) {
console.error('Password login disabled', error)
},
userAccountDisabled(error) {
console.error('User account disabled', error)
},
userAccountLocked(error) {
console.error('User account locked', error)
},
invalidCredentials(error) {
console.error('Invalid credentials', error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"login_state": "Finished"
}
CopyCopied!
enableMfa
Accepts the code provided by your authenticated user when setting up MFA. To set up MFA, use the QR Code (or secret) provided by fetchMfaStatusWithNewSecret.
Arguments
- Name
code*TypestringDescriptionThe code generated by your user's authenticator.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
alreadyEnabledDescriptionUser has MFA enabled already. - Name
badRequestDescriptionIncorrect arguments provided. This is the error you will get if the code is incorrect. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { enableMfa } = useAuthFrontendApis()
const response = await enableMfa({ code: '123456' })
await response.handle({
success: () => {
console.log('MFA enabled')
},
badRequest: (error) => {
console.log('Bad request error:', error.user_facing_errors.code)
},
unexpectedOrUnhandled: () => {
console.log('An unexpected error occurred')
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
fetchExpiredInvites
Fetches a paginated list of an org's expired invites.
Arguments
- Name
orgId*TypestringDescriptionThe ID of the org to fetch expired invites for. - Name
page_numberTypenumberDescriptionThe page number to return. Starts at 0. - Name
page_sizeTypenumberDescriptionThe amount of results per page. - Name
email_searchTypestringDescriptionFilter by invite email.
Success Response
- Name
expired_invitesTypeExpiredOrgInvite[]Description
An array of expired invites for the provided org.
emailstringrolestringadditional_rolesstring[]expires_at_secondsnumber
Name
total_countTypenumberDescriptionThe total amount of expired org invites.Name
page_numberTypenumberDescriptionThe current page.Name
page_sizeTypenumberDescriptionThe maximum amount of results of the page.Name
has_more_resultsTypebooleanDescriptionReturns true of there are more results beyond the current page.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgNotFoundDescriptionThe provided Org ID was not found. - Name
orgsNotEnabledDescriptionOrganizations are not enabled for the project. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchExpiredInvites } = useAuthFrontendApis()
const response = await fetchExpiredInvites("1189c444-8a2d-4c41-8b4b-ae43ce79a492", {
page_number: 0,
page_size: 10,
email_search: "Acme",
});
await response.handle({
success: (data) => {
setResponse(data);
},
orgNotFound(error) {
console.error('Org not found', error);
},
orgsNotEnabled(error) {
console.error('Org not enabled', error);
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error);
},
});
CopyCopied!
Successful Response
{
"expired_invites": [\
{\
"email": "test@example.com",\
"role": "Admin",\
"additional_roles" : [\
"Member"\
],\
"expired_at_seconds": 1737217437\
}\
],
"total_count": 1,
"page_number": 0,
"page_size": 10,
"has_more_results": false
}
CopyCopied!
fetchJoinableOrgs
Returns an array of organizations that the user can join based on their email domain.
Success Response
- Name
orgsTypeJoinableOrg[]Description
An array of objects that include the following:
- id: The ID of the organization.
- name: The name of the organization.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgsNotEnabledDescriptionOrganizations are not enabled in the PropelAuth Dashboard. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchJoinableOrgs } = useAuthFrontendApis()
const response = await fetchJoinableOrgs()
response.handle({
success(data) {
console.log(data.orgs)
},
orgsNotEnabled(error) {
console.error('Organizations are disabled', error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"orgs": [\
{\
"id": "org_123",\
"name": "Acme Corp"\
},\
{\
"id": "org_456",\
"name": "Widget Co"\
}\
]
}
CopyCopied!
fetchLoginState
Fetches the user's current login state, informing you of whether the user is logged in, needs to enroll in MFA, and more.
Success Response
- Name
login_stateTypeLoginStateDescription
Returns one of the following:
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchLoginState } = useAuthFrontendApis()
const response = await fetchLoginState()
await response.handle({
success: (data) => {
// handle user based on data.login_state
},
unexpectedOrUnhandled() {
console.log('An unexpected error occurred.')
},
})
CopyCopied!
Successful Response
{
"login_state": "LoginRequired"
}
CopyCopied!
fetchMfaStatusWithNewSecret
Fetches the current user's MFA status. If they do not have MFA enabled, it will provide you with a QR code to help get your user enrolled.
Success Response
- Name
typeTypestringDescription
The type of response depending on if the user has MFA enabled or disabled. Returns either Disabled or Enabled.
- Name
mfa_enabledTypebooleanDescription
Returns true if the current user has MFA enabled. Otherwise, returns false.
- Name
backup_codesTypestring[]Description
Only returned if mfa_enabled equals true. Returns the current users MFA backup codes.
- Name
new_secretTypestringDescription
Only returned if mfa_enabled equals false.
- Name
new_qrTypestringDescription
Only returned if mfa_enabled equals false. The QR code the current user can scan to enable MFA.
- Name
has_passwordTypebooleanDescriptionIf the user has a password configured.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
emailNotConfirmedDescriptionUser has not yet confirmed their email address. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchMfaStatusWithNewSecret } = useAuthFrontendApis()
const response = await fetchMfaStatusWithNewSecret()
await response.handle({
success: (data) => {
if (data.mfa_enabled) {
console.log('MFA is enabled')
console.log('Backup codes: ', data.backup_codes)
} else {
console.log('MFA is disabled')
console.log('QR code to enable it: ', data.new_qr)
console.log('Secret to enable it: ', data.new_secret)
}
},
unexpectedOrUnhandled: (error) => {
console.error(error)
},
})
CopyCopied!
Successful Response
// if MFA disabled
{
"type": "Disabled",
"mfa_enabled": false,
"new_secret": "2CPN3MORX7...",
"new_qr": "iVBORw0KGgoAAAA...",
"has_password": true
}
// if MFA enabled
{
"type": "Enabled",
"mfa_enabled": true,
"backup_codes": [\
"6GD3YU5AQE",\
"P5NQ28DWR",\
"ICQ036M4L8"\
],
"has_password": true
}
CopyCopied!
fetchOrgApiKeys
Fetches a paginated list of an org's API keys. This will not return the full API key, just the Key ID, expiration, created at, and metadata.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org to fetch expired invites for. - Name
page_numberTypenumberDescriptionThe page number to return. Starts at 0. - Name
page_sizeTypenumberDescriptionThe amount of results per page. - Name
api_key_searchTypestringDescriptionFilter by Key ID. - Name
sort_byTypestringDescriptionCan be one of the following: 'CreatedAtAsc' | 'CreatedAtDesc' | 'ExpiresAtAsc' | 'ExpiresAtDesc'
Success Response
- Name
api_keysTypeOrgApiKey[]Description
An array of API Keys belonging to the provided org.
display_namestring | nullapi_key_idstringcreated_atnumberexpires_at_secondsnumber | nullmetadataobject | null
Name
total_api_keysTypenumberDescriptionThe total amount of API keys belonging to the org.Name
current_pageTypenumberDescriptionThe current page.Name
page_sizeTypenumberDescriptionThe maximum amount of results of the page.Name
has_more_resultsTypebooleanDescriptionReturns true of there are more results beyond the current page.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgApiKeysDisabledDescriptionOrg API keys are not enabled in your PropelAuth project. - Name
badRequestDescriptionIncorrect arguments provided. - Name
orgNotFoundDescriptionThe provided Org ID was not found. - Name
cannotAccessOrgApiKeysDescriptionThe user does not have permission to access org API keys. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchOrgApiKeys } = useAuthFrontendApis()
const response = await fetchOrgApiKeys({
org_id: '1189c444-8a2d-4c41-8b4b-ae43ce79a492',
page_number: 0,
page_size: 10,
api_key_search: '31c41c16-c2...',
})
await response.handle({
success: (data) => {
console.log(data)
},
orgApiKeysDisabled(error) {
console.error('Org API keys are disabled', error.user_facing_error)
},
orgNotFound(error) {
console.error('Org not found', error.user_facing_error)
},
cannotAccessOrgApiKeys(error) {
console.error('Cannot access org API keys', error.user_facing_error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"api_keys": [\
{\
"display_name": "My API Key",\
"api_key_id": "eeb1dfea92cadc475dfce6d93aeac567",\
"created_at": 1732639470,\
"expires_at_seconds": 1732645813,\
"metadata": null\
},\
{\
"api_key_id": "e51c60d190d85d196c07c0caa44389c4",\
"created_at": 1731707412,\
"expires_at_seconds": null,\
"metadata": {\
"example": "test"\
}\
}\
],
"total_api_keys": 2,
"current_page": 0,
"page_size": 10,
"has_more_results": false
}
CopyCopied!
fetchOrgMembers
Fetches a paginated list of an org's members.
Arguments
- Name
orgId*TypestringDescriptionThe ID of the org. - Name
page_numberTypenumberDescriptionThe page number to return. Starts at 0. - Name
page_sizeTypenumberDescriptionThe amount of results per page. - Name
email_searchTypestringDescriptionFilter by member email.
Success Response
- Name
usersTypeOrgMember[]Description
An array of API Keys belonging to the provided org.
user_idstringemailstringrolestringadditional_rolesstring[]possible_rolesstring[]can_be_deletedbooleanis_enabledbooleanis_2fa_enabledboolean
Name
total_countTypenumberDescriptionThe total amount of org members.Name
page_numberTypenumberDescriptionThe current page.Name
page_sizeTypenumberDescriptionThe maximum amount of results of the page.Name
has_more_resultsTypebooleanDescriptionReturns true of there are more results beyond the current page.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
Request
const { fetchOrgMembers } = useAuthFrontendApis()
const response = await fetchOrgMembers('1189c444-8a2d-4c41-8b4b-ae43ce79a492', {
page_number: 0,
page_size: 10,
email_search: "test@example.com",
});
await response.handle({
success: (data) => {
console.log(data)
},
orgNotFound(error) {
console.error('Org not found', error);
},
orgsNotEnabled(error) {
console.error('Org not enabled', error);
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error);
},
});
CopyCopied!
Successful Response
{
"users": [\
{\
"user_id": "1d31f06...",\
"email": "test@example.com",\
"role": "Owner",\
"additional_roles": [],\
"possible_roles": [\
"Owner",\
"Admin",\
"Member"\
],\
"can_be_deleted": true,\
"is_enabled": true,\
"is_2fa_enabled": true\
},\
{\
"user_id": "d20605...",\
"email": "test2@example.com",\
"role": "Admin",\
"additional_roles": [],\
"possible_roles": [\
"Owner",\
"Admin",\
"Member"\
],\
"can_be_deleted": true,\
"is_enabled": true,\
"is_2fa_enabled": false\
}\
],
"total_count": 2,
"page_number": 0,
"page_size": 10,
"has_more_results": false
}
CopyCopied!
fetchOrgSettings
Fetches the provided org's settings and information, such as org name, SAML status, 2FA requirements, and more.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org.
Success Response
- Name
org_nameTypestringDescriptionThe name of the organization. - Name
user_can_edit_org_accessTypebooleanDescriptionReturns true if the user has the necessary permissions to update the org settings. - Name
user_can_update_metadataTypebooleanDescriptionReturns true if the user has the necessary permissions to update the org metadata. - Name
autojoin_by_domainTypebooleanDescriptionIf a domain is set for the org, new users can join the org if their domain matches the org's domain. - Name
restrict_to_domainTypebooleanDescriptionIf a domain is set for the org, only allow users with that domain to join. - Name
require_2fa_byTypestring | nullDescriptionThe date by which 2FA is required for the org. If null, 2FA is not required. - Name
existing_domainTypestring | nullDescriptionThe org's current domain, if one is set. - Name
current_user_domainTypestringDescriptionThe domain of the current user. - Name
current_user_domain_is_personalTypebooleanDescriptionReturns true if the current user's domain is personal (e.g. gmail.com). - Name
can_setup_samlTypebooleanDescription
Returns true if the org can set up SAML.
- Name
is_saml_enabledTypebooleanDescription
Returns true if the org has SAML enabled.
- Name
is_saml_in_test_modeTypebooleanDescription
Returns true if the org has SAML in test mode.
- Name
can_setup_scimTypebooleanDescription
Returns true if the org can set up SCIM.
- Name
is_scim_enabledTypebooleanDescription
Returns true if the org can set has SCIM enabled.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgsNotEnabledDescriptionOrgs are not enabled in the PropelAuth dashboard. - Name
orgNotFoundDescriptionThe provided organization was not found. - Name
forbiddenDescriptionThe user does not have permission to view the organization settings. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchOrgSettings } = useAuthFrontendApis()
const response = await fetchOrgSettings('1189c444-8a2d-4c41-8b4b-ae43ce79a492')
await response.handle({
success: (data) => {
console.log(data)
},
orgsNotEnabled() {
console.log('Organizations are not enabled.')
},
orgNotFound() {
console.log('Organization not found.')
},
forbidden() {
console.log("You do not have permission to view this organization's settings.")
},
unexpectedOrUnhandled() {
console.log('An unexpected error occurred.')
},
})
CopyCopied!
Successful Response
{
"user_can_update_metadata": true,
"user_can_edit_org_access": true,
"org_name": "Acme Inc",
"autojoin_by_domain": true,
"restrict_to_domain": true,
"existing_domain": "acmeinc.com",
"current_user_domain": "acmeinc.com",
"current_user_domain_is_personal": false,
"require_2fa_by": "1732645813",
"can_setup_saml": true,
"is_saml_enabled": false,
"is_saml_in_test_mode": false,
"can_setup_scim": false,
"is_scim_enabled": false
}
CopyCopied!
fetchPendingOrgInvites
Fetches a paginated list of an org's invites.
Arguments
Success Response
- Name
pending_invitesTypePendingOrgInvite[]Description
An array of invites for the provided org.
emailstringrolestringadditional_rolesstring[]expires_at_secondsnumber
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
Request
const { fetchPendingOrgInvites } = useAuthFrontendApis()
const response = await fetchPendingOrgInvites("1189c444-8a2d-4c41-8b4b-ae43ce79a492", {
page_number: 0,
page_size: 10,
email_search: "test@test.com",
});
await response.handle({
success: (data) => {
console.log("success")
},
orgNotFound(error) {
console.error('Org not found', error);
},
orgsNotEnabled(error) {
console.error('Org not enabled', error);
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error);
},
});
CopyCopied!
Successful Response
{
"pending_invites": [\
{\
"email": "test@example.com",\
"role": "Admin",\
"additional_roles": [],\
"expires_at_seconds": 1737217437\
}\
],
"total_count": 1,
"page_number": 0,
"page_size": 10,
"has_more_results": false
}
CopyCopied!
fetchPersonalApiKeys
Fetches a paginated list of the user's API keys. This will not return the full API key, just the Key ID, expiration, created at, and metadata.
Arguments
- Name
page_numberTypenumberDescriptionThe page number to return. Starts at 0. - Name
page_sizeTypenumberDescriptionThe amount of results per page. - Name
api_key_searchTypestringDescriptionFilter by Key ID. - Name
sort_byTypestringDescriptionCan be one of the following: 'CreatedAtAsc' | 'CreatedAtDesc' | 'ExpiresAtAsc' | 'ExpiresAtDesc'
Success Response
- Name
api_keysTypePersonalApiKey[]Description
An array of API Keys belonging to the logged in user.
display_namestring | nullapi_key_idstringcreated_atnumberexpires_at_secondsnumber | nullmetadataobject | null
Name
total_api_keysTypenumberDescriptionThe total amount of API keys belonging to the user.Name
current_pageTypenumberDescriptionThe current page.Name
page_sizeTypenumberDescriptionThe maximum amount of results of the page.Name
has_more_resultsTypebooleanDescriptionReturns true of there are more results beyond the current page.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
personalApiKeysDisabledDescriptionAPI keys are not enabled in your PropelAuth project. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { fetchPersonalApiKeys } = useAuthFrontendApis()
const response = await fetchPersonalApiKeys({
page_number: 0,
page_size: 10,
api_key_search: '1189c444-8a...',
})
await response.handle({
success: (data) => {
console.log(data)
},
personalApiKeysDisabled(error) {
console.error('Personal API keys are disabled', error.user_facing_error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"api_keys": [\
{\
"display_name": "My API Key",\
"api_key_id": "26bafab...",\
"created_at": 1736553453,\
"expires_at_seconds": 1737763053,\
"metadata": null\
},\
{\
"api_key_id": "df71d4e1...",\
"created_at": 1736553453,\
"expires_at_seconds": 1737763053,\
"metadata": {\
"test": "example"\
}\
}\
],
"total_api_keys": 2,
"current_page": 0,
"page_size": 10,
"has_more_results": false
}
CopyCopied!
inviteUserToOrg
Sends an invitation to a user to join an organization.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org. - Name
email*TypestringDescriptionThe email of the user who is being invited. - Name
role*TypestringDescriptionThe role the user will have. - Name
additional_rolesTypestring[]Description
If using multiple roles per user, an array of additional roles for the user.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
noInvitePermissionDescriptionThe user does not have permission to invite other users to the organization. - Name
orgNotFoundDescriptionThe org ID cannot be found. - Name
orgsNotEnabledDescriptionOrganizations are not enabled for the project. - Name
userAlreadyInOrgDescriptionThe email provided is already a member of the organization. - Name
orgMaxUsersLimitExceededDescriptionThe org's user limit has already been met. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { inviteUserToOrg } = useAuthFrontendApis()
const response = await inviteUserToOrg({
org_id: '1189c444-8a2d-4c41-8b4b-ae43ce79a492',
email: 'test@example.com',
role: 'Admin',
// if using multi-role support
additional_roles: [\
"Member"\
]
})
response.handle({
success: () => {
console.log('User invited')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
noInvitePermission(error) {
console.error('No invite permission', error)
},
orgNotFound(error) {
console.error('Org not found', error)
},
orgsNotEnabled(error) {
console.error('Org not enabled', error)
},
userAlreadyInOrg(error) {
console.error('User already in org', error)
},
orgMaxUsersLimitExceeded(error) {
console.error('Org max users limit exceeded', error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
joinOrg
Adds the logged in user as a member of the provided organization.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org to join.
Success Response
- Name
org_idTypestringDescriptionThe ID of the org. - Name
first_orgTypebooleanDescriptionIf the org is the first org the user belongs to.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
userAlreadyInTooManyOrgsDescriptionUser already belongs to the maximum amount of orgs. - Name
orgMaxUsersLimitExceededDescriptionThe org's user limit has already been met. - Name
orgsNotEnabledDescriptionOrganizations are not enabled for the project. - Name
orgNotFoundDescriptionThe org ID cannot be found. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { joinOrg } = useAuthFrontendApis()
const response = await joinOrg("1189c444-8a2d-4c41-8b4b-ae43ce79a492")
response.handle({
success(data) {
console.log("User added to org: ", data.org_id)
},
orgNotFound(error) {
console.error('Org not found', error)
},
orgsNotEnabled(error) {
console.error('Org not enabled', error)
},
userAlreadyInTooManyOrgs(error) {
console.error('User already in too many orgs', error)
},
orgMaxUsersLimitExceeded(error) {
console.error('Org max users limit exceeded', error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error)
},
})
CopyCopied!
Successful Response
{
"org_id": "1189c444-8a2d-4c41-8b4b-ae43ce79a492",
"first_org": true
}
CopyCopied!
loginViaSamlForOrg
Accepts either a domain, email, or org_id and returns a Enterprise SSO login URL for the specified organization. Works with both OIDC and SAML login.
Arguments
- Name
emailTypestringDescriptionThe email of the user. - Name
domainTypestringDescriptionThe domain of the user or organization, such as `acme.com`. - Name
org_idTypestringDescriptionThe ID of the organization.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgNotFoundDescriptionThe provided org_id or domain is not tied to an existing org with SAML enabled. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { loginViaSamlForOrg } = useAuthFrontendApis()
const response = await loginViaSamlForOrg({
// only one of these is required
email: "test@example.com",
domain: "acme.com",
org_id: "1189c444-8a2d-4c41-8b4b-ae43ce79a492"
})
response.handle({
success(data) {
// redirect to data.login_url
},
orgNotFound(error) {
console.error('Org not found', error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"login_url": "https://example.com/saml/login"
}
CopyCopied!
loginWithSocialProvider
Redirects the user to login with the specified Social Login provider. If signups are enabled, will create a new user if one does not already exist.
Arguments
- Name
provider*TypeSocialLoginProviderDescription
The provider to login with. Must be one of these options:
- Google
- Github
- Microsoft
- Slack
- Salesforce
- Outreach
- Quickbooks
- Xero
- Salesloft
- Atlassian
- Apple
Request
import { SocialLoginProvider } from '@propelauth/frontend-apis'
const { loginWithSocialProvider } = useAuthFrontendApis()
// Typescript version
<button onClick={() => loginWithSocialProvider(SocialLoginProvider.GITHUB)}>
Login with Github
</button>
// Javascript version
<button onClick={() => loginWithSocialProvider("Google")}>
Login with Google
</button>
CopyCopied!
passwordlessLogin
Sends a magic link to the user's email address to log them in.
Arguments
- Name
email*TypestringDescriptionThe email of the user to send a magic link to. - Name
create_if_doesnt_exist*TypebooleanDescriptionIf set to true, a new user will be created if the email is not associated with an existing user.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
passwordlessLoginDisabledDescriptionPasswordless login is disabled in the PropelAuth Dashboard. - Name
userAccountDisabledDescriptionUser cannot login due to their account being disabled. - Name
userAccountLockedDescriptionUser cannot login due to their account being locked. - Name
cannotSignupWithPersonalEmailDescriptionPersonal email domains are disabled in the PropelAuth Dashboard. - Name
domainNotAllowedDescriptionThe email domain is blocked in the PropelAuth Dashboard. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { passwordlessLogin } = useAuthFrontendApis()
const response = await passwordlessLogin({
email: "test@example.com",
create_if_doesnt_exist: false
})
response.handle({
success() {
console.log('Magic link sent')
},
userAccountDisabled(error) {
console.error('User account disabled', error.user_facing_error)
},
userAccountLocked(error) {
console.error('User account locked', error.user_facing_error)
},
passwordlessLoginDisabled(error) {
console.error('Passwordless login disabled', error.user_facing_error)
},
cannotSignupWithPersonalEmail(error) {
console.error('Cannot signup with personal email', error.user_facing_error)
},
domainNotAllowed(error) {
console.error('Domain not allowed', error.user_facing_error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
removeUserFromOrg
Removes the provided user from the provided organization.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org. - Name
user_id*TypestringDescriptionThe ID of the user to remove from the org.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgNotFoundDescriptionThe org ID cannot be found. - Name
userNotFoundInOrgDescriptionUser ID not found. - Name
noRemovePermissionDescriptionThe user doing the action does not have permission to remove the provided user from the org. - Name
orgsNotEnabledDescriptionOrganizations not enabled for this project. - Name
mustBeAtLeastOneOwnerDescriptionThe user you're trying to remove is the only Owner of the org. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { removeUserFromOrg } = useAuthFrontendApis()
const response = await removeUserFromOrg({
org_id: "1189c444-8a2d-4c41-8b4b-ae43ce79a492",
user_id: "31c41c16-c281-44ae-9602-8a047e3bf33d",
});
await response.handle({
success: async () => {
console.log('success')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
orgNotFound(error) {
console.error('Org not found', error);
},
userNotFoundInOrg(error) {
console.error('User not found', error);
},
noRemovePermission(error) {
console.error('No remove permission', error);
},
orgsNotEnabled(error) {
console.error('Org not enabled', error);
},
mustBeAtLeastOneOwner(error) {
console.error('There must be at least one user with the Owner role in this org', error);
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error);
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
resendEmailConfirmation
Sends another confirmation email to the logged in user.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
rateLimitedDescriptionToo many confirmation emails have been sent to this user in a short period of time. - Name
emailAlreadyConfirmedDescriptionThe user has already confirmed their email address. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { resendEmailConfirmation } = useAuthFrontendApis()
const response = await resendEmailConfirmation()
response.handle({
success() {
console.log('Confirmation email resent')
},
rateLimited(error) {
console.error('Rate limited', error.user_facing_error)
},
emailAlreadyConfirmed(error) {
console.error('Email already confirmed', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
revokeUserOrgInvitation
Revokes an existing invitation to a user to join an organization.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org. - Name
email*TypestringDescriptionThe email of the user.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgNotFoundDescriptionThe org ID cannot be found. - Name
noRevokeInvitePermissionDescriptionThe user doing the action does not have permission to revoke an invitation for the org. - Name
orgsNotEnabledDescriptionOrganizations not enabled for this project. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { revokeUserOrgInvitation } = useAuthFrontendApis()
const response = await revokeUserOrgInvitation({
org_id: "1189c444-8a2d-4c41-8b4b-ae43ce79a492",
email: "test@test.com",
});
await response.handle({
async success() {
console.log("success")
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
orgNotFound(error) {
console.error('Org not found', error);
},
orgsNotEnabled(error) {
console.error('Org not enabled', error);
},
noRevokeInvitePermission(error) {
console.error('No revoke invite permission', error);
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error);
},
});
CopyCopied!
Successful Response
{}
CopyCopied!
sendForgotPasswordEmail
Sends the user an email to reset their password if an account with that email exists.
Arguments
- Name
email*TypestringDescriptionThe email of the user
Success Response
- Name
messageTypestringDescriptionA confirmation message, such as 'If that email address is in our database, we will send you an email to reset your password.' - Name
sniper_linksTypedictionaryDescription
A dictionary of sniper links you can provide to the user for gmail, outlook, and yahoo.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { sendForgotPasswordEmail } = useAuthFrontendApis()
const response = await sendForgotPasswordEmail({
email: "test@example.com"
})
response.handle({
success(data) {
console.log(data)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"message": "If that email address is in our database, we will send you an email to reset your password.",
"sniper_links": {
"gmail": "https://mail.google.com/mail/u/0/#search/propelauth",
"outlook": "https://outlook.live.com/mail/0/inbox",
"yahoo": "https://mail.yahoo.com/d/folders/1"
}
}
CopyCopied!
signup
Create a user for your application using email and password. See passwordlesslogin and loginWithSocialProvider for alternative ways to sign users up.
Arguments
- Name
email*TypestringDescriptionThe email of the user to create. - Name
password*TypestringDescriptionThe password of the user to create. - Name
usernameTypestringDescription
The username of the user to create. See User Properties for more information.
- Name
first_nameTypestringDescription
The first name of the user to create. See User Properties for more information.
- Name
last_nameTypestringDescription
The last name of the user to create. See User Properties for more information.
- Name
propertiesTypedictionaryDescription
A dictionary of custom properties of the user to create. See Custom User Properties for more information.
- Name
invite_tokenTypestringDescription
The token included as a invite_token URL parameter in the invite link sent to the invited user.
- Name
turnstile_tokenTypestringDescription
The token returned by the Turnstile widget. Required if using the PropelAuth Cloudflare Turnstile Integration.
Success Response
- Name
login_stateTypeLoginStateDescription
Returns one of the following:
- Name
user_idTypestringDescriptionThe ID of the user that was created.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
signupDisabledDescriptionSignups are disabled in the PropelAuth Dashboard. - Name
badRequestDescriptionIncorrect arguments provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { signup } = useAuthFrontendApis()
const response = await signup({
email: "test@example.com",
password: "password",
username: "airbud3",
first_name: "Buddy",
last_name: "Framm",
properties: {
favoriteSport: "Basketball"
},
invite_token: "eyJvcmdfaWQ...",
turnstile_token: "0.sSXqFt-EH..Z"
})
response.handle({
success(data) {
// handle login state
},
signupDisabled(error) {
console.error('Signups are disabled', error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"login_state": "Finished",
"user_id": "bf186f61-b204-4dd6-a6dc-a4ba2c97db1d"
}
CopyCopied!
updateApiKey
Updates the display name of an API Key.
Arguments
- Name
api_key_id*TypestringDescriptionThe ID of the API Key to be updated. - Name
display_name*TypestringDescriptionThe new name of the API Key.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
apiKeyNotFoundDescriptionAPI Key ID not associated with an API key that belongs to the user. - Name
noApiKeyPermissionDescriptionUser does not have permission to update the API key. - Name
unauthorizedDescriptionThe user is not logged in. - Name
badRequestDescriptionIncorrect arguments given. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { updateApiKey } = useAuthFrontendApis()
const response = await updateApiKey({
api_key_id: 'c45ccb5055080ad0ebb03d43e6332f5d',
display_name: 'My API Key',
})
response.handle({
success: async () => {
console.log('success')
},
apiKeyNotFound(error) {
console.error('API key not found', error.user_facing_error)
},
noApiKeyPermission(error) {
console.error('Forbidden', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error.user_facing_error)
},
badRequest(error) {
console.error(error.user_facing_errors.display_name)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
updateEmail
Starts the update email flow by sending a confirmation email to the user. If the user accepts, their email will be updated.
Arguments
- Name
new_email*TypestringDescriptionThe email address the user wants to change their email to. - Name
passwordTypestringDescriptionAn optional argument to check if the user can provide the correct password. Required if the user has a password set.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
cannotChangeEmailDueToOrgMembershipDescriptionUser belongs to an organization that enforces an email domain restriction. - Name
rateLimitDescriptionToo many requests made for this specific user to update their email. - Name
emailChangeDisabledDescription'Allow users to change their email' disabled in PropelAuth dashboard. - Name
failedToSendEmailDescriptionThere was an error in sending the user the confirmation email. - Name
incorrectPasswordDescriptionThe user provided an incorrect password. - Name
userAccountLockedDescriptionThe user's account is locked. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { updateEmail } = useAuthFrontendApis()
const response = await updateEmail({
new_email: 'test@example.com',
password: 'password',
})
response.handle({
success: () => {
console.log('Email update confirmation sent successfully')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
failedToSendEmail: (error) => {
console.log('Failed to send email', error.user_facing_error)
},
incorrectPassword: (error) => {
console.log('The user provided an incorrect password', error.user_facing_error)
},
userAccountLocked: (error) => {
console.log('User account locked', error.user_facing_error)
},
rateLimit: (error) => {
console.log('Rate limit error', error.user_facing_error)
},
emailChangeDisabled: (error) => {
console.error('Email change disabled', error.user_facing_error)
},
cannotChangeEmailDueToOrgMembership: (error) => {
console.log('Cannot change email due to org membership', error.user_facing_error)
},
unexpectedOrUnhandled(error) {
console.log('Unexpected or unhandled error', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
updateOrgSettings
Updates the settings for an organization.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org to be updated. - Name
nameTypestringDescriptionThe new name of the org. - Name
allow_users_to_join_by_domainTypebooleanDescriptionIf a domain is set for the org, new users can join the org if their domain matches the org's domain. - Name
restrict_invites_by_domainTypebooleanDescriptionIf a domain is set for the org, only allow users with that domain to join. - Name
require_2fa_byTypedateDescriptionIf requiring 2FA for an org, the date you want to enforce it by.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
orgsNotEnabledDescriptionOrganizations are not enabled in this project. - Name
orgNotFoundDescriptionThe provided orgId was not found - Name
forbiddenDescriptionThe user does not have permission to edit the org. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { updateOrgSettings } = useAuthFrontendApis()
const response = await updateOrgSettings({
org_id: '1189c444-8a2d-4c41-8b4b-ae43ce79a492',
name: 'Acme Inc',
allow_users_to_join_by_domain: true,
restrict_invites_by_domain: true,
require_2fa_by: '2025-01-16T00:00:00.000Z',
})
response.handle({
success() {
console.log('Updated org settings successfully.')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
orgsNotEnabled(error) {
console.log('Org not enabled', error)
},
orgNotFound(error) {
console.log('Org not found', error)
},
forbidden(error) {
console.log('Forbidden', error)
},
unexpectedOrUnhandled(error) {
console.log('Unexpected or unhandled error', error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
updatePassword
Updates the logged in user's password.
Arguments
- Name
password*TypestringDescriptionThe user's new password. - Name
current_passwordTypestringDescriptionAn optional argument to check if the user can provide the correct current password. Required if the user already has a password set.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
incorrectPasswordDescriptionUser was not able to provide the correct current password. - Name
userAccountLockedDescriptionThe user's account is locked. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { updatePassword } = useAuthFrontendApis()
const response = await updatePassword({
current_password: 'currentPassword',
password: 'newPassword',
})
response.handle({
success: () => {
console.log('Password updated')
},
incorrectPassword(error) {
console.log('Incorrect password', error.user_facing_error)
},
userAccountLocked(error) {
setGlobalError('User Account is locked', error.user_facing_error)
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
updateUserMetadata
Updates user property fields such as username, first_name, last_name, and any custom user properties.
Arguments
- Name
usernameTypestringDescriptionThe user's new username. - Name
first_nameTypestringDescriptionThe user's new first name. - Name
last_nameTypestringDescriptionThe user's new last name. - Name
propertiesType{[key: string]: unknown}Description
An object containing any custom user properties.
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { updateUserMetadata } = useAuthFrontendApis()
const response = await updateUserMetadata({
username: 'airbud3',
first_name: 'Buddy',
last_name: 'Framm',
properties: {
favorite_sport: 'basketball',
},
})
await response.handle({
success: () => {
console.log('Updated user properties successfully.')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{}
CopyCopied!
updateUserRoleInOrg
Updates the provided user's role within the provided organization.
Arguments
- Name
org_id*TypestringDescriptionThe ID of the org. - Name
user_id*TypestringDescriptionThe ID of the user. - Name
role*TypestringDescriptionThe role the user will be updated to. - Name
additional_rolesTypestring[]Description
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
noUpdateRolePermissionDescriptionUser does not have permission to update this user's role. - Name
userNotFoundInOrgDescriptionUser ID not found. - Name
orgsNotEnabledDescriptionOrganizations not enabled for this project. - Name
badRequestDescriptionIncorrect arguments given. - Name
unauthorizedDescriptionThe user is not logged in. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { updateUserRoleInOrg } = useAuthFrontendApis()
const response = await updateUserRoleInOrg({
org_id: "1189c444-8a2d-4c41-8b4b-ae43ce79a492",
user_id: "31c41c16-c281-44ae-9602-8a047e3bf33d",
role: "Admin",
// if using multi-role support
additional_roles: [\
"Member"\
]
});
await response.handle({
success: async () => {
console.log('success')
},
badRequest(error) {
for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
}
},
userNotFoundInOrg(error) {
console.error('User not found', error);
},
noUpdateRolePermission(error) {
console.error('No update role permission', error);
},
orgsNotEnabled(error) {
console.error('Org not enabled', error);
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled error', error);
},
});
CopyCopied!
Successful Response
{}
CopyCopied!
verifyMfaBackupCodeForLogin
Verifies the user's MFA code for login.
Arguments
- Name
code*TypestringDescriptionThe user's MFA backup code
Success Response
- Name
login_stateTypeLoginStateDescription
Returns one of the following:
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
invalidCodeDescriptionInvalid code provided. - Name
mfaCookieTimeoutDescriptionThe user's MFA session has timed out. They must log in again to continue. - Name
userAccountDisabledDescriptionUser cannot login due to their account being disabled. - Name
userAccountLockedDescriptionUser cannot login due to their account being locked. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { verifyMfaBackupCodeForLogin } = useAuthFrontendApis()
const response = await verifyMfaBackupCodeForLogin({
code: "123456",
})
response.handle({
success() {
// handle login state
},
invalidCode(error) {
console.error('Invalid code provided', error)
},
userAccountDisabled(error) {
console.error('User account disabled', error)
},
userAccountLocked(error) {
console.error('User account locked', error)
},
mfaCookieTimeout(error) {
console.error('Session timeout', error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"login_state": "Finished"
}
CopyCopied!
verifyMfaForLogin
Verifies the user's MFA code for login.
Arguments
- Name
code*TypestringDescriptionThe MFA code generated by your user's authenticator.
Success Response
- Name
login_stateTypeLoginStateDescription
Returns one of the following:
Response Functions
The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.
- Name
successDescriptionSuccessful request. - Name
mfaCookieTimeoutDescriptionThe user's MFA session has timed out. They must log in again to continue. - Name
userAccountDisabledDescriptionUser cannot login due to their account being disabled. - Name
userAccountLockedDescriptionUser cannot login due to their account being locked. - Name
badRequestDescriptionIncorrect arguments provided or incorrect code provided. - Name
unexpectedOrUnhandledDescriptionAn unexpected error occurred.
Request
const { verifyMfaForLogin } = useAuthFrontendApis()
const response = await verifyMfaForLogin({
code: "123456",
})
response.handle({
success() {
// handle login state
},
userAccountDisabled(error) {
console.error('User account disabled', error)
},
userAccountLocked(error) {
console.error('User account locked', error)
},
mfaCookieTimeout(error) {
console.error('Session timeout', error)
},
badRequest(error) {
console.error('Bad request', error)
},
unexpectedOrUnhandled(error) {
console.error('Unexpected or unhandled', error.user_facing_error)
},
})
CopyCopied!
Successful Response
{
"login_state": "Finished"
}
CopyCopied!