B2B Saas Authentication

/

Mobile SDKs

/

React Native SDK reference

/

Organizations

/

Get Organization by Slug

Get Organization by Slug

The organization.getBySlug method can be used to retrieve details about an organization from its slug. This method may be called even if the Member is not logged in.

import React, { useEffect, useState } from 'react';
import { Text } from 'react-native';
import { useStytchB2BClient } from '@stytch/react-native/b2b';

export const OrganizationInfo = ({ slug }) => {
  const stytch = useStytchB2BClient();
  const [organization, setOrganization] = useState();
  useEffect(() => {
    stytch.organization
      .getBySlug({ organization_slug: slug })
      .then((response) => setOrganization(response.organization));
  }, [stytch, slug]);

  if (organization === undefined) {
    return <Text>Loading...</Text>;
  }

  if (!organization) {
    return <Text>No organization found for {slug}</Text>;
  }

  return <Text>Name: {organization.organization_name}</Text>;
};

RESPONSE

200
{
    "status_code": 200,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "organization": {
      "allowed_auth_methods": [],
      "auth_methods": "ALL_ALLOWED",
      "email_allowed_domains": [],
      "email_jit_provisioning": "NOT_ALLOWED",
      "mfa_policy": "OPTIONAL",
      "organization_id": "organization-test-staging-12345",
      "organization_logo_url": "",
      "organization_name": "Example Org Inc",
      "sso_active_connections": [],
      "sso_default_connection_id": null,
    }
}