TypeScript SDK
Use the repository SDK for typed reads, confirmed writes and local media uploads.
@influence/app-sdk is currently a private repository package, not a published npm installation. These examples apply to projects with that workspace package available. For an independent client, use the HTTP API.
Provide the trusted origin explicitly and load the key from your process’s secret environment:
import { InfluenceClient } from "@influence/app-sdk/client";
const accessToken = process.env.PUBLISH_API_TOKEN;
if (!accessToken) throw new Error("PUBLISH_API_TOKEN");
const client = new InfluenceClient({
baseUrl: "https://influence.so",
accessToken,
});
const catalog = await client.listTools();
const accounts = await client.callTool("accountList", {});
console.log(catalog.tools, accounts.output);
Use listTools() for discovery and callTool(name, input) for read-only tools. Writes use prepareTool(name, input) followed by confirmTool(name, input, confirmationCapability, { idempotencyKey }). Keep the same input, capability and key after an uncertain response. The SDK validates requests and responses and throws InfluenceSdkError for HTTP failures and tool failures.
uploadMedia(file, { clientKey, name, contentType, sizeBytes }) accepts a Blob and handles the confirmed multipart transfer. Retry the same file with the same clientKey. Read mediaUploadGet until the final asset is ready; a processing upload is not ready to publish. Respect the separate publishing review and retry rules.