Skip to Content
Getting StartedClient setup

Client setup

Create a client once and reuse it for apps, deployments, domains, and SSH resources. Use a workspace API token in STACKMACHINE_API_TOKEN and pass it explicitly; the SDK does not read environment variables automatically. See Tokens for token scope and management.

client.js
1
import StackMachine from "stackmachine";
2
 
3
const token = process.env.STACKMACHINE_API_TOKEN;
4
if (!token) throw new Error("STACKMACHINE_API_TOKEN is required");
5
 
6
const client = new StackMachine(token, { apiUrl: "https://api.stackmachine.dev/graphql" });

Source: stackmachine/sdks  examples.