Most methods in the Trust Stack require scoping to an organization. Learn more about organizations here.

At a high level, a organization is a collection of users or resources you manage within your own application. As an example, if you are a farm management system, you would likely have a organization for each farm you manage.

Scoping to an Organization

There are a few ways to scope to an organization.

Globally

To scope to an organization, you can pass the organizationId to the constructor of the SDK.

import { TrustStack } from '@truststack/core';

TrustStack.configure({ 
    accessToken: '<access_token>', 
    organizationId: '<organization_id>' 
});

This will globally scope all requests to the organization.

Per Request

To scope to an organization for a single request, you can pass the organizationId to the method.

import { CanvasClient } from '@truststack/canvas';

const client = new CanvasClient();

const organization = await truststack.createCanvasTemplate(
    { ... },
    { organizationId: '<organization_id>' }
);

Most methods will accept a second set of options where you can scope to an organization.