addRoles
Use this to add roles to a User API Key
Type signature of addRoles
async function addRoles(
userAPIKeyId: string,
roles: Array<string>
): Promise<
| {
error: "authorizationHeaderNotPresent";
success: false;
reason: string;
}
| {
error: "apiTokenNotPresent";
success: false;
reason: string;
}
| {
error: "invalidAPIToken";
success: false;
reason: string;
}
| {
error: "invalidBody";
success: false;
reason: string;
}
| {
error: "invalidId";
success: false;
reason: string;
}
| {
success: true;
count: number;
}
>;
Paramters
userAPIKeyId-idofUser API Keythat you got fromcreateUserAPIKeyIdroles- Anarrayof role names. Duplicated roles and roles which key already has will be ignored
Returns
type Returns = {
success: true;
count: number;
};
count represents number of roles added to User API Key
Errors
If roles are unable to add to User API Key successfully, then addRoles will return an error. Check the Type signature for possible errors that can happen