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

# Authentication

> Set up Workspace token or environment variable authentication for the ChatbotX CLI.

Connect the ChatbotX CLI to your self-hosted instance using a Workspace token (API Key) and API URL.

## Configuration Command (Recommended)

Save your credentials locally in the CLI configuration file:

```bash theme={null}
chatbotx config set --apiKey "YOUR_WORKSPACE_TOKEN" --apiUrl "https://app.chatbotx.io/api"
```

* `--apiKey`: Your Workspace token (found under **Settings → Developer → API Keys** or **Settings → Integrations → Workspace token**).
* `--apiUrl`: The API URL of your ChatbotX instance.

## Environment Variables

Use environment variables when you do not want secrets stored in shell history or shared scripts. The CLI will automatically detect them:

```bash theme={null}
export CHATBOTX_API_KEY="YOUR_WORKSPACE_TOKEN"
export CHATBOTX_API_URL="https://app.chatbotx.io/api"
```

## Custom API URL (Self-Hosted)

If you are self-hosting ChatbotX, point the CLI configuration or environment variables to your custom domain API endpoint:

```bash theme={null}
chatbotx config set --apiKey "YOUR_WORKSPACE_TOKEN" --apiUrl "https://app.yourdomain.com/api"
```

Or via environment variables:

```bash theme={null}
export CHATBOTX_API_URL="https://app.yourdomain.com/api"
```

## Override Configuration per Command

You can override the configured Workspace token and API URL for a single command by passing them as options:

```bash theme={null}
chatbotx --apiKey "YOUR_WORKSPACE_TOKEN" --apiUrl "https://app.chatbotx.io/api" workspaces get
```

If you are running a self-hosted instance:

```bash theme={null}
chatbotx --apiKey "YOUR_WORKSPACE_TOKEN" --apiUrl "https://app.yourdomain.com/api" workspaces get
```

## Self-Signed Certificates

If your self-hosted instance uses a self-signed certificate, configure the CLI to allow secure connections.

Using the CLI configuration:

```bash theme={null}
chatbotx config set --allowSelfSignedCert true
```

Or using an environment variable:

```bash theme={null}
export CHATBOTX_ALLOW_SELF_SIGNED_CERT=true
```

<Warning>
  Do not commit real Workspace tokens to git repositories. Use environment variables or a secret manager for automation scripts and CI/CD workflows.
</Warning>
