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:
| Variable | Description |
|---|---|
FORTE_PROJECT_ID | The project this service belongs to |
FORTE_SERVICE_ID | This service's ID |
FORTE_API_TOKEN | A 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.
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:
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:
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:
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' }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:
const forte = new ForteClient({
apiToken: "your-api-token",
});Or set the environment variable:
export FORTE_API_TOKEN="your-api-token"The TypeScript SDK works in browser environments too — pass apiToken directly since environment variables are not available in the browser.
Next Steps
- Learn how Service Tokens are injected into your services
- Understand Users and how authentication works
- Set up Authentication for your project's users