Skip to main content

users

Creates, updates, deletes, gets or lists a users resource.

Overview

Nameusers
TypeResource
Idokta.users.users

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe unique key for the user
_embeddedobjectEmbedded resources related to the user using the JSON Hypertext Application Language specification
_linksobjectSpecifies link relations (see Web Linking) available using the JSON Hypertext Application Language specification. This object is used for dynamic discovery of related resources and lifecycle operations.
activatedstring (date-time)The timestamp when the user status transitioned to ACTIVE
createdstring (date-time)The timestamp when the user was created
credentialsobjectSpecifies primary authentication and recovery credentials for a user. Credential types and requirements vary depending on the provider and security policy of the org.
lastLoginstring (date-time)The timestamp of the last login
lastUpdatedstring (date-time)The timestamp when the user was last updated
passwordChangedstring (date-time)The timestamp when the user's password was last updated
profileobjectSpecifies the default and custom profile properties for a user. The default user profile is based on the System for Cross-domain Identity Management: Core Schema. The only permitted customizations of the default profile are to update permissions, change whether the firstName and lastName properties are nullable, and specify a pattern for login. You can use the Profile Editor in the Admin Console or the Schemas API to make schema modifications. You can extend user profiles with custom properties. You must first add the custom property to the user profile schema before you reference it. You can use the Profile Editor in the Admin Console or the Schemas API to manage schema extensions. Custom attributes can contain HTML tags. It's the client's responsibility to escape or encode this data before displaying it. Use best-practices to prevent cross-site scripting.
realmIdstringThe ID of the realm in which the user is residing. See Realms. (example: guo1bfiNtSnZYILxO0g4)
statusstringThe current status of the user. The status of a user changes in response to explicit events, such as admin-driven lifecycle changes, user login, or self-service password recovery. Okta doesn't asynchronously sweep through users and update their password expiry state, for example. Instead, Okta evaluates password policy at login time, notices the password has expired, and moves the user to the expired state. When running reports, remember that the data is valid as of the last login or lifecycle event for that user.
statusChangedstring (date-time)The timestamp when the status of the user last changed
transitioningToStatusstringThe target status of an in-progress asynchronous status transition. This property is only returned if the user's state is transitioning.
typeobjectThe user type that determines the schema for the user's profile. The type property is a map that identifies the User Types. Currently it contains a single element, id. It can be specified when creating a new user, and ca be updated by an admin on a full replace of an existing user (but not a partial update).

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_usersselectsubdomainContent-Type, search, filter, q, after, limit, sortBy, sortOrder, expandLists users in your org, with pagination in most cases.

A subset of users can be returned that match a supported filter expression or search criteria. Different results are returned depending on specified queries in the request.

> Note: This operation omits users that have a status of DEPROVISIONED in the response. To return all users, use a filter or search query instead.
get_userselectsubdomainContent-Type, expandRetrieves a user from your Okta org.

You can substitute me for the id to fetch the current user linked to an API token or session cookie.
* The request returns the user linked to the API token that is specified in the Authorization header, not the user linked to the active session. Details of the admin user who granted the API token is returned.
* When the end user has an active Okta session, it is typically a CORS request from the browser. Therefore, it's possible to retrieve the current user without the Authorization header.

When fetching a user by login or login shortname, URL encode the request parameter to ensure that special characters are escaped properly. Logins with a / character can only be fetched by id due to URL issues with escaping the / character. If you don't know a user's ID, you can use the List all users endpoint to find it.

> Note: Some browsers block third-party cookies by default, which disrupts Okta functionality in certain flows. See Mitigate the impact of third-party cookie deprecation.
create_userinsertsubdomain, data__profileactivate, provider, nextLoginCreates a new user in your Okta org with or without credentials.

> Legal Disclaimer
>
> After a user is added to the Okta directory, they receive an activation email. As part of signing up for this service,
> you agreed not to use Okta's service/product to spam and/or send unsolicited messages.
> Please refrain from adding unrelated accounts to the directory as Okta is not responsible for, and disclaims any and all
> liability associated with, the activation email's content. You, and you alone, bear responsibility for the emails sent to any recipients.

All responses return the created user. Activation of a user is an asynchronous operation. The system performs group reconciliation during activation and assigns the user to all apps via direct or indirect relationships (group memberships).
* The user's transitioningToStatus property is ACTIVE during activation to indicate that the user hasn't completed the asynchronous operation.
* The user's status is ACTIVE when the activation process is complete.

The user is emailed a one-time activation token if activated without a password.

> Note: If the user is assigned to an app that is configured for provisioning, the activation process triggers downstream provisioning to the app. It is possible for a user to sign in before these apps have been successfully provisioned for the user.

> Important: Do not generate or send a one-time activation token when activating users with an assigned password. Users should sign in with their assigned password.

For more information about the various scenarios of creating a user listed in the examples, see the User creation scenarios section.
update_userupdatesubdomainstrict, If-MatchUpdates a user's profile or credentials with partial update semantics.

> Important: Use the POST method for partial updates. Unspecified properties are set to null with PUT.

profile and credentials can be updated independently or together with a single request.
> Note: Currently, the user type of a user can only be changed via a full replacement PUT operation. If the request parameters of a partial update include the type element from the user object,
the value must match the existing type of the user. Only admins are permitted to change the user type of a user; end users are not allowed to change their own user type.

> Note: To update a current user's profile with partial semantics, the /api/v1/users/me endpoint can be invoked.
>
> A user can only update profile properties for which the user has write access. Within the profile, if the user tries to update the primary or the secondary email IDs, verification emails are sent to those email IDs, and the fields are updated only upon verification.

If you are using this endpoint to set a password, it sets a password without validating existing user credentials. This is an administrative operation. For operations that validate credentials, refer to the Reset password, Start forgot password flow, and Update password endpoints.
replace_userreplacesubdomainstrict, If-MatchReplaces a user's profile, credentials, or both using strict-update semantics.

All profile properties must be specified when updating a user's profile with a PUT method. Any property not specified in the request is deleted.
> Important: Don't use a PUT method for partial updates.
delete_userdeletesubdomainsendEmail, PreferDeletes a user permanently. This operation can only be performed on users that have a DEPROVISIONED status.

> Warning: This action can't be recovered!

This operation on a user that hasn't been deactivated causes that user to be deactivated. A second delete operation is required to delete the user.

> Note: You can also perform user deletion asynchronously. To invoke asynchronous user deletion, pass an HTTP header Prefer: respond-async with the request.

This header is also supported by user deactivation, which is performed if the delete endpoint is invoked on a user that hasn't been deactivated.
end_user_sessionsexecsubdomainEnds Okta sessions for the currently signed in user. By default, the current session remains active. Use this method in a browser-based app.
> Note: This operation requires a session cookie for the user. The API token isn't allowed for this operation.
activate_userexecsubdomainsendEmailActivates a user.

Perform this operation only on users with a STAGED or DEPROVISIONED status. Activation of a user is an asynchronous operation.
* The user has the transitioningToStatus property with an ACTIVE value during activation. This indicates that the user hasn't completed the asynchronous operation.
* The user has an ACTIVE status when the activation process completes.

Users who don't have a password must complete the welcome flow by visiting the activation link to complete the transition to ACTIVE status.

> Note: If you want to send a branded user activation email, change the subdomain of your request to the custom domain that's associated with the brand.
> For example, change subdomain.okta.com to custom.domain.one. See Multibrand and custom domains.

> Note: If you have optional password enabled, visiting the activation link is optional for users who aren't required to enroll a password.
> See Create user with optional password.

> Legal disclaimer
> After a user is added to the Okta directory, they receive an activation email. As part of signing up for this service,
> you agreed not to use Okta's service/product to spam and/or send unsolicited messages.
> Please refrain from adding unrelated accounts to the directory as Okta is not responsible for, and disclaims any and all
> liability associated with, the activation email's content. You, and you alone, bear responsibility for the emails sent to any recipients.
deactivate_userexecsubdomainsendEmail, PreferDeactivates a user.

Perform this operation only on users that do not have a DEPROVISIONED status.
* The user's transitioningToStatus property is DEPROVISIONED during deactivation to indicate that the user hasn't completed the asynchronous operation.
* The user's status is DEPROVISIONED when the deactivation process is complete.

> Important: Deactivating a user is a destructive operation. The user is deprovisioned from all assigned apps, which might destroy their data such as email or files.
This action cannot be recovered!

You can also perform user deactivation asynchronously. To invoke asynchronous user deactivation, pass an HTTP header Prefer: respond-async with the request.
expire_passwordexecsubdomainExpires the password. This operation transitions the user status to PASSWORD_EXPIRED so that the user must change their password the next time that they sign in.


If you have integrated Okta with your on-premises Active Directory (AD), then setting a user's password as expired in Okta also expires the password in AD.
When the user tries to sign in to Okta, delegated authentication finds the password-expired status in AD,
and the user is presented with the password-expired page where they can change their password.

> Note: The Okta account management policy doesn't support the /users/{id}/lifecycle/expire_password endpoint. See Configure an Okta account management policy.
expire_password_with_temp_passwordexecsubdomainrevokeSessionsExpires the password and resets the user's password to a temporary password. This operation transitions the user status to PASSWORD_EXPIRED so that the user must change their password the next time that they sign in.
The user's password is reset to a temporary password that's returned, and then the user's password is expired.
If revokeSessions is included in the request with a value of true, the user's current outstanding sessions are revoked and require re-authentication.


If you have integrated Okta with your on-premises Active Directory (AD), then setting a user's password as expired in Okta also expires the password in AD.
When the user tries to sign in to Okta, delegated authentication finds the password-expired status in AD,
and the user is presented with the password-expired page where they can change their password.
reactivate_userexecsubdomainsendEmailReactivates a user.

Perform this operation only on users with a PROVISIONED or RECOVERY status.
This operation restarts the activation workflow if for some reason the user activation wasn't completed when using the activationToken from Activate User.

Users that don't have a password must complete the flow by completing the Reset password flow and MFA enrollment steps to transition the user to ACTIVE status.

If sendEmail is false, returns an activation link for the user to set up their account. The activation token can be used to create a custom activation link.
reset_factorsexecsubdomainResets all factors for the specified user. All MFA factor enrollments return to the unenrolled state. The user's status remains ACTIVE. This link is present only if the user is currently enrolled in one or more MFA factors.
reset_passwordexecsendEmail, subdomainrevokeSessionsResets a password. Generates a one-time token (OTT) that you can use to reset a user's password. You can automatically email the OTT link to the user or return the OTT to the API caller and distribute using a custom flow.

This operation transitions the user to the RECOVERY status. The user is then not able to sign in or initiate a forgot password flow until they complete the reset flow.

This operation provides an option to delete all the user's sessions. However, if the request is made in the context of a session owned by the specified user, that session isn't cleared.
> Note: You can also use this API to convert a user with the Okta credential provider to use a federated provider. After this conversion, the user can't directly sign in with a password.
> To convert a federated user back to an Okta user, use the default API call.

If an email address is associated with multiple users, keep in mind the following to ensure a successful password recovery lookup:
* Okta no longer includes deactivated users in the lookup.
* The lookup searches sign-in IDs first, then primary email addresses, and then secondary email addresses.
If sendEmail is false, returns a link for the user to reset their password.
suspend_userexecsubdomainSuspends a user. Perform this operation only on users with an ACTIVE status. The user has a SUSPENDED status when the process completes.

Suspended users can't sign in to Okta. They can only be unsuspended or deactivated. Their group and app assignments are retained.
unlock_userexecsubdomainUnlocks a user with a LOCKED_OUT status or unlocks a user with an ACTIVE status that's blocked from unknown devices. Unlocked users have an ACTIVE status and can sign in with their current password.
> Note: This operation works with Okta-sourced users. It doesn't support directory-sourced accounts such as Active Directory.
unsuspend_userexecsubdomainUnsuspends a user and returns them to the ACTIVE state. This operation can only be performed on users that have a SUSPENDED status.
change_passwordexecsubdomainstrictUpdates a user's password by validating the user's current password.

This operation provides an option to delete all the sessions of the specified user. However, if the request is made in the context of a session owned by the specified user, that session isn't cleared.

You can only perform this operation on users in STAGED, ACTIVE, PASSWORD_EXPIRED, or RECOVERY status that have a valid password credential.

The user transitions to ACTIVE status when successfully invoked in RECOVERY status.

> Note: The Okta account management policy doesn't support the /users/{userId}/credentials/change_password endpoint. See Configure an Okta account management policy.
change_recovery_questionexecsubdomainUpdates a user's recovery question and answer credential by validating the user's current password.
You can only perform this operation on users in STAGED, ACTIVE, or RECOVERY status that have a valid password credential.
forgot_passwordexecsubdomainsendEmailStarts the forgot password flow.

Generates a one-time token (OTT) that you can use to reset a user's password.

The user must validate their security question's answer when visiting the reset link. Perform this operation only on users with an ACTIVE status and
a valid recovery question credential.

> Note: If you have migrated to Identity Engine, you can allow users to recover passwords with any enrolled MFA authenticator. See Self-service account recovery.

If an email address is associated with multiple users, keep in mind the following to ensure a successful password recovery lookup:
* Okta no longer includes deactivated users in the lookup.
* The lookup searches sign-in IDs first, then primary email addresses, and then secondary email addresses.

If sendEmail is false, returns a link for the user to reset their password. This operation doesn't affect the status of the user.
forgot_password_set_new_passwordexecsubdomainsendEmailResets the user's password to the specified password if the provided answer to the recovery question is correct.
You must include the recovery question answer with the submission.
revoke_user_sessionsexecsubdomainoauthTokens, forgetDevicesRevokes all active identity provider sessions of the user. This forces the user to authenticate on the next operation. Optionally revokes OpenID Connect and OAuth refresh and access tokens issued to the user.

You can also clear the user's remembered factors for all devices using the forgetDevices parameter. See forgetDevices.
> Note: This operation doesn't clear the sessions created for web or native apps.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
sendEmailboolean
subdomainstringThe domain of your organization. This can be a provided subdomain of an official okta domain (okta.com, oktapreview.com, etc) or one of your configured custom domains. (default: my-org)
Content-TypestringSpecifies the media type of the resource. Optional okta-response value can be included for performance optimization. Complex DelAuth configurations may degrade performance when fetching specific parts of the response, and passing this parameter can omit these parts, bypassing the bottleneck. Enum values for okta-response: * omitCredentials: Omits the credentials subobject from the response. * omitCredentialsLinks: Omits the following HAL links from the response: Update password, Change recovery question, Start forgot password flow, Reset password, Reset factors, Unlock. * omitTransitioningToStatus: Omits the transitioningToStatus field from the response.
If-MatchstringThe ETag value of the user's expected current state. This becomes a conditional request used for concurrency control. See [Conditional Requests and Entity Tags]https://developer.okta.com/docs/api#conditional-requests-and-entity-tags. (example: W/"1234567890abcdef")
PreferstringRequest asynchronous processing
activatebooleanExecutes an activation lifecycle operation when creating the user
afterstringThe cursor to use for pagination. It is an opaque string that specifies your current location in the list and is obtained from the Link response header. See Pagination.
expandstringAn optional parameter to include metadata in the _embedded attribute. Valid values: blocks or <x-lifecycle class="ea"></x-lifecycle> classification.
filterstringFilters users with a supported expression for a subset of properties. > Note: Returned users include those with the DEPROVISIONED status. This requires URL encoding. For example, filter=lastUpdated gt "2013-06-01T00:00:00.000Z" is encoded as filter=lastUpdated%20gt%20%222013-06-01T00:00:00.000Z%22. Filtering is case-sensitive for property names and query values, while operators are case-insensitive. Filtering supports the following limited number of properties: status, lastUpdated, id, profile.login, profile.email, profile.firstName, and profile.lastName. Additionally, filtering supports only the equal eq operator from the standard Okta API filtering semantics, except in the case of the lastUpdated property. This property can also use the inequality operators (gt, ge, lt, and le). For logical operators, only the logical operators and and or are supported. The not operator isn't supported. See Filter and Operators.
forgetDevicesbooleanClears the user's remembered factors for all devices. > Note: This parameter defaults to false in Classic Engine.
limitinteger (int32)Specifies the number of results returned. Defaults to 10 if q is provided.
nextLoginstringWith activate=true, if nextLogin=changePassword, a user is created, activated, and the password is set to EXPIRED. The user must change it the next time they sign in.
oauthTokensbooleanRevokes issued OpenID Connect and OAuth refresh and access tokens
providerbooleanIndicates whether to create a user with a specified authentication provider
qstringFinds users who match the specified query. This doesn't support pagination. > Note: For optimal performance, use the search parameter instead. Use the q parameter for simple queries, such as a lookup of users by name when creating a people picker. The value of q is matched against firstName, lastName, or email. This performs a startsWith match, but this is an implementation detail and can change without notice. You don't need to specify firstName, lastName, or email. > Note: Using the q parameter in a request omits users that have a status of DEPROVISIONED. To return all users, use a filter or search query instead.
revokeSessionsbooleanRevokes all user sessions, except for the current session, if set to true
sendEmailboolean
sortBystringSpecifies field to sort by (for search queries only). This can be any single property, for example sortBy=profile.lastName. Users with the same value for the sortBy property will be ordered by id.
sortOrderstringSpecifies the sort order: asc or desc (for search queries only). Sorting is done in ASCII sort order (that is, by ASCII character value), but isn't case sensitive. sortOrder is ignored if sortBy isn't present.
strictbooleanIf true, validates against the password minimum age policy

SELECT examples

Lists users in your org, with pagination in most cases.

A subset of users can be returned that match a supported filter expression or search criteria. Different results are returned depending on specified queries in the request.

> Note: This operation omits users that have a status of DEPROVISIONED in the response. To return all users, use a filter or search query instead.

SELECT
id,
_embedded,
_links,
activated,
created,
credentials,
lastLogin,
lastUpdated,
passwordChanged,
profile,
realmId,
status,
statusChanged,
transitioningToStatus,
type
FROM okta.users.users
WHERE subdomain = '{{ subdomain }}' -- required
AND Content-Type = '{{ Content-Type }}'
AND search = '{{ search }}'
AND filter = '{{ filter }}'
AND q = '{{ q }}'
AND after = '{{ after }}'
AND limit = '{{ limit }}'
AND sortBy = '{{ sortBy }}'
AND sortOrder = '{{ sortOrder }}'
AND expand = '{{ expand }}'
;

INSERT examples

Creates a new user in your Okta org with or without credentials.

> Legal Disclaimer
>
> After a user is added to the Okta directory, they receive an activation email. As part of signing up for this service,
> you agreed not to use Okta's service/product to spam and/or send unsolicited messages.
> Please refrain from adding unrelated accounts to the directory as Okta is not responsible for, and disclaims any and all
> liability associated with, the activation email's content. You, and you alone, bear responsibility for the emails sent to any recipients.

All responses return the created user. Activation of a user is an asynchronous operation. The system performs group reconciliation during activation and assigns the user to all apps via direct or indirect relationships (group memberships).
* The user's transitioningToStatus property is ACTIVE during activation to indicate that the user hasn't completed the asynchronous operation.
* The user's status is ACTIVE when the activation process is complete.

The user is emailed a one-time activation token if activated without a password.

> Note: If the user is assigned to an app that is configured for provisioning, the activation process triggers downstream provisioning to the app. It is possible for a user to sign in before these apps have been successfully provisioned for the user.

> Important: Do not generate or send a one-time activation token when activating users with an assigned password. Users should sign in with their assigned password.

For more information about the various scenarios of creating a user listed in the examples, see the User creation scenarios section.

INSERT INTO okta.users.users (
data__credentials,
data__groupIds,
data__profile,
data__realmId,
data__type,
subdomain,
activate,
provider,
nextLogin
)
SELECT
'{{ credentials }}',
'{{ groupIds }}',
'{{ profile }}' /* required */,
'{{ realmId }}',
'{{ type }}',
'{{ subdomain }}',
'{{ activate }}',
'{{ provider }}',
'{{ nextLogin }}'
RETURNING
id,
_embedded,
_links,
activated,
created,
credentials,
lastLogin,
lastUpdated,
passwordChanged,
profile,
realmId,
status,
statusChanged,
transitioningToStatus,
type
;

UPDATE examples

Updates a user's profile or credentials with partial update semantics.

> Important: Use the POST method for partial updates. Unspecified properties are set to null with PUT.

profile and credentials can be updated independently or together with a single request.
> Note: Currently, the user type of a user can only be changed via a full replacement PUT operation. If the request parameters of a partial update include the type element from the user object,
the value must match the existing type of the user. Only admins are permitted to change the user type of a user; end users are not allowed to change their own user type.

> Note: To update a current user's profile with partial semantics, the /api/v1/users/me endpoint can be invoked.
>
> A user can only update profile properties for which the user has write access. Within the profile, if the user tries to update the primary or the secondary email IDs, verification emails are sent to those email IDs, and the fields are updated only upon verification.

If you are using this endpoint to set a password, it sets a password without validating existing user credentials. This is an administrative operation. For operations that validate credentials, refer to the Reset password, Start forgot password flow, and Update password endpoints.

UPDATE okta.users.users
SET
data__credentials = '{{ credentials }}',
data__profile = '{{ profile }}',
data__realmId = '{{ realmId }}'
WHERE
subdomain = '{{ subdomain }}' --required
AND strict = {{ strict}}
AND If-Match = '{{ If-Match}}'
RETURNING
id,
_embedded,
_links,
activated,
created,
credentials,
lastLogin,
lastUpdated,
passwordChanged,
profile,
realmId,
status,
statusChanged,
transitioningToStatus,
type
;

REPLACE examples

Replaces a user's profile, credentials, or both using strict-update semantics.

All profile properties must be specified when updating a user's profile with a PUT method. Any property not specified in the request is deleted.
> Important: Don't use a PUT method for partial updates.

REPLACE okta.users.users
SET
data__credentials = '{{ credentials }}',
data__profile = '{{ profile }}',
data__realmId = '{{ realmId }}'
WHERE
subdomain = '{{ subdomain }}' --required
AND strict = {{ strict}}
AND If-Match = '{{ If-Match}}'
RETURNING
id,
_embedded,
_links,
activated,
created,
credentials,
lastLogin,
lastUpdated,
passwordChanged,
profile,
realmId,
status,
statusChanged,
transitioningToStatus,
type
;

DELETE examples

Deletes a user permanently. This operation can only be performed on users that have a DEPROVISIONED status.

> Warning: This action can't be recovered!

This operation on a user that hasn't been deactivated causes that user to be deactivated. A second delete operation is required to delete the user.

> Note: You can also perform user deletion asynchronously. To invoke asynchronous user deletion, pass an HTTP header Prefer: respond-async with the request.

This header is also supported by user deactivation, which is performed if the delete endpoint is invoked on a user that hasn't been deactivated.

DELETE FROM okta.users.users
WHERE subdomain = '{{ subdomain }}' --required
AND sendEmail = '{{ sendEmail }}'
AND Prefer = '{{ Prefer }}'
;

Lifecycle Methods

Ends Okta sessions for the currently signed in user. By default, the current session remains active. Use this method in a browser-based app.
> Note: This operation requires a session cookie for the user. The API token isn't allowed for this operation.

EXEC okta.users.users.end_user_sessions 
@subdomain='{{ subdomain }}' --required
@@json=
'{
"keepCurrent": {{ keepCurrent }}
}'
;