BEARER TOKEN
CUSTOMER DATA
Segment gives your agent customer data operations in each user's Segment workspace: manage sources, destinations, and warehouses, build Engage audiences and computed traits, maintain tracking plans, and check delivery and usage.
For more tools, view docs.
import { ScalekitClient } from "@scalekit-sdk/node";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
const sk = new ScalekitClient(env.SCALEKIT_ENV_URL, env.SCALEKIT_CLIENT_ID, env.SCALEKIT_CLIENT_SECRET);
// Segment tools scoped to this user
const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["segment"], toolNames: [
"segment_sources_list",
"segment_delivery_overview_failed_delivery_get",
"segment_destination_update"] },
pageSize: 100,
});
const agent = createReactAgent({ llm, tools });
await agent.invoke({ messages: [{ role: "user", content: "Find failed deliveries from the iOS source yesterday" }] });import OpenAI from "openai";
import { ScalekitClient } from "@scalekit-sdk/node";
const sk = new ScalekitClient(env.SCALEKIT_ENV_URL, env.SCALEKIT_CLIENT_ID, env.SCALEKIT_CLIENT_SECRET);
const openai = new OpenAI();
const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["segment"] }, pageSize: 100,
});
const res = await openai.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Find failed deliveries from the iOS source yesterday" }],
tools,
});
// Execute the tool call with the user's vaulted Segment access token
await sk.tools.executeTool(res.choices[0].message.tool_calls[0], "user_123");import Anthropic from "@anthropic-ai/sdk";
import { ScalekitClient } from "@scalekit-sdk/node";
const sk = new ScalekitClient(env.SCALEKIT_ENV_URL, env.SCALEKIT_CLIENT_ID, env.SCALEKIT_CLIENT_SECRET);
const anthropic = new Anthropic();
const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["segment"] }, pageSize: 100,
});
const msg = await anthropic.messages.create({
model: "claude-sonnet-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Find failed deliveries from the iOS source yesterday" }],
tools,
});
// Tool call runs with the user's vaulted Segment access token
await sk.tools.executeTool(msg.content, "user_123");import { Agent } from "@google/adk/agents";
import { ScalekitClient } from "@scalekit-sdk/node";
const sk = new ScalekitClient(env.SCALEKIT_ENV_URL, env.SCALEKIT_CLIENT_ID, env.SCALEKIT_CLIENT_SECRET);
const { tools } = await sk.tools.listScopedTools("user_123", {
filter: { connectionNames: ["segment"] }, pageSize: 100,
});
const agent = new Agent({
name: "data_ops_agent",
model: "gemini-2.5-pro",
instruction: "Segment tools scoped to this user",
tools,
});
await agent.run("Find failed deliveries from the iOS source yesterday");// shared token
audit → bot_service_account
// scalekit
audit → user_abc ✓