Class UsersManager

Hierarchy

  • BaseAPI
    • UsersManager

Constructors

Properties

configuration: Configuration

Methods

  • Link two user accounts together forming a primary and secondary relationship. On successful linking, the endpoint returns the new array of the primary account identities.

    Note: There are two ways of invoking the endpoint:

    • With the authenticated primary account's JWT in the Authorization header, which has the update:current_user_identities scope:
            POST /api/v2/users/PRIMARY_ACCOUNT_USER_ID/identities
            Authorization: "Bearer PRIMARY_ACCOUNT_JWT"
            {
              "link_with": "SECONDARY_ACCOUNT_JWT"
            }
          
      In this case, only the link_with param is required in the body, which also contains the JWT obtained upon the secondary account's authentication.
    • With a token generated by the API V2 containing the update:users scope:
          POST /api/v2/users/PRIMARY_ACCOUNT_USER_ID/identities
          Authorization: "Bearer YOUR_API_V2_TOKEN"
          {
            "provider": "SECONDARY_ACCOUNT_PROVIDER",
            "connection_id": "SECONDARY_ACCOUNT_CONNECTION_ID(OPTIONAL)",
            "user_id": "SECONDARY_ACCOUNT_USER_ID"
          }
          
      In this case you need to send provider and user_id in the body. Optionally you can also send the connection_id param which is suitable for identifying a particular database connection for the 'auth0' provider.
    Link a User Account

    Throws

    Parameters

    Returns Promise<ApiResponse<UserIdentity[]>>

  • Update a user.

    These are the attributes that can be updated at the root level:

    • app_metadata
    • blocked
    • email
    • email_verified
    • family_name
    • given_name
    • name
    • nickname
    • password
    • phone_number
    • phone_verified
    • picture
    • username
    • user_metadata
    • verify_email

    Some considerations:

    • The properties of the new object will replace the old ones.
    • The metadata fields are an exception to this rule (user_metadata and app_metadata). These properties are merged instead of being replaced but be careful, the merge only occurs on the first level.
    • If you are updating email, email_verified, phone_number, phone_verified, username or password of a secondary identity, you need to specify the connection property too.
    • If you are updating email or phone_number you can specify, optionally, the client_id property.
    • Updating email_verified is not supported for enterprise and passwordless sms connections.
    • Updating the blocked to false does not affect the user's blocked state from an excessive amount of incorrectly provided credentials. Use the "Unblock a user" endpoint from the "User Blocks" API to change the user's state.
    Updating a field (non-metadata property)
    To mark the email address of a user as verified, the body to send should be:
    { "email_verified": true }
    Updating a user metadata root property
    Let's assume that our test user has the following user_metadata:
    { "user_metadata" : { "profileCode": 1479 } }

    To add the field addresses the body to send should be:

    { "user_metadata" : { "addresses": {"work_address": "100 Industrial Way"} }}

    The modified object ends up with the following user_metadata property:

    {
      "user_metadata": {
        "profileCode": 1479,
        "addresses": { "work_address": "100 Industrial Way" }
      }
    }

    Updating an inner user metadata property
    If there's existing user metadata to which we want to add "home_address": "742 Evergreen Terrace" (using the addresses property) we should send the whole addresses object. Since this is a first-level object, the object will be merged in, but its own properties will not be. The body to send should be:
    {
      "user_metadata": {
        "addresses": {
          "work_address": "100 Industrial Way",
          "home_address": "742 Evergreen Terrace"
        }
      }
    }

    The modified object ends up with the following user_metadata property:

    {
      "user_metadata": {
        "profileCode": 1479,
        "addresses": {
          "work_address": "100 Industrial Way",
          "home_address": "742 Evergreen Terrace"
        }
      }
    }

    Update a User

    Throws

    Parameters

    Returns Promise<ApiResponse<GetUsers200ResponseOneOfInner>>