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.
Get Organization by Slug
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
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,
}
}
RESPONSE 401
200
{
"status_code": 401,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "unauthorized_credentials",
"error_message": "Unauthorized credentials.",
"error_url": "https://stytch.com/docs/api/errors/401"
}
RESPONSE 429
200
{
"status_code": 429,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "too_many_requests",
"error_message": "Too many requests have been made.",
"error_url": "https://stytch.com/docs/api/errors/429"
}
RESPONSE 500
200
{
"status_code": 500,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "internal_server_error",
"error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
"error_url": "https://stytch.com/docs/api/errors/500"
}