The admin module is used to manage organizations and in the future, other administrative resources for your tenant.

Installation

With @truststack/sdk installed and configured, or alternatively, just the @truststack/admin package.

npm install @truststack/sdk
# or
npm install @truststack/admin

Managing Organizations

Using the Admin module, you can manage organizations. An organization is just a logic grouping of users that likely exists on your platform.

Read more about organizations to learn more.

Create an Organization

To create an organization, you can use the Admin module.

import { AdminClient } from '@truststack/admin';

const client = new AdminClient();
const organization = await client.createOrganization({ name: 'ACME Farms' });

console.log(organization);

Response
{
  "id": "'ACME-FARMS-ID",
  "name": "ACME Farms",
  "createdAt": "2024-03-20T10:30:00Z",
  "updatedAt": "2024-03-20T10:30:00Z"
}

Update an Organization

To update an organization, you can use the updateOrganization method.

const organization = await client.updateOrganization({
  id: "ACME-FARMS-ID",
  name: "Clean and Green ACME Farms",
});

console.log(organization);
Response
{
  "id": "ACME-FARMS-ID",
  "name": "Clean and Green ACME Farms",
  "createdAt": "2024-03-20T10:30:00Z",
  "updatedAt": "2024-03-20T10:30:00Z"
}

Delete an Organization

To delete an organization, you can use the deleteOrganization method.

await client.deleteOrganization("ACME-FARMS-ID");

Get an Organization

To get an organization, you can use the getOrganization method.

const organization = await client.getOrganization("ACME-FARMS-ID");
console.log(organization);