Better Auth in Rust
OpenAPI Reference

Default

Default endpoints that are included with Better Auth by default. These endpoints are not part of any plugin.

Social Sign In

POST
/sign-in/social

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

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

OAuth2 provider to use

disableRedirect?string

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

idToken?string

ID token from the provider to sign in the user with id token

scopes?string

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

requestSignUp?string

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

loginHint?string

The login hint to use for the authorization code request

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/sign-in/social" \  -H "Content-Type: application/json" \  -d '{    "provider": "string"  }'
{
  "redirect": false,
  "token": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/get-session

GET
/get-session

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/get-session"
{
  "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": true,
    "image": "string",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "username": "string",
    "displayUsername": "string",
    "twoFactorEnabled": true,
    "role": "string",
    "banned": true,
    "banReason": "string",
    "banExpires": "2019-08-24T14:15:22Z"
  }
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/sign-out

POST
/sign-out

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/sign-out" \  -H "Content-Type: application/json" \  -d '{}'
{
  "success": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/sign-up/email

POST
/sign-up/email

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

name*string

The name of the user

email*string

The email of the user

password*string

The password of the user

callbackURL?string

The URL to use for email verification callback

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/sign-up/email" \  -H "Content-Type: application/json" \  -d '{    "name": "string",    "email": "string",    "password": "string"  }'
{
  "token": "string",
  "user": {
    "id": "string",
    "email": "[email protected]",
    "name": "string",
    "image": "http://example.com",
    "emailVerified": true,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/sign-in/email

POST
/sign-in/email

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

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?string

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

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/sign-in/email" \  -H "Content-Type: application/json" \  -d '{    "email": "string",    "password": "string"  }'
{
  "redirect": false,
  "token": "string",
  "url": null,
  "user": {
    "id": "string",
    "email": "string",
    "name": "string",
    "image": "string",
    "emailVerified": true,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/forget-password

POST
/forget-password

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

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

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/forget-password" \  -H "Content-Type: application/json" \  -d '{    "email": "string"  }'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/reset-password

POST
/reset-password

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

newPassword*string

The new password to set

token?string

The token to reset the password

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/reset-password" \  -H "Content-Type: application/json" \  -d '{    "newPassword": "string"  }'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/verify-email

GET
/verify-email

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Query Parameters

token*string

The token to verify the email

callbackURL?string

The URL to redirect to after email verification

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/verify-email?token=string"
{
  "user": {
    "id": "string",
    "email": "string",
    "name": "string",
    "image": "string",
    "emailVerified": true,
    "createdAt": "string",
    "updatedAt": "string"
  },
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/send-verification-email

POST
/send-verification-email

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

email*string

The email to send the verification email to

callbackURL?string

The URL to use for email verification callback

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/send-verification-email" \  -H "Content-Type: application/json" \  -d '{    "email": "[email protected]"  }'
{
  "status": true
}
{
  "message": "Verification email isn't enabled"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/change-email

POST
/change-email

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

newEmail*string

The new email to set

callbackURL?string

The URL to redirect to after email verification

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/change-email" \  -H "Content-Type: application/json" \  -d '{    "newEmail": "string"  }'
{
  "status": true,
  "message": "Email updated"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/change-password

POST
/change-password

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

newPassword*string

The new password to set

currentPassword*string

The current password

revokeOtherSessions?string

Revoke all other sessions

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/change-password" \  -H "Content-Type: application/json" \  -d '{    "newPassword": "string",    "currentPassword": "string"  }'
{
  "token": "string",
  "user": {
    "id": "string",
    "email": "[email protected]",
    "name": "string",
    "image": "http://example.com",
    "emailVerified": true,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/update-user

POST
/update-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

name?string

The name of the user

image?string

The image of the user

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/update-user" \  -H "Content-Type: application/json" \  -d '{}'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/delete-user

POST
/delete-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

callbackURL?string
password?string
token?string

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/delete-user" \  -H "Content-Type: application/json" \  -d '{}'
{
  "success": true,
  "message": "User deleted"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/reset-password/{token}

GET
/reset-password/{token}

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Query Parameters

callbackURL?string

The URL to redirect the user to reset their password

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/reset-password/{token}"
{
  "token": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/list-sessions

GET
/list-sessions

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/list-sessions"
[
  {
    "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"
  }
]
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/revoke-session

POST
/revoke-session

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

token*string

The token to revoke

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/revoke-session" \  -H "Content-Type: application/json" \  -d '{    "token": "string"  }'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/revoke-sessions

POST
/revoke-sessions

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/revoke-sessions" \  -H "Content-Type: application/json" \  -d '{}'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/revoke-other-sessions

POST
/revoke-other-sessions

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/revoke-other-sessions" \  -H "Content-Type: application/json" \  -d '{}'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
POST
/link-social

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

callbackURL?string

The URL to redirect to after the user has signed in

provider*string

The OAuth2 provider to use

scopes?string

Additional scopes to request from the provider

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/link-social" \  -H "Content-Type: application/json" \  -d '{    "provider": "string"  }'
{
  "url": "string",
  "redirect": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/list-accounts

GET
/list-accounts

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/list-accounts"
[
  {
    "id": "string",
    "provider": "string",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
]
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/delete-user/callback

GET
/delete-user/callback

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Query Parameters

token?string
callbackURL?string

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/delete-user/callback"
{
  "success": true,
  "message": "User deleted"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
POST
/unlink-account

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

providerId*string
accountId?string

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/unlink-account" \  -H "Content-Type: application/json" \  -d '{    "providerId": "string"  }'
{
  "status": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/refresh-token

POST
/refresh-token

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

providerId*string

The provider ID for the OAuth provider

accountId?string

The account ID associated with the refresh token

userId?string

The user ID associated with the account

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/refresh-token" \  -H "Content-Type: application/json" \  -d '{    "providerId": "string"  }'
{
  "tokenType": "string",
  "idToken": "string",
  "accessToken": "string",
  "refreshToken": "string",
  "accessTokenExpiresAt": "2019-08-24T14:15:22Z",
  "refreshTokenExpiresAt": "2019-08-24T14:15:22Z"
}
Empty
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/get-access-token

POST
/get-access-token

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

providerId*string

The provider ID for the OAuth provider

accountId?string

The account ID associated with the refresh token

userId?string

The user ID associated with the account

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/get-access-token" \  -H "Content-Type: application/json" \  -d '{    "providerId": "string"  }'
{
  "tokenType": "string",
  "idToken": "string",
  "accessToken": "string",
  "refreshToken": "string",
  "accessTokenExpiresAt": "2019-08-24T14:15:22Z",
  "refreshTokenExpiresAt": "2019-08-24T14:15:22Z"
}
Empty
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/ok

GET
/ok

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/ok"
{
  "ok": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/error

GET
/error

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

text/html

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/error"
"string"
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}