Skip to content

Setup Guide

This guide covers everything you need to go from zero to a working Imbrace SDK integration — installation, environments, credentials, and service URL overrides.


System Requirements

RequirementMinimum version
Node.js18.0.0+
npm8.0.0+
Python3.9+
pip23.0+

Installation

From npm registry:

Terminal window
npm install @imbrace/sdk
# or
yarn add @imbrace/sdk
# or
pnpm add @imbrace/sdk

Monorepo / local development:

Terminal window
# Step 1 — install dependencies and build
cd ts
npm install
npm run build
# Step 2 (optional) — link globally to use in another project on the same machine
npm link

Then in your external project:

Terminal window
npm link @imbrace/sdk

Verify:

import { ImbraceClient } from "@imbrace/sdk";
console.log("SDK loaded:", typeof ImbraceClient); // 'function'

Environments

NameGateway URLUse when
develophttps://app-gateway.dev.imbrace.coInternal development
sandboxhttps://app-gateway.sandbox.imbrace.coIntegration testing
stablehttps://app-gatewayv2.imbrace.coProduction (default)

Switch environments via the env constructor option, or override the URL directly with baseUrl:

const client = new ImbraceClient({ env: "sandbox" });

Configure Credentials

Create a .env file

The SDK does not auto-read environment variables — you pass credentials directly to the constructor. A .env file is a user convention for storing secrets; use dotenv or your framework’s env loader to read them.

# Credentials
IMBRACE_API_KEY=your_api_key_here
IMBRACE_ACCESS_TOKEN=your_jwt_token_here
# Organization ID — sent with every request
IMBRACE_ORGANIZATION_ID=your_org_id_here
# Optional: override the gateway URL directly
IMBRACE_GATEWAY_URL=https://app-gatewayv2.imbrace.co

Get an API Key

See Get an API Key for full instructions.


Initialize the Client

import { ImbraceClient } from "@imbrace/sdk";
// Server-side — API Key
const client = new ImbraceClient({
apiKey: process.env.IMBRACE_API_KEY,
organizationId: process.env.IMBRACE_ORGANIZATION_ID,
env: "stable",
});
// Client-side — Access Token (e.g. after a previous login, or a token you store yourself)
const client = new ImbraceClient({
accessToken: process.env.IMBRACE_ACCESS_TOKEN,
env: "stable",
});
// Password login (POST /v1/login/sign_in) — most common for end-user apps.
// Returns { token: "login_acc_...", organizations: [...] } in one call; pick one
// with selectOrganization() and the SDK swaps for an org-scoped acc_ token.
const anon = new ImbraceClient({ env: "stable" });
const { organizations } = await anon.login("user@example.com", "password");
await anon.selectOrganization(organizations[0].id);
// OTP login flow (alternative — for email-OTP UX instead of password)
await anon.requestOtp("user@example.com");
await anon.loginWithOtp("user@example.com", "123456");
// Token is stored automatically on the client

CLI Installation

Terminal window
# Install globally
npm install -g @imbrace/cli
# Login to get started
imbrace login --api-key api_xxx...

See CLI Installation for alternative install methods and CLI Commands for the full command reference.


Override Service URLs

Use this when a microservice runs at a different address (e.g. local dev, dedicated staging).

const client = new ImbraceClient({
env: "develop",
services: {
aiAgent: "http://localhost:4000/ai-agent",
dataBoard: "http://localhost:3001/data-board",
channelService: "http://localhost:3002/channel-service",
},
});

All valid service keys:

Python keyTypeScript keyService
gatewaygatewayApp Gateway
platformplatformPlatform service
channel_servicechannelServiceChannel service
data_boarddataBoardData Board
backendbackendLegacy monolith (/v1/backend) — used for auth sign-in, templates, and a handful of routes not yet split out
ipsipsIPS service
aiaiAI service
marketplacesmarketplacesMarketplace service
file_servicefileServiceFile service
message_suggestionmessageSuggestionMessage Suggestion service
predictpredictPredict service
workflow_engineworkflowEngineWorkflows
ai_agentaiAgentAI Agent service

Troubleshooting

Cannot find package '@imbrace/sdk'

Package is not linked. Re-run from ts:

Terminal window
npm link
cd /path/to/your-project && npm link @imbrace/sdk
ERR_MODULE_NOT_FOUND for files in dist/

Package has not been built yet:

Terminal window
cd ts && npm run build
ModuleNotFoundError: No module named 'imbrace'
Terminal window
cd py && pip install -e ".[dev]"
401 Unauthorized

API Key expired or invalid. Generate a new one from the Imbrace Dashboard or see the API Key guide.

UserWarning: ImbraceClient: no credentials provided

No api_key or access_token passed. If intentional (e.g. login-only flow), ignore this warning. Otherwise check your .env file.