Better Auth in Rust
OpenAPI Reference

Admin

Admin plugin endpoints for user management, banning, and impersonation.

Set Role

POST
/admin/set-role

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

role*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/admin/set-role" \  -H "Content-Type: application/json" \  -d '{    "userId": "string",    "role": "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"
}

Create User

POST
/admin/create-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

email*string

The email of the user

password*string

The password of the user

name*string

The name of the user

role?string
data?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/admin/create-user" \  -H "Content-Type: application/json" \  -d '{    "email": "string",    "password": "string",    "name": "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"
}

List Users

GET
/admin/list-users

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Query Parameters

searchValue?string

The value to search for

searchField?string

The field to search in, defaults to email. Can be email or name

searchOperator?string

The operator to use for the search. Can be contains, starts_with or ends_with

limit?string

The number of users to return

offset?string

The offset to start from

sortBy?string

The field to sort by

sortDirection?string

The direction to sort by

filterField?string

The field to filter by

filterValue?string

The value to filter by

filterOperator?string

The operator to use for the filter

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/admin/list-users"
{
  "users": [
    {
      "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"
    }
  ],
  "total": 0,
  "limit": 0,
  "offset": 0
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

List User Sessions

POST
/admin/list-user-sessions

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/admin/list-user-sessions" \  -H "Content-Type: application/json" \  -d '{    "userId": "string"  }'
{
  "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"
}

Unban User

POST
/admin/unban-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/admin/unban-user" \  -H "Content-Type: application/json" \  -d '{    "userId": "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"
}

Ban User

POST
/admin/ban-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

banReason?string

The reason for the ban

banExpiresIn?string

The number of seconds until the ban expires

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/admin/ban-user" \  -H "Content-Type: application/json" \  -d '{    "userId": "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"
}

Impersonate User

POST
/admin/impersonate-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/admin/impersonate-user" \  -H "Content-Type: application/json" \  -d '{    "userId": "string"  }'
{
  "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"
}

/admin/stop-impersonating

POST
/admin/stop-impersonating

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/admin/stop-impersonating"
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

Revoke User Session

POST
/admin/revoke-user-session

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

sessionToken*string

The session 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/admin/revoke-user-session" \  -H "Content-Type: application/json" \  -d '{    "sessionToken": "string"  }'
{
  "success": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

Revoke User Sessions

POST
/admin/revoke-user-sessions

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

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

Remove User

POST
/admin/remove-user

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

userId*string

The user id

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

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

Set User Password

POST
/admin/set-user-password

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

newPassword*string

The new password

userId*string

The user id

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

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

/admin/has-permission

POST
/admin/has-permission

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

permission?objectDeprecated

The permission to check

permissions*object

The permission to check

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/admin/has-permission" \  -H "Content-Type: application/json" \  -d '{    "permissions": {}  }'
{
  "error": "string",
  "success": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}