[GH-ISSUE #3309] Add support for organizationSlug in hasPermission API to allow permission checks using slugs #26888

Closed
opened 2026-04-17 17:37:22 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @brunowego on GitHub (Jul 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3309

Is this suited for github?

  • Yes, this is suited for github

Currently, the hasPermission API only supports permission checks using the organizationId. However, many applications use organizationSlug as the primary identifier in routes and UI logic, making it more convenient and user-friendly.

We propose adding support for passing organizationSlug directly to the hasPermission API, allowing developers to verify permissions without needing to resolve or store the organizationId first.

Describe the solution you'd like

const { success: hasAccess } = await auth.api.hasPermission({
  headers: await headers(),
  body: {
    permissions,
    organizationSlug: workspace,
  },
});

Describe alternatives you've considered

I’m currently using organizationId by performing an additional query beforehand to resolve the organizationSlug to its corresponding ID. While this works, it introduces extra database or API calls, adds complexity to the code, and slightly increases latency in permission checks.

Additional context

Benefits

• Simplifies permission checks in apps that use slugs as primary identifiers.
• Reduces the need for extra database lookups or additional API calls to resolve slugs to IDs.
• Improves developer experience and reduces boilerplate.

Originally created by @brunowego on GitHub (Jul 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3309 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently, the hasPermission API only supports permission checks using the organizationId. However, many applications use organizationSlug as the primary identifier in routes and UI logic, making it more convenient and user-friendly. We propose adding support for passing organizationSlug directly to the hasPermission API, allowing developers to verify permissions without needing to resolve or store the organizationId first. ### Describe the solution you'd like ``` const { success: hasAccess } = await auth.api.hasPermission({ headers: await headers(), body: { permissions, organizationSlug: workspace, }, }); ``` ### Describe alternatives you've considered I’m currently using organizationId by performing an additional query beforehand to resolve the organizationSlug to its corresponding ID. While this works, it introduces extra database or API calls, adds complexity to the code, and slightly increases latency in permission checks. ### Additional context Benefits • Simplifies permission checks in apps that use slugs as primary identifiers. • Reduces the need for extra database lookups or additional API calls to resolve slugs to IDs. • Improves developer experience and reduces boilerplate.
GiteaMirror added the lockedenhancement labels 2026-04-17 17:37:22 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 7, 2025):

Hi, @brunowego. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary

  • You requested adding support for organizationSlug in the hasPermission API.
  • The goal is to simplify permission checks by using slugs instead of requiring organizationId.
  • This would reduce extra database or API calls and improve developer experience.
  • No further activity or comments have been recorded on this issue yet.

Next Steps

  • Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue.
  • If I don’t hear back within 7 days, I will automatically close this issue.

Thanks for your understanding and contribution!

<!-- gh-comment-id:3377560369 --> @dosubot[bot] commented on GitHub (Oct 7, 2025): Hi, @brunowego. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary** - You requested adding support for `organizationSlug` in the `hasPermission` API. - The goal is to simplify permission checks by using slugs instead of requiring `organizationId`. - This would reduce extra database or API calls and improve developer experience. - No further activity or comments have been recorded on this issue yet. **Next Steps** - Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue. - If I don’t hear back within 7 days, I will automatically close this issue. Thanks for your understanding and contribution!
Author
Owner

@ceolinwill commented on GitHub (Nov 28, 2025):

I think this feature is still relevant. AFAIK, we can't use organizationSlug with hasPermission yet.

<!-- gh-comment-id:3587826304 --> @ceolinwill commented on GitHub (Nov 28, 2025): I think this feature is still relevant. AFAIK, we can't use `organizationSlug` with `hasPermission` yet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26888