View Source WorkOS.UserManagement (WorkOS SDK for Elixir v1.1.0)

Manage User Management in WorkOS.

@see https://workos.com/docs/reference/user-management

Summary

Functions

Authenticates an OAuth or SSO User.

Generates an OAuth 2.0 authorization URL.

Lists all auth factors of a user.

Lists all invitations.

Lists all organization memberships.

Lists all users.

Creates a one-time Magic Auth code.

Sends a password reset email to a user.

Functions

Link to this function

authenticate_with_code(client \\ WorkOS.client(), opts)

View Source

Authenticates an OAuth or SSO User.

Parameter options:

  • :code - The authorization value which was passed back as a query parameter in the callback to the Redirect URI. (required)
  • :ip_address - The IP address of the request from the user who is attempting to authenticate.
  • :user_agent - The user agent of the request from the user who is attempting to authenticate. This should be the value of the User-Agent header.
Link to this function

authenticate_with_email_verification(client \\ WorkOS.client(), opts)

View Source
@spec authenticate_with_email_verification(WorkOS.Client.t(), map()) ::
  WorkOS.Client.response(WorkOS.UserManagement.Authentication.t())

Authenticates with Email Verification Code

Parameter options:

  • :code - The one-time code that was emailed to the user. (required)
  • :pending_authentication_code - The pending_authentication_token returned from an authentication attempt due to an unverified email address. (required)
  • :ip_address - The IP address of the request from the user who is attempting to authenticate.
  • :user_agent - The user agent of the request from the user who is attempting to authenticate. This should be the value of the User-Agent header.
Link to this function

authenticate_with_magic_auth(client \\ WorkOS.client(), opts)

View Source
@spec authenticate_with_magic_auth(WorkOS.Client.t(), map()) ::
  WorkOS.Client.response(WorkOS.UserManagement.Authentication.t())

Authenticates with Magic Auth.

Parameter options:

  • :code - The one-time code that was emailed to the user. (required)
  • :email - The email the User who will be authenticated. (required)
  • :link_authorization_code - An authorization code used in a previous authenticate request that resulted in an existing user error response.
  • :ip_address - The IP address of the request from the user who is attempting to authenticate.
  • :user_agent - The user agent of the request from the user who is attempting to authenticate. This should be the value of the User-Agent header.
Link to this function

authenticate_with_password(client \\ WorkOS.client(), opts)

View Source

Authenticates a user with password.

Parameter options:

  • :email - The email address of the user. (required)
  • :password - The password of the user. (required)
  • :ip_address - The IP address of the request from the user who is attempting to authenticate.
  • :user_agent - The user agent of the request from the user who is attempting to authenticate. This should be the value of the User-Agent header.
Link to this function

authenticate_with_selected_organization(client \\ WorkOS.client(), opts)

View Source
@spec authenticate_with_selected_organization(WorkOS.Client.t(), map()) ::
  WorkOS.Client.response(WorkOS.UserManagement.Authentication.t())

Authenticates with Selected Organization

Parameter options:

  • :pending_authentication_code - The token returned from a failed authentication attempt due to organization selection being required. (required)
  • :organization_id - The Organization ID the user selected. (required)
  • :ip_address - The IP address of the request from the user who is attempting to authenticate.
  • :user_agent - The user agent of the request from the user who is attempting to authenticate. This should be the value of the User-Agent header.
Link to this function

authenticate_with_totp(client \\ WorkOS.client(), opts)

View Source

Authenticates with MFA TOTP

Parameter options:

  • :code - The time-based-one-time-password generated by the Factor that was challenged. (required)
  • :authentication_challenge_id - The unique ID of the authentication Challenge created for the TOTP Factor for which the user is enrolled. (required)
  • :pending_authentication_code - The token returned from a failed authentication attempt due to MFA challenge. (required)
  • :ip_address - The IP address of the request from the user who is attempting to authenticate.
  • :user_agent - The user agent of the request from the user who is attempting to authenticate. This should be the value of the User-Agent header.
Link to this function

create_organization_membership(client \\ WorkOS.client(), opts)

View Source

Creates an organization membership.

Parameter options:

  • :user_id - The ID of the User. (required)
  • :organization_id - The ID of the Organization to which the user belongs to. (required)
Link to this function

create_user(client \\ WorkOS.client(), opts)

View Source

Creates a user.

Parameter options:

  • :email - The email address of the user. (required)
  • :domains - The password to set for the user.
  • :first_name - The user's first name.
  • :last_name - The user's last name.
  • :email_verified - Whether the user's email address was previously verified.
Link to this function

delete_organization_membership(client \\ WorkOS.client(), organization_membership_id)

View Source
@spec delete_organization_membership(WorkOS.Client.t(), String.t()) ::
  WorkOS.Client.response(nil)

Deletes an organization membership.

Link to this function

delete_user(client \\ WorkOS.client(), user_id)

View Source
@spec delete_user(WorkOS.Client.t(), String.t()) :: WorkOS.Client.response(nil)

Deletes a user.

Link to this function

enroll_auth_factor(client \\ WorkOS.client(), user_id, opts)

View Source

Enrolls a user in a new Factor.

Parameter options:

  • :type - The type of the factor to enroll. Only option available is totp. (required)
  • :totp_issuer - For totp factors. Typically your application or company name, this helps users distinguish between factors in authenticator apps.
  • :totp_user - For totp factors. Used as the account name in authenticator apps. Defaults to the user's email.
Link to this function

get_authorization_url(params)

View Source
@spec get_authorization_url(map()) :: {:ok, String.t()} | {:error, String.t()}

Generates an OAuth 2.0 authorization URL.

Parameter options:

  • :organization_id - The organization_id connection selector is used to initiate SSO for an Organization.
  • :connection_id - The connection_id connection selector is used to initiate SSO for a Connection.
  • :redirect_uri - A Redirect URI to return an authorized user to. (required)
  • :client_id - This value can be obtained from the SSO Configuration page in the WorkOS dashboard.
  • :provider - The provider connection selector is used to initiate SSO using an OAuth-compatible provider.
  • :state - An optional parameter that can be used to encode arbitrary information to help restore application state between redirects.
  • :login_hint - Can be used to pre-fill the username/email address field of the IdP sign-in page for the user, if you know their username ahead of time.
  • :domain_hint - Can be used to pre-fill the domain field when initiating authentication with Microsoft OAuth, or with a GoogleSAML connection type.
Link to this function

get_invitation(client \\ WorkOS.client(), invitation_id)

View Source

Gets an invitation.

Link to this function

get_organization_membership(client \\ WorkOS.client(), organization_membership_id)

View Source

Gets an organization membership.

Link to this function

get_user(client \\ WorkOS.client(), user_id)

View Source

Gets a user.

Link to this function

list_auth_factors(client \\ WorkOS.client(), user_id)

View Source
@spec list_auth_factors(WorkOS.Client.t(), String.t()) ::
  WorkOS.Client.response(
    WorkOS.List.t(WorkOS.UserManagement.MultiFactor.AuthenticationFactor.t())
  )

Lists all auth factors of a user.

Link to this function

list_invitations(opts \\ %{})

View Source
Link to this function

list_invitations(client, opts)

View Source

Lists all invitations.

Parameter options:

  • :email - The email address of a recipient.
  • :organization_id - The ID of the Organization that the recipient was invited to join.
  • :limit - Maximum number of records to return. Accepts values between 1 and 100. Default is 10.
  • :after - Pagination cursor to receive records after a provided event ID.
  • :before - An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.
  • :order - Order the results by the creation time. Supported values are "asc" and "desc" for showing older and newer records first respectively.
Link to this function

list_organization_memberships(opts \\ %{})

View Source
@spec list_organization_memberships(map()) ::
  WorkOS.Client.response(
    WorkOS.List.t(WorkOS.UserManagement.OrganizationMembership.t())
  )
Link to this function

list_organization_memberships(client, opts)

View Source
@spec list_organization_memberships(WorkOS.Client.t(), map()) ::
  WorkOS.Client.response(
    WorkOS.List.t(WorkOS.UserManagement.OrganizationMembership.t())
  )

Lists all organization memberships.

Parameter options:

  • :user_id - The ID of the User.
  • :organization_id - The ID of the Organization to which the user belongs to.
  • :limit - Maximum number of records to return. Accepts values between 1 and 100. Default is 10.
  • :after - Pagination cursor to receive records after a provided event ID.
  • :before - An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.
  • :order - Order the results by the creation time. Supported values are "asc" and "desc" for showing older and newer records first respectively.
Link to this function

list_users(client, opts)

View Source

Lists all users.

Parameter options:

  • :email - Filter Users by their email.
  • :organization_id - Filter Users by the organization they are members of.
  • :limit - Maximum number of records to return. Accepts values between 1 and 100. Default is 10.
  • :after - Pagination cursor to receive records after a provided event ID.
  • :before - An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.
  • :order - Order the results by the creation time. Supported values are "asc" and "desc" for showing older and newer records first respectively.
Link to this function

reset_password(client \\ WorkOS.client(), opts)

View Source

Resets password.

Parameter options:

  • :token - The reset token emailed to the user. (required)
  • :new_password - The new password to be set for the user. (required)
Link to this function

revoke_invitation(client \\ WorkOS.client(), invitation_id)

View Source

Revokes an invitation.

Link to this function

send_invitation(client \\ WorkOS.client(), opts)

View Source

Sends an invitation.

Parameter options:

  • :email - The email address of the recipient. (required)
  • :organization_id - The ID of the Organization to which the recipient is being invited.
  • :expires_in_days - The number of days the invitations will be valid for.
  • :inviter_user_id - The ID of the User sending the invitation.
Link to this function

send_magic_auth_code(client \\ WorkOS.client(), email)

View Source

Creates a one-time Magic Auth code.

Parameter options:

  • :email - The email address the one-time code will be sent to. (required)
Link to this function

send_password_reset_email(client \\ WorkOS.client(), opts)

View Source

Sends a password reset email to a user.

Parameter options:

  • :email - The email of the user that wishes to reset their password. (required)
  • :password_reset_url - The password to set for the user. (required)
Link to this function

send_verification_email(client \\ WorkOS.client(), user_id)

View Source
@spec send_verification_email(WorkOS.Client.t(), String.t()) ::
  WorkOS.Client.response(
    WorkOS.UserManagement.EmailVerification.SendVerificationEmail.t()
  )

Sends verification email.

Link to this function

update_user(client \\ WorkOS.client(), user_id, opts)

View Source

Updates a user.

Parameter options:

  • :first_name - The user's first name.
  • :last_name - The user's last name.
  • :email_verified - Whether the user's email address was previously verified.
  • :password - The password to set for the user.
  • :password_hash - The hashed password to set for the user, used when migrating from another user store. Mutually exclusive with password.
  • :password_hash_type - The algorithm originally used to hash the password, used when providing a password_hash. Valid values are bcrypt.
Link to this function

verify_email(client \\ WorkOS.client(), user_id, opts)

View Source
@spec verify_email(WorkOS.Client.t(), String.t(), map()) ::
  WorkOS.Client.response(
    WorkOS.UserManagement.EmailVerification.VerifyEmail.t()
  )

Verifies user email.

Parameter options:

  • :code - The one-time code emailed to the user. (required)