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

config/auth.rb
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

server.rb
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

MethodPathRuby API method
POST/organization/createauth.api.create_organization
GET/organization/listauth.api.list_organizations
POST/organization/set-activeauth.api.set_active_organization
POST/organization/invite-memberauth.api.create_invitation
POST/organization/accept-invitationauth.api.accept_invitation
POST/organization/add-memberauth.api.add_member
POST/organization/update-member-roleauth.api.update_member_role
POST/organization/create-teamauth.api.create_team
POST/organization/create-roleauth.api.create_org_role

Options

Current Ruby options accepted by BetterAuth::Plugins.organization:

  • allow_user_to_create_organization
  • creator_role
  • membership_limit
  • invitation_expires_in
  • invitation_limit
  • ac
  • roles
  • organization_limit
  • cancel_pending_invitations_on_re_invite
  • send_invitation_email
  • require_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.

On this page