TypeScript SDK
Call the wtree Cloud API from TypeScript with typed functions generated from the OpenAPI spec.
Use @wtree/cloud-sdk to call any wtree Cloud endpoint from TypeScript with typed inputs and responses. The CLI and the MCP server are built on it.
Before you start
An API key from Profile (avatar menu) › API/CLI Keys.
Set up
Install the package.
npm install @wtree/cloud-sdk
# or
bun add @wtree/cloud-sdkConfigure the shared client once. The base URL is your wtree Cloud URL followed by /api.
import { client } from "@wtree/cloud-sdk";
client.setConfig({
baseUrl: "https://panel.example.com/api",
headers: {
"x-api-key": process.env.W3PANEL_API_KEY,
},
});Call endpoints
Each endpoint is a function named after its route: project.create becomes projectCreate, application.one becomes applicationOne. Functions return { data, error, response }; pass throwOnError: true to throw on failure instead. Types are exported too, such as ApplicationOneData and ApplicationOneResponse.
Mutations take input in body, queries in query.
import { projectCreate, applicationOne } from "@wtree/cloud-sdk";
const created = await projectCreate({
body: { name: "my-project", description: "My awesome project" },
});
const { data, error } = await applicationOne({
query: { applicationId: "app-id" },
});
console.log(data?.name);Several instances
client is a shared default. For more than one instance, create a client per instance and pass it to each call.
import { createClient, createConfig, projectAll } from "@wtree/cloud-sdk";
const staging = createClient(
createConfig({
baseUrl: "https://staging.example.com/api",
headers: { "x-api-key": process.env.STAGING_API_KEY },
}),
);
const { data } = await projectAll({ client: staging });Versioning
The SDK is regenerated from the OpenAPI spec of each wtree Cloud release. Use the SDK version that matches your wtree Cloud version so functions line up with your instance's endpoints.
Next steps
- API reference lists every endpoint with its parameters.
