sitemap.xml llms.txt
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.

Permissions​

Requires a SYSTEM role.

Function description​

The createAccount() function:

  • Constructs a POST request to to the {ACCOUNT_SHORT_NAME}/{PROJECT_SHORT_NAME}/account endpoint setting the path parameters {ACCOUNT_SHORT_NAME}='epicenter' and {PROJECT_SHORT_NAME}='manager'.
  • Returns an AccountReadOutView representing the newly created personal or team account.
Function signature
export async function createAccount(
view: PersonalAccountCreateInView | TeamAccountCreateInView,
): Promise<AccountReadOutView>

Parameters​

view (Union Type: PersonalAccountCreateInView or TeamAccountCreateInView): An object containing the account creation details. It can be either of the following types:

  • PersonalAccountCreateInView: Represents the details required for creating a personal account.
  • TeamAccountCreateInView: Represents the details required for creating a team account.

Return value​

A promise that resolves to an AccountReadOutView.

Usage example​

import { accountAdapter } from 'epicenter-libs';

// Create a personal account
const personalAccount = await accountAdapter.createAccount({
objectType: 'personal',
adminKey: 'admin-key',
name: 'John Doe',
shortName: 'johndoe',
});

// Create a team account with billing
const teamAccount = await accountAdapter.createAccount({
objectType: 'team',
adminKey: 'admin-key',
name: 'Acme Corp',
shortName: 'acme',
billingInformation: {
billingInterval: 'monthly',
subscriptionPlan: 'standard',
},
});

Get an account​

Retrieve the details of an account by accountShortName.

Permissions​

Requires a role of SUPPORT or higher.

Function description​

The getAccount() function:

  • Constructs a GET request to /account using the provided account short name.
  • Returns an AccountReadOutView, which may represent either a personal or team account depending on the account type.
Function signature
export async function getAccount(accountShortName: string): Promise<AccountReadOutView>

Parameters​

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

Return value​

A promise that resolves to an AccountReadOutView.

Usage example​

import { accountAdapter } from 'epicenter-libs';
const account = await accountAdapter.getAccount('acme');

List team accounts​

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

Permissions​

Requires a SYSTEM role.

Function description​

The teamForAdmin() function:

  • Constructs a GET request to {ACCOUNT_SHORT_NAME}/{PROJECT_SHORT_NAME}/account/team/for/{ADMIN_KEY} setting the path parameters {ACCOUNT_SHORT_NAME}='epicenter' and {PROJECT_SHORT_NAME}='manager'.
  • Accepts optional filters such as member inclusion, result filtering, and pagination.
  • Returns an array of AccountReadOutView objects representing the team accounts administered by the specified admin.
Function signature
export async function teamForAdmin(
adminKey: string,
optionals: {
includeAllMembers?: boolean;
filter?: string;
first?: number;
max?: number;
} & RoutingOptions = {},
): Promise<AccountReadOutView[]>

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 AccountReadOutView, each representing a team account.


Update an account​

Update account details.

Permissions​

Requires a role of AUTHOR or higher.

Function description​

The updateAccount() function:

  • Constructs a PATCH request to the /account endpoint.
  • Sends either a PersonalAccountUpdateInView or TeamAccountUpdateInView object in the request body.
  • Accepts optional routing overrides through a RoutingOptions object.
  • Returns an AccountReadOutView representing the updated account.
Function signature
export async function updateAccount(
view: PersonalAccountUpdateInView | TeamAccountUpdateInView,
optionals: RoutingOptions = {},
): Promise<AccountReadOutView> {
return await new Router()
.patch('/account', {
body: view,
...optionals,
}).then(({ body }) => body);
}

Parameters​

Return value​

A promise that resolves to an AccountReadOutView representing the updated account.


Remove an account​

Delete an account and all account details.

Permissions​

Requires a role of OWNER or higher.

Function description​

The removeAccount() function:

  • Constructs a DELETE request to /account using the provided account short name.
  • Returns a promise that resolves to void when the deletion is complete.
Function signature
export async function removeAccount(
accountShortName: string,
): Promise<void> {
return await new Router()
.withAccountShortName(accountShortName)
.delete('/account')
.then(({ body }) => body);
}

Parameters​

accountShortName (Type: string): Account short name.

Return value​

A promise that resolves to void.

Usage example​

import { accountAdapter } from 'epicenter-libs';
await accountAdapter.removeAccount('acme');