B2B Saas Authentication

/

Frontend SDKs

/

Headless

/

Discovery

/

List Discovered Organizations

List discovered Organizations

Wraps Stytch's list discovered Organizations endpoint. If there is a current Member Session, the SDK will call the endpoint with the session token. Otherwise, the SDK will use the intermediate session token.

Intermediate session tokens are generated upon successful calls to primary authenticate methods in the case where MFA is required, such as email magic link authenticate, or upon successful calls to discovery authenticate methods, such as email magic link discovery authenticate.

If neither a Member Session nor an intermediate session token is present, this method will fail.

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

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

  useEffect(() => {
    const authenticate = async () => {
      const { email_address, discovered_organizations } = await stytch.discovery.organizations.list();
      console.log({ email_address, discovered_organizations });
    };
    authenticate();
  }, [stytch]);

  return <div>Find Your Organization</div>;
};

RESPONSE

200
{
	"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
	"status_code": 200,
	"email_address": "sandbox@stytch.com",
	"discovered_organizations": [{...}, {...}],
	"organization_id_hint": "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931"
}