Skip to main content
import { useEffect, useState } from 'react';
import { useStytchB2BClient } from '@stytch/react/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 <p>Loading...</p>;
  }

  if (organization === null) {
    return <p>No organization found for {slug}</p>;
  }

  return <p>Name: {organization.organization_name}</p>;
};
{
  "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,
  }
}
The organization.getBySlug method can be used to retrieve details about an from its slug. This method may be called even if the is not logged in, so it returns a subset of non-sensitive information about the Organization.

Parameters

organization_slug
string
The unique URL slug of the Organization to get.The slug only accepts alphanumeric characters and the following reserved characters: - . _ ~. Must be between 2 and 128 characters in length.

Response

organization
object
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.