---
title: "Client setup"
description: "Initialize the StackMachine client in JavaScript or Python."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.stackmachine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/getting-started/tokens) for token scope and management.


```javascript
import StackMachine from "stackmachine";

const token = process.env.STACKMACHINE_API_TOKEN;
if (!token) throw new Error("STACKMACHINE_API_TOKEN is required");

const client = new StackMachine(token);
```

```python
import os
from stackmachine import StackMachine

token = os.environ["STACKMACHINE_API_TOKEN"]
client = StackMachine(token)
```

> Source: [stackmachine/sdks](https://github.com/stackmachine/sdks/tree/main) examples.

Source: https://docs.stackmachine.com/getting-started/client/index.mdx
