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.

POST /tenant/create

Create a new tenant.

Body

FieldTypeRequiredDescription
namestringyesDisplay name
slugstringyesUnique URL-friendly id
metadataobjectnoArbitrary JSON metadata

Response: Tenant object


GET /tenant/get

Get a tenant by id or slug.

Query

FieldTypeRequiredDescription
idstringone ofTenant id
slugstringone ofTenant slug

Response: Tenant object


GET /tenant/list

List all tenants.

Response: Array of tenant objects


POST /tenant/update

Update a tenant.

Body

FieldTypeRequiredDescription
tenantIdstringyesTenant to update
namestringnoNew display name
slugstringnoNew slug
metadataobjectnoNew metadata

Response: Updated tenant object


POST /tenant/delete

Delete a tenant and cascade related records.

Body

FieldTypeRequiredDescription
tenantIdstringyesTenant to delete

Response: { success: true }

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)

*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

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
errorCallbackURLstringnoError redirect

Response: Redirect to OAuth provider


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.