Skip to main content

Account Functions

To create functionality that manages you personal and team Epicenter accounts, leverage the Account adapter.

Importing the adapter

To use the functions of the Account adapter, import it as shown:
import { accountAdapter } from 'epicenter-libs';

The accountAdapter namespace exports functions that make calls to the Account API.

learn more

For descriptions of the objects used by the account adapter functions, read Account entities.


Create an account

Create a personal or team account.

Function signature
export async function createAccount(
view: PersonalAccountCreateView | TeamAccountCreateView
): Promise<AccountReadView>

The function sends a POST request to the {accountShortName}/{projectShortName}/account endpoint setting the path parameters {accountShortName}='epicenter' and {projectShortName}='manager'.

The view parameter is serialized as the body of the API request.

Permissions

Requires a SYSTEM role.

Parameters

view (Union Type: PersonalAccountCreateView | TeamAccountCreateView): An object containing the account creation details. It can be either of the following types:

Return value

A promise that resolves to an object of type AccountReadView. This object contains the details of the created account.


Get an account

Retrieve the details of an account by accountShortName.

Function signature
export async function getAccount(accountShortName: string): Promise<AccountReadView>

The function sends a GET request to the /account endpoint.

Permissions

Requires a role of SUPPORT or higher.

Parameters

accountShortName (Type: string): Serves as the unique identifier of the account.

Return value

A promise that resolves to an object of type AccountReadView. This object contains the account's details retrieved from the server.


List team accounts

Retrieve a filtered list of team accounts which a specific admin has permission to access.

Function signature
export async function teamForAdmin(
adminKey: string,
optionals: {
includeAllMembers?: boolean,
filter?: string,
first?: number,
max?: number,
} & RoutingOptions = {},
): Promise<AccountReadView[]>

Permissions

Requires a SYSTEM role.

Parameters

  • adminKey (type: string): A GUID that identifies the admin.
  • optionals (optional, type: object): Filter, pagination, and routing options.
    • includeAllMembers (boolean): If True, includes all members of the team in the response.
    • filter (string): A filter string to narrow down the results.
    • first (number): Specifies the starting index for pagination.
    • max (number): Defines the maximum number of results to return.
    • RoutingOptions (object): An optional parameter providing additional routing options. Defaults to an empty object.

Return value

A promise that resolves to an array of AccountReadView objects, each representing a team account.


Update an account

Update account details.

Function signature
export async function updateAccount(
view: PersonalAccountUpdateView | TeamAccountUpdateView,
optionals: RoutingOptions = {},
): Promise<AccountReadView>

The function sends a PATCH request to the /account endpoint.

Permissions

Requires a role of AUTHOR or higher.

Parameters

Return value

A promise that resolves to an object of type AccountReadView, containing the updated account details.


Remove an account

Delete an account and all account details.

Function signature
export async function removeAccount(accountShortName: string): Promise<void>

The function sends a DELETE request to the /account endpoint.

Permissions

Requires a role of OWNER or higher.

Parameters

accountShortName (Type: string): Serves as the unique identifier of the account.

Return value

A promise that resolves to void.