Skip to navigation

Connect a program

Call the Gateway from your own system, with an SDK or with plain HTTP.
View as Markdown

A program is a system of your organization that uses Basement from code: an integration, a script, a back-end service. It uses the same tools as an agent, with a key of its own, so the activity log shows the system by its name.

1

Create a key for the program

In Basement, open Agents and click Connect agent. Select Program, give the system a name (for example “Billing system”), and select its access level.

Basement shows the key one time. Copy it now, and keep it in a secret store or an environment variable. Do not put it in your source code.

2

Install the SDK

npm install @basementai/gateway
3

Make the first call

import { BasementGatewayClient } from "@basementai/gateway";
const basement = new BasementGatewayClient({
apiKey: process.env.BASEMENT_API_KEY,
});
const me = await basement.whoami();
console.log(me.orgName);
const { docs } = await basement.docs.list();
const doc = await basement.docs.read({ docId: docs[0].id });
console.log(doc.title, doc.bodyMarkdown);

Both SDKs read the key from the BASEMENT_API_KEY environment variable when you do not give one.

What happens next

  • The program can call only what its access level allows. A call outside it answers 403. See Errors and limits.
  • Each call is in Agents, Activity, marked as a program, with the SDK and its version. See Activity log.
  • The full list of operations is in the API Reference.