Skip to Content
Documentation

Core

Email and password sign-up and sign-in, sessions, the user's profile and linked accounts.

Social Sign In

POST
/sign-in/social

Sign in with a social provider

Request Body

application/json
  1. body
callbackURL?string

Callback URL to redirect to after the user has signed in

newUserCallbackURL?string
errorCallbackURL?string

Callback URL to redirect to if an error happens

provider*|string
disableRedirect?boolean

Disable automatic redirection to the provider. Useful for handling the redirection yourself

idToken?
scopes?array<string>

Array of scopes to request from the provider. This will override the default scopes passed.

requestSignUp?boolean

Explicitly request sign-up. Useful when disableImplicitSignUp is true for this provider

loginHint?string

The login hint to use for the authorization code request

additionalParams?

Extra query parameters to append to the provider authorization URL (e.g. Cognito identity_provider, Google hd).

additionalData?

Response Body

Success - Returns session details (idToken branch) or an authorize URL (redirect branch)

application/json
  1. response

Returns session details when idToken is provided, or an authorize URL otherwise

token?string
user?
url?string
redirect*boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/sign-in/social' \  -H 'Content-Type: application/json' \  -d '{  "provider": "apple"}'
Example Response
{  "token": "string",  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  },  "url": "string",  "redirect": true}

/callback/{id}

GET
/callback/{id}

Path Parameters

id*string

Query Parameters

code?string
error?string
device_id?string
error_description?string
state?string
user?string
iss?string

Response Body

Bad Request. Usually due to missing parameters, or invalid parameters.

application/json
  1. response
message*string
Example Request
curl -X GET 'https://auth.example.com/api/auth/callback/string'
Example Response
{  "message": "string"}

/callback/{id}

POST
/callback/{id}

Path Parameters

id*string

Query Parameters

code?string
error?string
device_id?string
error_description?string
state?string
user?string
iss?string

Request Body

application/json
  1. body
code?string
error?string
device_id?string
error_description?string
state?string
user?string
iss?string

Response Body

Bad Request. Usually due to missing parameters, or invalid parameters.

application/json
  1. response
message*string
Example Request
curl -X POST 'https://auth.example.com/api/auth/callback/string' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "message": "string"}

Get Session

GET
/get-session

Get the current session

Query Parameters

disableCookieCache?boolean

Disable cookie cache and fetch session from database

disableRefresh?boolean

Disable session refresh. Useful for checking session status, without updating the session

Response Body

Success

application/json
  1. response
session*
user*
Example Request
curl -X GET 'https://auth.example.com/api/auth/get-session'
Example Response
{  "session": {    "id": "string",    "expiresAt": "2019-08-24T14:15:22Z",    "token": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "ipAddress": "string",    "userAgent": "string",    "userId": "string",    "impersonatedBy": "string",    "activeOrganizationId": "string"  },  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  }}

Get Session Post

POST
/get-session

Get the current session

Query Parameters

disableCookieCache?boolean

Disable cookie cache and fetch session from database

disableRefresh?boolean

Disable session refresh. Useful for checking session status, without updating the session

Request Body

application/json
  1. body

Response Body

Success

application/json
  1. response
session*
user*
Example Request
curl -X POST 'https://auth.example.com/api/auth/get-session' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "session": {    "id": "string",    "expiresAt": "2019-08-24T14:15:22Z",    "token": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "ipAddress": "string",    "userAgent": "string",    "userId": "string",    "impersonatedBy": "string",    "activeOrganizationId": "string"  },  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  }}

Sign Out

POST
/sign-out

Sign out the current user

Request Body

application/json
  1. body
callbackURL?string

The URL to redirect to after provider logout

disableRedirect?boolean

Return the provider logout URL without redirecting

state?string

State to pass to the provider logout endpoint

Response Body

Success

application/json
  1. response
success?boolean
url?string

Provider logout URL when RP-initiated logout is available

redirect?boolean

Whether the client should redirect to the provider logout URL

Example Request
curl -X POST 'https://auth.example.com/api/auth/sign-out' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "success": true,  "url": "string",  "redirect": true}
POST
/sign-up/email

Sign up a user using email and password

Request Body

application/json
  1. body
name*string

The name of the user

email*string

The email of the user

password*string

The password of the user

image?string

The profile image URL of the user

callbackURL?string

The URL to use for email verification callback

rememberMe?boolean

If this is false, the session will not be remembered. Default is true.

username?string
displayUsername?string

Response Body

Successfully created user

application/json
  1. response
token?string

Authentication token for the session

user*
Example Request
curl -X POST 'https://auth.example.com/api/auth/sign-up/email' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "email": "string",  "password": "string"}'
Example Response
{  "token": "string",  "user": {    "id": "string",    "email": "user@example.com",    "name": "string",    "image": "http://example.com",    "emailVerified": true,    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }}

Sign In Email

POST
/sign-in/email

Sign in with email and password

Request Body

application/json
  1. body
email*string

Email of the user

password*string

Password of the user

callbackURL?string

Callback URL to use as a redirect for email verification

rememberMe?boolean

If this is false, the session will not be remembered. Default is true.

Response Body

Success - Returns either session details or redirect URL

application/json
  1. response

Session response when idToken is provided

redirect*false
Value infalse
token*string

Session token

url?string
user*
Example Request
curl -X POST 'https://auth.example.com/api/auth/sign-in/email' \  -H 'Content-Type: application/json' \  -d '{  "email": "string",  "password": "string"}'
Example Response
{  "redirect": false,  "token": "string",  "url": "string",  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  }}

Reset Password

POST
/reset-password

Reset the password for a user

Query Parameters

token?string

Request Body

application/json
  1. body
newPassword*string

The new password to set

token?string

The token to reset the password

Response Body

Success

application/json
  1. response
status?boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/reset-password' \  -H 'Content-Type: application/json' \  -d '{  "newPassword": "string"}'
Example Response
{  "status": true}

Verify Password

POST
/verify-password

Verify the current user's password

Request Body

application/json
  1. body
password*string

The password to verify

Response Body

Success

application/json
  1. response
status?boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/verify-password' \  -H 'Content-Type: application/json' \  -d '{  "password": "string"}'
Example Response
{  "status": true}

/verify-email

GET
/verify-email

Verify the email of the user

Query Parameters

token*string

The token to verify the email

callbackURL?string

The URL to redirect to after email verification

Response Body

Success

application/json
  1. response
user*
status*boolean

Indicates if the email was verified successfully

Example Request
curl -X GET 'https://auth.example.com/api/auth/verify-email?token=string'
Example Response
{  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  },  "status": true}

Send Verification Email

POST
/send-verification-email

Send a verification email to the user

Request Body

application/json
  1. body
email*string

The email to send the verification email to

callbackURL?string

The URL to use for email verification callback

Response Body

Success

application/json
  1. response
status?boolean

Indicates if the email was sent successfully

Example Request
curl -X POST 'https://auth.example.com/api/auth/send-verification-email' \  -H 'Content-Type: application/json' \  -d '{  "email": "string"}'
Example Response
{  "status": true}

Change Email

POST
/change-email

Request Body

application/json
  1. body
newEmail*string

The new email address to set must be a valid email address

callbackURL?string

The URL to redirect to after email verification

Response Body

Email change request processed successfully

application/json
  1. response
user?
status*boolean

Indicates if the request was successful

message?string

Status message of the email change process

Value in"Email updated""Verification email sent"
Example Request
curl -X POST 'https://auth.example.com/api/auth/change-email' \  -H 'Content-Type: application/json' \  -d '{  "newEmail": "string"}'
Example Response
{  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  },  "status": true,  "message": "Email updated"}

Change Password

POST
/change-password

Change the password of the user

Request Body

application/json
  1. body
newPassword*string

The new password to set

currentPassword*string

The current password is required

revokeOtherSessions?boolean

Must be a boolean value

Response Body

Password successfully changed

application/json
  1. response
token?string

New session token if other sessions were revoked

user*
Example Request
curl -X POST 'https://auth.example.com/api/auth/change-password' \  -H 'Content-Type: application/json' \  -d '{  "newPassword": "string",  "currentPassword": "string"}'
Example Response
{  "token": "string",  "user": {    "id": "string",    "email": "user@example.com",    "name": "string",    "image": "http://example.com",    "emailVerified": true,    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }}

Update Session

POST
/update-session

Update the current session

Request Body

application/json
  1. body
[key: string]?unknown

Response Body

Success

application/json
  1. response
session?
Example Request
curl -X POST 'https://auth.example.com/api/auth/update-session' \  -H 'Content-Type: application/json' \  -d '{  "property1": null,  "property2": null}'
Example Response
{  "session": {    "id": "string",    "expiresAt": "2019-08-24T14:15:22Z",    "token": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "ipAddress": "string",    "userAgent": "string",    "userId": "string",    "impersonatedBy": "string",    "activeOrganizationId": "string"  }}

Update User

POST
/update-user

Update the current user

Request Body

application/json
  1. body
name?string

The name of the user

image?string

The image of the user

username?string
displayUsername?string

Response Body

Success

application/json
  1. response
user?
Example Request
curl -X POST 'https://auth.example.com/api/auth/update-user' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  }}

Delete User

POST
/delete-user

Delete the user

Request Body

application/json
  1. body
callbackURL?string

The callback URL to redirect to after the user is deleted

password?string

The user's password. Required if session is not fresh

token?string

The deletion verification token

Response Body

User deletion processed successfully

application/json
  1. response
success*boolean

Indicates if the operation was successful

message*string

Status message of the deletion process

Value in"User deleted""Verification email sent"
Example Request
curl -X POST 'https://auth.example.com/api/auth/delete-user' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "success": true,  "message": "User deleted"}

Request Password Reset

POST
/request-password-reset

Send a password reset email to the user

Request Body

application/json
  1. body
email*string

The email address of the user to send a password reset email to

redirectTo?string

The URL to redirect the user to reset their password. If the token isn't valid or expired, it'll be redirected with a query parameter ?error=INVALID_TOKEN. If the token is valid, it'll be redirected with a query parameter `?token=VALID_TOKEN

Response Body

Success

application/json
  1. response
status?boolean
message?string
Example Request
curl -X POST 'https://auth.example.com/api/auth/request-password-reset' \  -H 'Content-Type: application/json' \  -d '{  "email": "string"}'
Example Response
{  "status": true,  "message": "string"}

Reset Password Callback

GET
/reset-password/{token}

Redirects the user to the callback URL with the token

Path Parameters

token*string

The token to reset the password

Query Parameters

callbackURL*string

The URL to redirect the user to reset their password

Response Body

Success

application/json
  1. response
token?string
Example Request
curl -X GET 'https://auth.example.com/api/auth/reset-password/string?callbackURL=string'
Example Response
{  "token": "string"}

List User Sessions

GET
/list-sessions

List all active sessions for the user

Response Body

Success

application/json
  1. response
[index: integer]?
Example Request
curl -X GET 'https://auth.example.com/api/auth/list-sessions'
Example Response
[  {    "id": "string",    "expiresAt": "2019-08-24T14:15:22Z",    "token": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "ipAddress": "string",    "userAgent": "string",    "userId": "string",    "impersonatedBy": "string",    "activeOrganizationId": "string"  }]

/revoke-session

POST
/revoke-session

Revoke a single session

Request Body

application/json
  1. body
token*string

The token to revoke

Response Body

Success

application/json
  1. response
status*boolean

Indicates if the session was revoked successfully

Example Request
curl -X POST 'https://auth.example.com/api/auth/revoke-session' \  -H 'Content-Type: application/json' \  -d '{  "token": "string"}'
Example Response
{  "status": true}

/revoke-sessions

POST
/revoke-sessions

Revoke all sessions for the user

Request Body

application/json
  1. body

Response Body

Success

application/json
  1. response
status*boolean

Indicates if all sessions were revoked successfully

Example Request
curl -X POST 'https://auth.example.com/api/auth/revoke-sessions' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "status": true}

/revoke-other-sessions

POST
/revoke-other-sessions

Revoke all other sessions for the user except the current one

Request Body

application/json
  1. body

Response Body

Success

application/json
  1. response
status*boolean

Indicates if all other sessions were revoked successfully

Example Request
curl -X POST 'https://auth.example.com/api/auth/revoke-other-sessions' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "status": true}
POST
/link-social

Link a social account to the user

Request Body

application/json
  1. body
callbackURL?string

The URL to redirect to after the user has signed in

provider*|string
idToken?
requestSignUp?boolean
scopes?array<string>

Additional scopes to request from the provider

errorCallbackURL?string

The URL to redirect to if there is an error during the link process

disableRedirect?boolean

Disable automatic redirection to the provider. Useful for handling the redirection yourself

loginHint?string

The login hint to use for the authorization code request

additionalParams?

Extra query parameters to append to the provider authorization URL (e.g. Cognito identity_provider, Google hd).

additionalData?

Response Body

Success

application/json
  1. response
url?string

The authorization URL to redirect the user to

redirect*boolean

Indicates if the user should be redirected to the authorization URL

status?boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/link-social' \  -H 'Content-Type: application/json' \  -d '{  "provider": "apple"}'
Example Response
{  "url": "string",  "redirect": true,  "status": true}

List User Accounts

GET
/list-accounts

List all accounts linked to the user

Response Body

Success

application/json
  1. response
[index: integer]?
Example Request
curl -X GET 'https://auth.example.com/api/auth/list-accounts'
Example Response
[  {    "id": "string",    "providerId": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "accountId": "string",    "userId": "string",    "scopes": [      "string"    ]  }]
POST
/unlink-account

Unlink an account

Request Body

application/json
  1. body
accountId*string

The Better Auth account ID to unlink

Response Body

Success

application/json
  1. response
status?boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/unlink-account' \  -H 'Content-Type: application/json' \  -d '{  "accountId": "string"}'
Example Response
{  "status": true}

/refresh-token

POST
/refresh-token

Refresh the access token using a refresh token

Request Body

application/json
  1. body
accountId*string

The Better Auth account ID

userId?string

The user ID associated with the account

Response Body

Access token refreshed successfully

application/json
  1. response
tokenType?string
idToken?string
accessToken?string
refreshToken?string
accessTokenExpiresAt?string
Formatdate-time
refreshTokenExpiresAt?string
Formatdate-time
Example Request
curl -X POST 'https://auth.example.com/api/auth/refresh-token' \  -H 'Content-Type: application/json' \  -d '{  "accountId": "string"}'
Example Response
{  "tokenType": "string",  "idToken": "string",  "accessToken": "string",  "refreshToken": "string",  "accessTokenExpiresAt": "2019-08-24T14:15:22Z",  "refreshTokenExpiresAt": "2019-08-24T14:15:22Z"}

/get-access-token

POST
/get-access-token

Get a valid access token, doing a refresh if needed

Request Body

application/json
  1. body
accountId*string

The Better Auth account ID

userId?string

The user ID associated with the account

Response Body

A Valid access token

application/json
  1. response
tokenType?string
idToken?string
accessToken?string
accessTokenExpiresAt?string
Formatdate-time
Example Request
curl -X POST 'https://auth.example.com/api/auth/get-access-token' \  -H 'Content-Type: application/json' \  -d '{  "accountId": "string"}'
Example Response
{  "tokenType": "string",  "idToken": "string",  "accessToken": "string",  "accessTokenExpiresAt": "2019-08-24T14:15:22Z"}

/account-info

GET
/account-info

Get the account info provided by the provider

Response Body

Success

application/json
  1. response
user*
account*
data*
Example Request
curl -X GET 'https://auth.example.com/api/auth/account-info'
Example Response
{  "user": {    "name": "string",    "email": "string",    "image": "string",    "emailVerified": true  },  "account": {    "id": "string",    "providerId": "string",    "accountId": "string"  },  "data": {}}

/ok

GET
/ok

Check if the API is working

Response Body

API is working

application/json
  1. response
ok*boolean

Indicates if the API is working

Example Request
curl -X GET 'https://auth.example.com/api/auth/ok'
Example Response
{  "ok": true}

/error

GET
/error

Displays an error page

Response Body

Success

response?stringtext/html

The HTML content of the error page

Example Request
curl -X GET 'https://auth.example.com/api/auth/error'
Example Response
"string"