K
Kinde4mo ago
top kek

Do I need to get ALL organizations just to find one matching the handle?

My URLs are shaped like studio.inploi.com/<ORG_HANDLE>/<PAGE> I would like to be able to get the organization matching the handle from the server, but there is no way currently is that correct? Im pretty sure this would be a very common use case
Kinde docs
Kinde Management API
The management API is for managing your Kinde account. Most things that can be done via the Kinde admin UI can be done with this API
5 Replies
Roshan
Roshan4mo ago
Hi Freddie,
Thanks for reaching out,

Based on your URL structure, using the Kinde Management API to find the organization (though as you noted, there's no direct "get by handle" endpoint), here are some of the option you have: - Use list organization endpoint GET /api/v1/organizations and filter by handle. This Kinde Management API's GET /api/v1/organization endpoint only accepts a code - You could store a mapping between handles and organization codes in your own database or cache, updating it when organizations are created or modified. The organization handle feature is primarily designed for dynamic callback URLs during authentication flows.

If you’d like us to prioritize this feature in a future release, please visit our Feature release page ,and you can also submit your request using the 'Leave feedback' form. https://updates.kinde.com/board Let me know if this helps, Thanks.
Kinde - Feature release hub
Check out the latest product updates on the Kinde LaunchNotes page.
top kek
top kekOP4mo ago
the whole 3rd party auth service idea was so that we wouldn’t have to store user/org info in our own infrastructure, having a potentially stale map of org handles to org ids where both are within kinde sounds quite silly will issue a feature request and continue working with listing ALL orgs just to find one
Roshan
Roshan4mo ago
Appreciate you raising a feature request, I’ve flagged this internally as well to support. We’ll keep you updated if there’s any update on this.

Thanks
top kek
top kekOP4mo ago
thank you very much 🙂 Look at this sad bit of code:
import { Organizations, type organization_item_schema } from '@kinde/management-api-js';

export const getKindeOrgByHandle = async (handle: string) => {
const orgs = await getOrgsRec(undefined);
return orgs.find((org) => org.handle === handle);
};

/** Recursively fetch all organizations from Kinde
* Kinde does not offer a way to get an organization by slug, so we need to fetch all organizations
* and filter them by slug. A feature request has been made to Kinde to add this functionality.
*/
const getOrgsRec = async (nextToken: string | undefined): Promise<organization_item_schema[]> => {
const res = await Organizations.getOrganizations({ pageSize: 100, nextToken });
const orgs = res.organizations ?? [];
if (res.next_token) {
const next = await getOrgsRec(res.next_token);
return [...orgs, ...next];
}
return orgs;
};
import { Organizations, type organization_item_schema } from '@kinde/management-api-js';

export const getKindeOrgByHandle = async (handle: string) => {
const orgs = await getOrgsRec(undefined);
return orgs.find((org) => org.handle === handle);
};

/** Recursively fetch all organizations from Kinde
* Kinde does not offer a way to get an organization by slug, so we need to fetch all organizations
* and filter them by slug. A feature request has been made to Kinde to add this functionality.
*/
const getOrgsRec = async (nextToken: string | undefined): Promise<organization_item_schema[]> => {
const res = await Organizations.getOrganizations({ pageSize: 100, nextToken });
const orgs = res.organizations ?? [];
if (res.next_token) {
const next = await getOrgsRec(res.next_token);
return [...orgs, ...next];
}
return orgs;
};
Roshan
Roshan4mo ago
Thanks for sharing the code and totally understand why it feels a bit “sad.” I’ve passed this along internally again with the extra context, including the recursive approach you're using. Hopefully, this helps highlight the practical impact and adds weight to the feature request already submitted. We’ll keep you posted if there’s any movement on this. Appreciate your patience and feedback as always.
Thanks

Did you find this page helpful?