B2B Saas Authentication

/

Frontend SDKs

/

Headless

/

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 { 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) {
    return <p>No organization found for {slug}</p>;
  }

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

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,
    }
  }