Organization
Organizations, members, invitations, teams, and roles.
This page documents the current Ruby port behavior. Ruby uses snake_case option names and auth.api method names; HTTP paths and JSON keys keep the upstream wire shape where implemented.
Configure
require "better_auth"
auth = BetterAuth.auth(
secret: ENV.fetch("BETTER_AUTH_SECRET"),
base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
plugins: [
BetterAuth::Plugins.organization(allow_user_to_create_organization: true, creator_role: "owner")
]
)Usage
organization = auth.api.create_organization(headers: { "cookie" => owner_cookie }, body: { name: "Example Inc", slug: "example" })
auth.api.create_invitation(headers: { "cookie" => owner_cookie }, body: { organizationId: organization[:id], email: "member@example.com", role: "member" })Routes
| Method | Path | Ruby API method |
|---|---|---|
POST | /organization/create | auth.api.create_organization |
GET | /organization/list | auth.api.list_organizations |
POST | /organization/set-active | auth.api.set_active_organization |
POST | /organization/invite-member | auth.api.create_invitation |
POST | /organization/accept-invitation | auth.api.accept_invitation |
POST | /organization/add-member | auth.api.add_member |
POST | /organization/update-member-role | auth.api.update_member_role |
POST | /organization/create-team | auth.api.create_team |
POST | /organization/create-role | auth.api.create_org_role |
Options
Current Ruby options accepted by BetterAuth::Plugins.organization:
allow_user_to_create_organizationcreator_rolemembership_limitinvitation_expires_ininvitation_limitacrolesorganization_limitcancel_pending_invitations_on_re_invitesend_invitation_emailrequire_email_verification_on_invitation
Support Notes
- The examples above are based on Ruby plugin source and tests in
packages/better_auth. - If an upstream section is not represented here, treat it as not yet documented or not yet supported by the Ruby port until the matching Ruby implementation exists.