SDK
The TypeScript SDK client surface.
Last updated
The TypeScript SDK client surface.
@motif-ai/sdk is the server-side TypeScript client for Motif. One createClient() exposes every capability (users, profiling, strategies, questionnaires, partner portfolios, and Clarity), authenticated with a single API key.
npm install @motif-ai/sdkimport { createClient } from '@motif-ai/sdk'
const motif = createClient({
apiKey: process.env.MOTIF_API_KEY!,
// baseURL defaults to https://api.motifapp.ai/api
})The SDK is server-side only. The API key is an organization-wide secret. For browsers, use the iframe embed.
Organization-scoped namespaces authenticate with the API key alone:
motif.users
create, get, getByExternalId, list, update, delete
Manage end users
motif.questionnaires
create
Create questionnaire sessions
User-scoped operations go through motif.forUser(userId), which adds the x-user-id header:
forUser(id).profile
getQuestions, saveAnswer, getAnswers, getInvestorProfile, computeInvestorProfile, getCompletion
Every failure throws MotifSDKError with a message, statusCode, and response. See Error handling.
Quickstart: install and first call
Authentication: headers and environments
API reference: the underlying REST endpoints
Last updated