Member

Once a Member has successfully logged in, the SDK can be used to view and manage that Member's information along with information about the Organization they belong to. In addition, the Member may create, update, and delete other Members in the Organization if their Role gives them permissions to do so. To learn more about our RBAC implementation, see our RBAC guide.

Methods

Get Member

The SDK provides synchronous and asynchronous methods for getting a Member. The recommended approach is to use the synchronous method, member.getSync, and listen to changes with the member.onChange method.

If logged in, the member.getSync method returns the cached Member object. Otherwise it returns null. This method does not refresh the Member's data.

The member.getInfo method is similar to member.getSync, but it returns an object containing the member object and a fromCache boolean. If fromCache is true, the Member object is from the cache and a state refresh is in progress.

The member.onChange method takes in a callback that gets called whenever the Member object changes. It returns an unsubscribe method for you to call when you no longer want to listen for such changes.

The @stytch/react-native library also provides the useStytchMember hook that implements these methods for you to easily access the Member and listen for changes.

The asynchronous method, member.get, wraps the search member endpoint. It fetches the Member's data and refreshes the cached object if changes are detected. The Stytch SDK will invoke this method automatically in the background, so you probably won't need to call this method directly.

import React from 'react';
import { useStytchMember } from '@stytch/react-native/b2b';

export const Home = () => {
  const { member } = useStytchMember();

  return member ? <p>Welcome, {member.name}</p> : <p>Log in to continue!</p>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}

Create a Member

The Create Member method wraps the Create Member API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to create Members in other Organizations.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the create action on the stytch.member Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


email_address*string

namestring

untrusted_metadataobject

create_member_as_pendingboolean

is_breakglassboolean

mfa_phone_numberstring

mfa_enrolledboolean

rolesarray[strings]
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const CreateMember = () => {
  const stytch = useStytchB2BClient();

  const createMember = () => {
    stytch.organization.members.create({
      email_address: 'sandbox@stytch.com',
    });
  };

  return <button onClick={createMember}>Create a Member</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}

Update a Member

The Update Member method wraps the Update Member API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method can be used to update any Member in the logged-in Member's Organization.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. The specific permissions needed depend on which of the optional fields are passed in the request. For example, if the name argument is provided, the Member must have permission to perform the update.info.name action on the stytch.member Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


member_id*string

email_addressstring

namestring

untrusted_metadataobject

is_breakglassboolean

mfa_phone_numberstring

mfa_enrolledboolean

default_mfa_methodstring

rolesarray[strings]
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const UpdateMemberName = () => {
  const stytch = useStytchB2BClient();

  const updateMemberName = () => {
    stytch.organization.members.update({
      member_id: 'member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f$',
      name: 'Jane Doe',
    });
  };

  return <button onClick={updateMemberName}>Update Member name</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}

Search Members

The Search Members method wraps the Search Members API endpoint. It can be used to search for Members within the logged-in Member's Organization.

Submitting an empty query returns all non-deleted Members within the logged-in Member's Organization.

*All fuzzy search filters require a minimum of three characters.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the search action on the stytch.member Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


cursorstring

limitint

queryobject
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const SearchMembers = () => {
  const stytch = useStytchB2BClient();

  const searchMembers = () => {
    stytch.organization.members.search();
  };

  return <button onClick={searchMembers}>Search Members</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "results_metadata": {
		"next_cursor": null,
		"total": 5
	},
  "members": [
    ...
  ]
  "organizations": <
    ...
  >
}

Delete Member

The Delete Member method wraps the delete member API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to delete Members in other Organizations.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the delete action on the stytch.member Resource.

If the logged-in Member matches the member_id passed in the request, the request is also permissible if the logged-in Member has permission to perform the delete action on the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


member_id*string
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeleteMember = () => {
  const stytch = useStytchB2BClient();

  const deleteMember = () => {
    stytch.organization.members.delete('member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f');
  };

  return <button onClick={deleteMember}>Delete Member</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f"
}

Reactivate a Member

The Reactivate Member method wraps the Reactivate Member API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to reactivate Members in other Organizations.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the create action on the stytch.member Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


member_id*string
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const ReactivateMember = () => {
  const stytch = useStytchB2BClient();

  const reactivateMember = () => {
    stytch.organization.members.reactivate('member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f');
  };

  return <button onClick={reactivateMember}>Reactivate Member</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}

Delete Member password

The Delete Member password method wraps the Delete Member password API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to delete the passwords of Members in other Organizations.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the update.info.delete.password action on the stytch.member Resource.

If the logged-in Member matches the Member associated with the member_password_id passed in the request, the request is also permissible if the logged-in Member has permission to perform the update.info.delete.password action on the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


member_password_id*string
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeletePassword = () => {
  const stytch = useStytchB2BClient();

  const deletePassword = () => {
    stytch.organization.members.deletePassword('member-password-test-51861cbc-d3b9-428b-9761-227f5fb12be9');
  };

  return <button onClick={deletePassword}>Delete Password</button>;
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}

Delete Member MFA phone number

The Delete Member MFA phone number method wraps the Delete Member MFA phone number API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to delete the phone numbers of Members in other Organizations.

To change a Member's phone number, you must first call this endpoint to delete the existing phone number.

Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is deleted, and MFA will not be enforced until the Member logs in again. If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter a new phone number and calling the SMS OTP send endpoint, then calling the SMS Authenticate endpoint.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the update.info.delete.mfa-phone action on the stytch.member Resource.

If the logged-in Member matches the member_id passed in the request, the request is also permissible if the logged-in Member has permission to perform the update.info.delete.mfa-phone action on the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


member_id*string
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeleteMemberMFAPhoneNumber = () => {
  const stytch = useStytchB2BClient();

  const deleteMemberMFAPhoneNumber = () => {
    stytch.organization.members.deleteMFAPhoneNumber('member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f');
  };

  return <button onClick={deleteMemberMFAPhoneNumber}>Delete Phone Number</button>;
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}

Delete Member TOTP

The Delete Member TOTP method wraps the Delete Member TOTP API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to delete totps of Members in other Organizations.

To change a Member's TOTP, you must first call this endpoint to delete the existing TOTP.

Existing Member Sessions that include a TOTP authentication factor will not be revoked if the TOTP is deleted, and MFA will not be enforced until the Member logs in again. If you wish to enforce MFA immediately after a TOTP is deleted, you can do so by prompting the Member to create a TOTP and calling the Create TOTP endpoint, then calling the TOTP Authenticate endpoint.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the update.info.delete.mfa-totp action on the stytch.member Resource.

If the logged-in Member matches the member_id passed in the request, the request is also permissible if the logged-in Member has permission to perform the update.info.delete.mfa-totp action on the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.


Method parameters


member_id*string
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeleteMFATOTP = () => {
  const stytch = useStytchB2BClient();

  const deleteMFATOTP = () => {
    stytch.organization.members.deleteMFATOTP('member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f');
  };

  return <button onClick={deleteMFATOTP}>Delete TOTP</button>;
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}

Update Self

The Update Self method wraps the Update Member API endpoint. The organization_id and member_id will be automatically inferred from the logged-in Member's session. This method can be used to update only the logged-in Member.

You can listen for successful Member updates anywhere in the codebase with the stytch.organization.onMemberChange() method or useStytchMember hook.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. The specific permissions needed depend on which of the optional fields are passed in the request. For example, if the name argument is provided, the Member must have permission to perform the update.info.name action on either the stytch.member or stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. See the RBAC guide for more details.


Method parameters


namestring

untrusted_metadataobject

mfa_phone_numberstring

mfa_enrolledboolean

default_mfa_methodstring
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const UpdateName = () => {
  const stytch = useStytchB2BClient();

  const updateName = () => {
    stytch.self.update({
      name: 'Jane Doe',
    });
  };

  return <button onClick={updateName}>Update name</button>;
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}

Delete Self password

The Delete Self password method wraps the Delete Member password API endpoint. The organization_id and member_id will be automatically inferred from the logged-in Member's session. This method can only be used to delete the logged-in Member's password.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the update.info.delete.password action on either the stytch.member or the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.

import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeletePassword = () => {
  const stytch = useStytchB2BClient();

  const deletePassword = () => {
    stytch.self.deletePassword();
  };

  return <button onClick={deletePassword}>Delete Password</button>;
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}

Delete Self MFA phone number

The Delete Self MFA phone number method wraps the Delete Member MFA phone number API endpoint. The organization_id and member_id will be automatically inferred from the logged-in Member's session. This method can only be used to delete the logged-in Member's MFA phone number.

To change a Member's phone number, you must first call this endpoint to delete the existing phone number.

Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is deleted, and MFA will not be enforced until the Member logs in again. If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter a new phone number and calling the SMS OTP send endpoint, then calling the SMS Authenticate endpoint.

You can listen for successful Member updates anywhere in the codebase with the stytch.organization.onMemberChange() method or useStytchMember hook.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the update.info.delete.mfa-phone action on either the stytch.member or the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.

import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeleteMFAPhoneNumber = () => {
  const stytch = useStytchB2BClient();

  const deleteMFAPhoneNumber = () => {
    stytch.self.deleteMFAPhoneNumber();
  };

  return <button onClick={deleteMFAPhoneNumber}>Delete Phone Number</button>;
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}

Delete Self MFA TOTP

The Delete Self MFA totp method wraps the Delete Member MFA TOTP API endpoint. The organization_id and member_id will be automatically inferred from the logged-in Member's session. This method can only be used to delete the logged-in Member's MFA totp.

To change a Member's totp, you must first call this endpoint to delete the existing totp.

Existing Member Sessions that include a TOTP authentication factor will not be revoked if the TOTP is deleted, and MFA will not be enforced until the Member logs in again. If you wish to enforce MFA immediately after a TOTP is deleted, you can do so by prompting the Member to create a new TOTP and calling the TOTP create endpoint, then calling the TOTP Authenticate endpoint.

You can listen for successful Member updates anywhere in the codebase with the stytch.organization.onMemberChange() method or useStytchMember hook.

This method is not available for unauthenticated end users. In order to call this method, there must be a valid Member Session containing the necessary Role to complete this action. This method requires the Member to have permission to perform the update.info.delete.mfa-totp action on either the stytch.member or the stytch.self Resource.

In addition, Member actions & permissions must be enabled in the SDK Configuration page of the Stytch dashboard. To learn more about our RBAC implementation, see our RBAC guide.

import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const DeleteMFATOTP = () => {
  const stytch = useStytchB2BClient();

  const deleteMFATOTP = () => {
    stytch.self.deleteMFATOTP();
  };

  return <button onClick={deleteMFATOTP}>Delete MFA TOTP</button>;
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}

Update Member (Deprecated)

This method is deprecated. Please use the Update Self method to update the logged-in Member, or use the new Update Member method to update other Members.

The Update Member method wraps the Update Member API endpoint. Use this method to update the Member's name, untrusted metadata, MFA phone number, and MFA enrollment status.

You can listen for successful Member updates anywhere in the codebase with the stytch.organization.onMemberChange() method or useStytchMember hook.


Method parameters


namestring

untrusted_metadataobject

mfa_phone_numberstring

mfa_enrolledboolean
import React, { useCallback } from 'react';
import { useStytchB2BClient } from '@stytch/react';

export const UpdateMember = () => {
  const stytchClient = useStytchB2BClient();

  const updateName = useCallback(() => {
    stytchClient.member.update({
      name: 'Jane Doe',
      untrusted_metadata: {
        display_theme: 'DARK_MODE',
      },
    });
  }, [stytchClient]);

  return (
    <>
      <button onClick={updateName}>Update name</button>
    </>
  );
};

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "member": {...},
  "organization": {...}
}

Delete Member MFA phone number (Deprecated)

This method is deprecated. Please use the Delete Self MFA Phone Number method to update the logged-in Member's MFA phone number, or use the new Delete MFA Phone Number method to update other Members' MFA phone numbers.

The Delete Member MFA phone number method wraps the Delete Member MFA phone number API endpoint. Use this method to delete the Member's MFA phone number.

To change a Member's phone number, you must first call this endpoint to delete the existing phone number.

Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is deleted, and MFA will not be enforced until the Member logs in again. If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter a new phone number and calling the SMS OTP send endpoint, then calling the SMS Authenticate endpoint.

You can listen for successful Member updates anywhere in the codebase with the stytch.organization.onMemberChange() method or useStytchMember hook.

import React from 'react';
import { useStytchB2BClient } from '@stytch/react';

export const deleteMemberMFAPhoneNumber = () => {
  const stytchClient = useStytchB2BClient();

  const deleteMFAPhoneNumber = () => {
    stytchClient.member.deleteMFAPhoneNumber();
  };

  return (
    <>
      <button onClick={deleteMFAPhoneNumber}>Delete MFA phone number</button>
    </>
  );
};

RESPONSE

200
{
    "member": {...},
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "organization": {...}
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "status_code": 200
}