Log in

SDKs

Forte provides runtime SDKs for TypeScript, Java, and Python. These SDKs give your services a simple interface to interact with the Forte API — managing users, reading project data, and more — without dealing with authentication manually.

Installation

See the SDK repository for installation instructions for TypeScript, Java, and Python.

Automatic Credential Loading

When your code runs inside a Forte service, the SDK automatically reads credentials from the environment variables that Forte injects at runtime:

VariableDescription
FORTE_PROJECT_IDThe project this service belongs to
FORTE_SERVICE_IDThis service's ID
FORTE_API_TOKENA Bearer token scoped to this project

FORTE_API_TOKEN is scoped to the service's project and injected automatically — just import the SDK and start using it.

typescript
import { ForteClient } from "@forteplatforms/sdk";
 
// Credentials are loaded automatically from the environment
const forte = new ForteClient();

Common Use Cases

Retrieve the authenticated user

Every request to your service includes a Forte-User-Id header with the authenticated user's ID. Use the SDK to fetch the full user profile:

typescript
import { ForteClient } from "@forteplatforms/sdk";
 
const forte = new ForteClient();
 
app.get("/profile", async (req, res) => {
  const userId = req.headers["forte-user-id"];
  const user = await forte.users.get(userId);
 
  res.json({
    name: user.displayName,
    email: user.contactMethods.find((c) => c.type === "EMAIL")?.value,
  });
});

List users in the project

Query all users in your project with pagination:

typescript
const { users, nextPageToken } = await forte.users.list({
  limit: 50,
});

Store custom attributes on a user

Attach arbitrary key-value metadata to users — useful for subscription tiers, feature flags, or app-specific preferences:

typescript
const userId = req.headers["forte-user-id"];
 
await forte.projects.putUserCustomAttributes(userId, {
  plan: "pro",
  referral_source: "google",
  onboarding_completed: "true",
});
 
// Read them back
const user = await forte.users.get(userId);
console.log(user.customMetadataAttributes);
// { plan: 'pro', referral_source: 'google', onboarding_completed: 'true' }
Replacement semantics

Each call replaces all custom attributes on the user. To update a single field, read the user first, merge, then write back. Keys must be 1–64 characters (letters, numbers, underscores, hyphens). Values are strings.

Using Outside Forte

For local development or running outside of Forte, pass credentials directly to the SDK constructor:

typescript
const forte = new ForteClient({
  apiToken: "your-api-token",
});

Or set the environment variable:

bash
export FORTE_API_TOKEN="your-api-token"
Browser / React

The TypeScript SDK works in browser environments too — pass apiToken directly since environment variables are not available in the browser.

Next Steps

Search

Search documentation and console pages