> ## Documentation Index
> Fetch the complete documentation index at: https://docs.truststack.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started

> How to install the Trust Stack SDK, get access to the API, and start building with Trust Stack.

# Installation

To get started, install the Trust Stack SDK.

<CodeGroup>
  ```bash npm theme={null}
  npm install @truststack/sdk
  ```

  ```bash yarn theme={null}
  yarn add @truststack/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @truststack/sdk
  ```
</CodeGroup>

## Modules

The Trust Stack SDK is also available as a set of NPM packages to keep your codebase clean and focused. Read more about [modules](/client-sdk/modules) to learn more.

Each core functionality is either available per the `TrustStack` client in `@truststack/sdk` or as a module in the `@truststack/<MODULE>` package.

```typescript theme={null}
import {TrustStack} from "@truststack/sdk";

const truststack = new TrustStack();
const organizations = await truststack.admin.createOrganization({
  name: "ACME Farms",
});
```

Or, alternatively, via only installing the `@truststack/admin`:

```typescript theme={null}
import {AdminClient} from "@truststack/admin";

const client = new AdminClient();
const organizations = await client.createOrganization({name: "ACME Farms"});
```

## Access Token Configuration

You can configure the SDK globally and set your access token.

```typescript theme={null}
import {TrustStack} from "@truststack/sdk";

const truststack = TrustStack.configure({accessToken: "<access_token>"});
```

Subsequent module usage will use the access token you have configured. Below is an example of how to use the Canvas module.

```typescript theme={null}
import {CanvasClient} from "@truststack/canvas";

// Access token is automatically used from above
const client = new CanvasClient();
await client.createCanvasTemplate({name: "My Canvas"});
```

You can also configure globally with each module as well. The following examples all have the same effect.

```typescript theme={null}
import {CanvasClient} from "@truststack/canvas";
import {AdminClient} from "@truststack/admin";
import {TrustStackClient} from "@truststack/core";

CanvasClient.configure({accessToken: "<access_token>"});
// or
AdminClient.configure({accessToken: "<access_token>"});
// or
TrustStackClient.configure({accessToken: "<access_token>"});
```

### Environment Variables

You can also set the access token via environment variables.

```bash theme={null}
TRUSTSTACK_ACCESS_TOKEN=<access_token>
```

## Organization Configuration

It is recommended you read about [Organizations](/documentation/organizations) before continuing.

Most actions within the Trust Stack require the concept of a "Organization". The [Organizations](/documentation/organizations) section has more information
but setting the organization is important to ensure your requests are made in the correct context.

It enforces permissions and authorization for the actions you perform on hehalf of your user groups.

There are a few ways to set the organization.

You can set the organization globally:

### Globally Set Organization

```typescript theme={null}
import {TrustStack} from "@truststack/core";

const truststack = TrustStack.configure({
  organization: "<organization_id>",
  accessToken: "<access_token>",
});
```

### Per client set organization

You can also set the organization on a per client basis.

```typescript theme={null}
import {CanvasClient} from "@truststack/canvas";

const client = new CanvasClient({organization: "<organization_id>"});
```

### Per request set organization

You can also set the organization on a per request basis. Most module functions accept a second set of parameters to do this.

```typescript theme={null}
import {CanvasClient} from "@truststack/canvas";

const client = new CanvasClient();
await client.createCanvasTemplate(
  {name: "My Canvas"},
  {organization: "<organization_id>"}
);
```

## No organization?

If you don't set an organization, the SDK will default your tenant as the organization. If you are require DIDs, Credentials, or other resources, you will need to set the organization.
managed against your tenant, this is the default behavior.
