ruLog in to Senler

API SDK

What it is

@senlerio/api is a typed client for the public Senler AI API. It is generated from the OpenAPI specification and provides the AiSenlerClient class, response models, and separate method groups such as client.projects, client.agents, and client.apps.

The SDK is intended primarily for server-side integrations. It also runs in an environment with global fetch, but an arbitrary external website cannot call the production API unless its origin is allowed by the CORS policy. Never put a project API key or Client Secret in browser code.

Installation

Install the current published version from GitHub using a pinned tag:

npm install github:SenlerBot/Senler-io-sdk#v0.8.0

The package requires Node.js 18+ and includes TypeScript declarations. The pinned tag prevents a newly generated SDK contract from being pulled during the next dependency installation.

Authorization

Pass only the token value to accessToken, without the Bearer prefix. The SDK adds the Authorization: Bearer <token> header to every request.

Two token sources are supported:

  • a project API key in the senler_sk_... format for an integration with one project;
  • an application OAuth access token for access granted by a user through OAuth.

Available methods depend on the token scope and permissions. A user OAuth token is additionally restricted by the user's current permissions in the target project or developer application.

First request

Example for a project API key or project-scoped OAuth token:

import { AiSenlerClient } from "@senlerio/api";

const client = new AiSenlerClient({
  accessToken: process.env.SENLER_API_TOKEN!,
});

const currentProject = await client.projects.getMe();

const agents = await client.agents.agentsList({
  projectId: currentProject.project.id,
  limit: 20,
});

An external integration does not need X-Session-Id: that header belongs to a cabinet session and is not part of the generated SDK method parameters.

Methods and types

A client group corresponds to an API section, and a method corresponds to an operation in the public OpenAPI specification. For example:

  • client.projects covers projects;
  • client.agents covers agents;
  • client.dialogsMessaging covers dialog messages;
  • client.apps covers developer applications;
  • client.appDocumentation covers developer application documentation.

These are examples, not a complete catalog. Current groups and signatures are available through TypeScript completion for the installed SDK version. Endpoint behavior, required parameters, and permissions are documented in the API reference.

Method parameters are passed as one camelCase object. The SDK converts property names to the API JSON format and converts responses into typed models. For example, idempotencyKey is sent as idempotency_key. If a required parameter is missing, TypeScript reports it during compilation and the runtime check throws RequiredError.

Use client.leadVariables.leadVariablesGetValues2 to read lead-variable values. Lead search uses cursor pagination: omit cursor for the first page.

When sending or editing a message, choose its text format: plain text or Markdown. Formatting is adapted to the recipient's channel.

Developer application settings are updated through separate methods: client.apps.updateGeneralSettings for the name, description, and website, client.apps.updateToolsSettings for agent tools, and client.apps.updateEmbeddedPageSettings for the embedded page. Each method accepts only the fields from its section, so changing one form does not overwrite adjacent settings.

For available model objects in the SDK, supportedServerBindingModes lists the MCP modes compatible with the model and its active provider connections. In the raw API JSON response, this field is named supported_server_binding_modes. Use the installed SDK's field when selecting an agent model instead of hard-coding compatibility in an integration.

Client configuration

The constructor supports these parameters:

  • accessToken is the required API key or OAuth access token;
  • baseUrl is the API address and defaults to https://api.senler.io; an override is normally useful only for development and tests;
  • fetchApi supplies a custom fetch implementation when required by a runtime or test.

For a long-lived integration, configure OAuth token refresh and error handling.

Application action decorators and CLI are described in SDK for NestJS.

Reference materials