---
title: supertokens-node/recipe/userroles
description: References documentation for the supertokens-node/recipe/userroles package
sidebar:
  order: 270
---

## Classes

### default

Defined in: [recipe/userroles/index.ts:22](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L22)

#### Constructors

##### Constructor

```ts check=false reason="Generated API signature"
new default(): default;
```

###### Returns

[`default`](#default)

#### Properties

| Property | Modifier | Type | Default value | Defined in |
| ------ | ------ | ------ | ------ | ------ |
| <a id="member-default-init"></a> `init` | `static` | (`config?`) => [`RecipeListFunction`](types#recipelistfunction) | `Recipe.init` | [recipe/userroles/index.ts:23](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L23) |
| <a id="member-default-permissionclaim"></a> `PermissionClaim` | `static` | `PermissionClaimClass` | `PermissionClaim` | [recipe/userroles/index.ts:24](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L24) |
| <a id="member-default-userroleclaim"></a> `UserRoleClaim` | `static` | `UserRoleClaimClass` | `UserRoleClaim` | [recipe/userroles/index.ts:25](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L25) |

#### Methods

##### addRoleToUser()

```ts check=false reason="Generated API signature"
static addRoleToUser(
   tenantId, 
   userId, 
   role, 
   userContext?): Promise<
  | {
  didUserAlreadyHaveRole: boolean;
  status: "OK";
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}>;
```

Defined in: [recipe/userroles/index.ts:27](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L27)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userId` | `string` |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `didUserAlreadyHaveRole`: `boolean`;
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

##### createNewRoleOrAddPermissions()

```ts check=false reason="Generated API signature"
static createNewRoleOrAddPermissions(
   role, 
   permissions, 
   userContext?): Promise<{
  createdNewRole: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/userroles/index.ts:61](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L61)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `permissions` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `createdNewRole`: `boolean`;
  `status`: `"OK"`;
\}\>

##### deleteRole()

```ts check=false reason="Generated API signature"
static deleteRole(role, userContext?): Promise<{
  didRoleExist: boolean;
  status: "OK";
}>;
```

Defined in: [recipe/userroles/index.ts:91](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L91)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `didRoleExist`: `boolean`;
  `status`: `"OK"`;
\}\>

##### getAllRoles()

```ts check=false reason="Generated API signature"
static getAllRoles(userContext?): Promise<{
  roles: string[];
  status: "OK";
}>;
```

Defined in: [recipe/userroles/index.ts:98](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L98)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `roles`: `string`[];
  `status`: `"OK"`;
\}\>

##### getPermissionsForRole()

```ts check=false reason="Generated API signature"
static getPermissionsForRole(role, userContext?): Promise<
  | {
  permissions: string[];
  status: "OK";
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}>;
```

Defined in: [recipe/userroles/index.ts:69](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L69)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `permissions`: `string`[];
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

##### getRolesForUser()

```ts check=false reason="Generated API signature"
static getRolesForUser(
   tenantId, 
   userId, 
   userContext?): Promise<{
  roles: string[];
  status: "OK";
}>;
```

Defined in: [recipe/userroles/index.ts:45](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L45)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `roles`: `string`[];
  `status`: `"OK"`;
\}\>

##### getRolesThatHavePermission()

```ts check=false reason="Generated API signature"
static getRolesThatHavePermission(permission, userContext?): Promise<{
  roles: string[];
  status: "OK";
}>;
```

Defined in: [recipe/userroles/index.ts:84](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L84)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `permission` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `roles`: `string`[];
  `status`: `"OK"`;
\}\>

##### getUsersThatHaveRole()

```ts check=false reason="Generated API signature"
static getUsersThatHaveRole(
   tenantId, 
   role, 
   userContext?): Promise<
  | {
  status: "OK";
  users: string[];
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}>;
```

Defined in: [recipe/userroles/index.ts:53](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L53)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `users`: `string`[];
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

##### removePermissionsFromRole()

```ts check=false reason="Generated API signature"
static removePermissionsFromRole(
   role, 
   permissions, 
   userContext?): Promise<{
  status: "OK" | "UNKNOWN_ROLE_ERROR";
}>;
```

Defined in: [recipe/userroles/index.ts:76](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L76)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `permissions` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<\{
  `status`: `"OK"` \| `"UNKNOWN_ROLE_ERROR"`;
\}\>

##### removeUserRole()

```ts check=false reason="Generated API signature"
static removeUserRole(
   tenantId, 
   userId, 
   role, 
   userContext?): Promise<
  | {
  didUserHaveRole: boolean;
  status: "OK";
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}>;
```

Defined in: [recipe/userroles/index.ts:36](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L36)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userId` | `string` |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

###### Returns

`Promise`\<
  \| \{
  `didUserHaveRole`: `boolean`;
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

## Variables

### addRoleToUser()

```ts check=false reason="Generated API signature"
const addRoleToUser: (tenantId, userId, role, userContext?) => Promise<
  | {
  didUserAlreadyHaveRole: boolean;
  status: "OK";
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}> = Wrapper.addRoleToUser;
```

Defined in: [recipe/userroles/index.ts:106](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L106)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userId` | `string` |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `didUserAlreadyHaveRole`: `boolean`;
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

***

### createNewRoleOrAddPermissions()

```ts check=false reason="Generated API signature"
const createNewRoleOrAddPermissions: (role, permissions, userContext?) => Promise<{
  createdNewRole: boolean;
  status: "OK";
}> = Wrapper.createNewRoleOrAddPermissions;
```

Defined in: [recipe/userroles/index.ts:110](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L110)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `permissions` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `createdNewRole`: `boolean`;
  `status`: `"OK"`;
\}\>

***

### deleteRole()

```ts check=false reason="Generated API signature"
const deleteRole: (role, userContext?) => Promise<{
  didRoleExist: boolean;
  status: "OK";
}> = Wrapper.deleteRole;
```

Defined in: [recipe/userroles/index.ts:114](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L114)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `didRoleExist`: `boolean`;
  `status`: `"OK"`;
\}\>

***

### getAllRoles()

```ts check=false reason="Generated API signature"
const getAllRoles: (userContext?) => Promise<{
  roles: string[];
  status: "OK";
}> = Wrapper.getAllRoles;
```

Defined in: [recipe/userroles/index.ts:115](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L115)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `roles`: `string`[];
  `status`: `"OK"`;
\}\>

***

### getPermissionsForRole()

```ts check=false reason="Generated API signature"
const getPermissionsForRole: (role, userContext?) => Promise<
  | {
  permissions: string[];
  status: "OK";
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}> = Wrapper.getPermissionsForRole;
```

Defined in: [recipe/userroles/index.ts:111](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L111)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `permissions`: `string`[];
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

***

### getRolesForUser()

```ts check=false reason="Generated API signature"
const getRolesForUser: (tenantId, userId, userContext?) => Promise<{
  roles: string[];
  status: "OK";
}> = Wrapper.getRolesForUser;
```

Defined in: [recipe/userroles/index.ts:108](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L108)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userId` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `roles`: `string`[];
  `status`: `"OK"`;
\}\>

***

### getRolesThatHavePermission()

```ts check=false reason="Generated API signature"
const getRolesThatHavePermission: (permission, userContext?) => Promise<{
  roles: string[];
  status: "OK";
}> = Wrapper.getRolesThatHavePermission;
```

Defined in: [recipe/userroles/index.ts:113](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L113)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `permission` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `roles`: `string`[];
  `status`: `"OK"`;
\}\>

***

### getUsersThatHaveRole()

```ts check=false reason="Generated API signature"
const getUsersThatHaveRole: (tenantId, role, userContext?) => Promise<
  | {
  status: "OK";
  users: string[];
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}> = Wrapper.getUsersThatHaveRole;
```

Defined in: [recipe/userroles/index.ts:109](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L109)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `status`: `"OK"`;
  `users`: `string`[];
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

***

### init()

```ts check=false reason="Generated API signature"
const init: (config?) => RecipeListFunction = Wrapper.init;
```

Defined in: [recipe/userroles/index.ts:105](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L105)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `config?` | [`TypeInput`](recipe-userroles-types#typeinput) |

#### Returns

[`RecipeListFunction`](types#recipelistfunction)

***

### PermissionClaim

```ts check=false reason="Generated API signature"
const PermissionClaim: PermissionClaimClass;
```

Defined in: [recipe/userroles/permissionClaim.ts:41](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/permissionClaim.ts#L41)

***

### removePermissionsFromRole()

```ts check=false reason="Generated API signature"
const removePermissionsFromRole: (role, permissions, userContext?) => Promise<{
  status: "OK" | "UNKNOWN_ROLE_ERROR";
}> = Wrapper.removePermissionsFromRole;
```

Defined in: [recipe/userroles/index.ts:112](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L112)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `role` | `string` |
| `permissions` | `string`[] |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<\{
  `status`: `"OK"` \| `"UNKNOWN_ROLE_ERROR"`;
\}\>

***

### removeUserRole()

```ts check=false reason="Generated API signature"
const removeUserRole: (tenantId, userId, role, userContext?) => Promise<
  | {
  didUserHaveRole: boolean;
  status: "OK";
}
  | {
  status: "UNKNOWN_ROLE_ERROR";
}> = Wrapper.removeUserRole;
```

Defined in: [recipe/userroles/index.ts:107](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/index.ts#L107)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `tenantId` | `string` |
| `userId` | `string` |
| `role` | `string` |
| `userContext?` | `Record`\<`string`, `any`\> |

#### Returns

`Promise`\<
  \| \{
  `didUserHaveRole`: `boolean`;
  `status`: `"OK"`;
\}
  \| \{
  `status`: `"UNKNOWN_ROLE_ERROR"`;
\}\>

***

### UserRoleClaim

```ts check=false reason="Generated API signature"
const UserRoleClaim: UserRoleClaimClass;
```

Defined in: [recipe/userroles/userRoleClaim.ts:24](https://github.com/supertokens/supertokens-node/blob/8353a9a70d8b17dd9ff6ffe41201fa2ef0e60218/lib/ts/recipe/userroles/userRoleClaim.ts#L24)

## References

### RecipeInterface

Re-exports [RecipeInterface](recipe-userroles-types#recipeinterface)
