createUserAPIKey
It creates a User API Key which can be give to users of your api. That key must be sent along while making requests to your api.
Type signature of createUserAPIKey
async function createUserAPIKey(
prefix: string,
roles?: Array<string>
): Promise<
| {
success: true;
apiKey: string;
id: string;
roles: string[];
}
| {
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;
}
>;
Parameters
prefix- is the prefix of the generatedUser API Key. For example if the prefix isuserthen the generatedUser API Keywill beuser_xxx....roles(optional) - Anarrayof roles. Example[ROLE_1, ROLE_2]
Returns
If User API Key is generated successfully. Then the createUserAPIKey returns
type Returns = {
success: true;
apiKey: string;
id: string;
roles: string[];
};
Errors
If User API Key is unable to generate successfully, then createuserAPIKey will return an error. Check the Type signature for possible errors that can happen