Skip to content

Endpoints ​

All endpoints are mounted under your Better Auth base path (e.g. /api/auth).

Tenant management ​

Requires management authorization unless noted. See Tenant management for membership roles vs global admin rules.

POST /tenant/create ​

Create a new tenant. The authenticated platform user’s id is stored as ownerId and an owner tenantMember row is created when a session is present.

Body

FieldTypeRequiredDescription
namestringyesDisplay name
slugstringyesUnique URL-friendly id
metadataobjectnoArbitrary JSON metadata

Response: Tenant object


GET /tenant/get ​

Get a tenant by id or slug. This endpoint is public, but the response depends on the caller:

  • Unauthorized callers (and unrelated platform users) receive only the public fields: id, name, slug, createdAt.
  • Tenant members and global admins (canManageTenants) receive the full record, including ownerId and metadata.
  • Set exposeTenantDetailsPublicly: true to always return the full record (not recommended if metadata holds private data).

Query

FieldTypeRequiredDescription
idstringone ofTenant id
slugstringone ofTenant slug

Response: Tenant object (public subset for unauthorized callers)


GET /tenant/list ​

List tenants the caller can access (all for global admin; memberships for platform users).

Query

FieldTypeRequiredDescription
limitnumbernoMax items to return (1–100)
offsetnumbernoNumber of items to skip (default 0)

Response: Array of tenant objects when limit and offset are omitted. When either is provided, returns { data, total, nextOffset? }.


POST /tenant/update ​

Update a tenant. Requires admin role or higher (or global admin).

Body

FieldTypeRequiredDescription
idstringyesTenant to update
dataobjectyesFields to update

data may include name, slug, and metadata. Pass metadata: null to clear metadata; omit the field to leave it unchanged.

Response: Updated tenant object


POST /tenant/delete ​

Delete a tenant and cascade related records. Requires owner role (or global admin).

Body

FieldTypeRequiredDescription
idstringyesTenant to delete

Response: { success: true }

Membership ​

POST /tenant/member/add ​

Add a platform user as a member. Requires admin or higher. Admins may only assign role member.

Body

FieldTypeRequiredDescription
tenantIdstringyesTenant
userIdstringone ofPlatform user id
emailstringone ofPlatform user email
rolestringnoowner | admin | member

Response: TenantMember object


GET /tenant/member/list ​

List members. Requires member role or higher.

Query

FieldTypeRequiredDescription
tenantIdstringyesTenant
limitnumbernoMax items to return (1–100)
offsetnumbernoNumber of items to skip (default 0)

Response: Array of TenantMember objects when limit and offset are omitted. When either is provided, returns { data, total, nextOffset? }.


POST /tenant/member/update ​

Change a member’s role. Requires owner (or global admin). Cannot demote the last owner.

Body: tenantId, userId, role

Response: TenantMember object


POST /tenant/member/remove ​

Remove a member. Requires admin or higher. Admins cannot remove owners/admins. Cannot remove the last owner.

Body: tenantId, userId

Response: { success: true }

Invites ​

Manage invites for tenant end-user email and first-time OAuth registration. Requires admin role or higher (or global admin). When requireInviteForTenantSignUp is enabled, registration must include a matching inviteToken.

POST /tenant/invite/create ​

Create an invite for a tenant end-user.

Body

FieldTypeRequiredDescription
tenantIdstringyesTenant
emailstringyesEmail address to invite
expiresInnumbernoLifetime in seconds (default 7 days)

Response: TenantInvite object (includes token for the sign-up link)


GET /tenant/invite/list ​

List invites for a tenant. By default returns only pending (unconsumed, unrevoked, unexpired) invites.

Query

FieldTypeRequiredDescription
tenantIdstringyesTenant
includeConsumedbooleannoInclude consumed and revoked invites

Response: Array of TenantInvite objects


POST /tenant/invite/revoke ​

Revoke a pending invite.

Body: tenantId, inviteId

Response: TenantInvite object

Email auth ​

POST /tenant/sign-up/email ​

Sign up a user under a tenant.

Body

FieldTypeRequiredDescription
tenantIdstringno*Tenant id
namestringyesUser display name
emailstringyesEmail address
passwordstringyesPassword
imagestringnoProfile image URL
callbackURLstringnoEmail verification callback
rememberMebooleannoRemember session (default true)
inviteTokenstringno*Invite token from an admin

*Required when requireInviteForTenantSignUp is enabled.

*Required unless resolved via header or resolveTenantId.

Response: User and session (when verification not required)


POST /tenant/sign-in/email ​

Sign in a user under a tenant.

Body

FieldTypeRequiredDescription
tenantIdstringno*Tenant id
emailstringyesEmail address
passwordstringyesPassword
callbackURLstringnoRedirect after sign-in
rememberMebooleannoRemember session (default true)

Response: User and session


GET /tenant/verify-email ​

Verify a tenant-scoped user's email from the link sent by signUpEmailTenant / signInEmailTenant. Not interchangeable with core's GET /verify-email — see Email auth.

Query

FieldTypeRequiredDescription
tokenstringyesTenant-scoped verification token
callbackURLstringnoRedirect target after (or on failure)

Response: { status: true, user: null }, or a redirect to callbackURL (with ?error=<code> on failure) when provided

OAuth configuration ​

Requires management authorization.

POST /tenant/oauth-config/register ​

Create or update a per-tenant OAuth provider config.

Body

FieldTypeRequiredDescription
tenantIdstringno*Tenant id
providerIdstringyese.g. google, github
clientIdstringyesOAuth client id
clientSecretstringyesOAuth client secret
scopesstring[]noRequested scopes
redirectURIstringnoOverride redirect URI
enabledbooleannoDefault true

Response: Config object (no client secret)


GET /tenant/oauth-config/list ​

List OAuth configs for a tenant.

Query

FieldTypeRequiredDescription
tenantIdstringno*Tenant id

Response: Array of config objects (secrets omitted)


POST /tenant/oauth-config/delete ​

Delete a tenant OAuth config.

Body

FieldTypeRequiredDescription
tenantIdstringno*Tenant id
providerIdstringyesProvider to remove

Response: { success: true }

OAuth sign-in ​

POST /tenant/sign-in/social ​

Start OAuth sign-in for a tenant.

Body

FieldTypeRequiredDescription
tenantIdstringno*Tenant id
providerstringyesProvider id
callbackURLstringnoSuccess redirect
newUserCallbackURLstringnoRedirect for newly registered users
errorCallbackURLstringnoError redirect
inviteTokenstringno*Required for first-time registration when invite-only sign-up is enabled
requestSignUpbooleannoExplicitly request sign-up
disableRedirectbooleannoReturn the URL instead of redirecting

Response: Redirect to OAuth provider (or { url, redirect } when disableRedirect is true)

First-time social registration honors requireInviteForTenantSignUp / allowedEmailDomains the same way as email sign-up. Existing OAuth users can sign in without an invite.


GET /tenant/callback/{providerId} ​

OAuth callback handler. Creates a session with tenantId and redirects to callbackURL.

Tenant id resolution ​

For endpoints marked with *, tenantId can be omitted when resolved via:

  1. resolveTenantId option
  2. Request body tenantId
  3. Query tenantId
  4. Header (default x-tenant-id)

See Configuration.

Released under the MIT License.