Overview
The TypeScript client: install, construct, open a session.
1 min read
SDK Reference
@codespar/sdkv0.10.11Full TypeScript reference for @codespar/sdk. See the migration guide when upgrading across a major.
npm install @codespar/sdkCodeSpar class
The entry point. Creates sessions for users.
import { } from "@codespar/sdk";
const codespar = new ({ : "csk_live_...", // or set CODESPAR_API_KEY env var
: "https://api.codespar.dev", // optional, default
});constructor(config?: CodeSparConfig)
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | CODESPAR_API_KEY env | API key from dashboard |
baseUrl | string | No | https://api.codespar.dev | API base URL |
Throws if no API key is provided (neither in config nor env).
create(userId, config?): Promise<Session>
Creates a new session for a user.
const session = await codespar.create("user_123", {
servers: ["stripe", "correios"],
preset: "brazilian",
});| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Unique user identifier |
config | SessionConfig | No | Session configuration |
SessionConfig
interface SessionConfig {
servers?: string[];
preset?: "brazilian" | "mexican" | "argentinian" | "colombian" | "all";
manageConnections?: {
waitForConnections?: boolean;
timeout?: number; // ms, default 30000
};
metadata?: Record<string, string>;
}| Field | Type | Description |
|---|---|---|
servers | string[] | Server IDs to connect (e.g., ["stripe", "asaas"]) |
preset | string | Country preset — connects all servers for that country |
manageConnections | object | Block until servers are connected |
metadata | Record | Key-value metadata attached to every tool call |