Novant

Documentation

Sign in

Organization

An organization key can access every project in your organization, so an integration can work across your portfolio with a single NovantClient.

Project and Organization Keys

NovantClient accepts either key type:

Key Type Prefix Access
Project ak_ A single project
Organization ak_org_ Every project in the organization

A project key is bound to its project, so calls do not need to identify one. An organization key must name the project for every call to a project method using proj_id. For more on key types, see Authentication.

Targeting a Project

Every project method accepts an optional proj_id option. Pass it per call to work with a different project on each call:

const client = new NovantClient({ apiKey: "ak_org_xxx" });

const zones  = await client.zones({ proj_id: 4821 });
const values = await client.values({ source_id: "s.2", proj_id: 5307 });

Or set a default projId on the client. A proj_id passed to a method overrides the default for that call:

const client = new NovantClient({ apiKey: "ak_org_xxx", projId: 4821 });

const zones = await client.zones();                    // project 4821
const annex = await client.zones({ proj_id: 5307 });   // project 5307

Every result returned by a project method includes the proj_id of the project it came from:

console.log(zones.proj_id);   // 4821

Calling a project method with an organization key and no proj_id throws a NovantError with status 400. See Error Handling.

Projects

Returns the projects in the organization. Requires an organization key; calls made with a project key throw a NovantError with status 403.

orgProjects()

Returns

OrgProjectList with the following field:

Field Type Description
projects OrgProject[] Projects in the organization

Each OrgProject has:

Field Type Description
proj_id number Project ID
proj_name string Project name
city string Project city
tz string Project timezone
area number Project area; omitted if not set
access string Key access level: read, edit, or control

Example

const client = new NovantClient({ apiKey: "ak_org_xxx" });

// List every project in the organization
const { projects } = await client.orgProjects();
for (const p of projects) {
  console.log(p.proj_id, p.proj_name, p.city);
}

// Lookup by ID
const proj = projects.find((p) => p.proj_id === 4821);
console.log(proj.proj_name);   // "Lumon Industries"

// Read zones across every project
for (const p of projects) {
  const { zones } = await client.zones({ proj_id: p.proj_id });
  console.log(p.proj_name, zones.length);
}