# CLI Reference





samplex login [#samplex-login]

Authenticate with your Sample.app account.

```bash
samplex login
```

Opens your default browser to sign in using OAuth 2.0 with PKCE. After authentication, tokens are stored locally at `~/.samplex/credentials.json`.

<Callout type="info">
  Tokens refresh automatically before each command. If a token expires or becomes invalid, run
  `samplex login` again.
</Callout>

***

samplex deploy [#samplex-deploy]

Deploy a static site to a preview URL.

```bash
samplex deploy [dir]
```

Arguments [#arguments]

<TypeTable
  type="{
  dir: {
    description: &#x22;Path to the build output directory.&#x22;,
    type: &#x22;string&#x22;,
    default: &#x22;Auto-detects dist, build, out, or .output/public&#x22;,
  },
}"
/>

Options [#options]

<TypeTable
  type="{
  &#x22;--slug&#x22;: {
    description: &#x22;Set the site slug used in the preview URL.&#x22;,
    type: &#x22;string&#x22;,
  },
  &#x22;--name&#x22;: {
    description: &#x22;Set a display name for the site.&#x22;,
    type: &#x22;string&#x22;,
  },
}"
/>

How it works [#how-it-works]

1. The CLI archives your build directory as a `.tar.gz` with a SHA-256 integrity hash
2. Uploads to the Sample.app API
3. Files are extracted and served on your preview URL

<Callout type="info">
  If a `.samplex.config.json` exists in the current directory, the CLI reuses the slug from it.
  Otherwise, a random name is generated (like `brave-panda`).
</Callout>

Examples [#examples]

```bash
# Deploy with auto-detected directory
samplex deploy

# Deploy a specific directory with a custom slug
samplex deploy ./dist --slug my-project --name "My Project"
```

Your site is available at:

```
https://<slug>.sample.app
```

***

samplex list [#samplex-list]

List your deployed sites.

```bash
samplex list
```

Outputs a table with each site's slug, URL, view count, bundle size, status, and creation date.

***

samplex delete [#samplex-delete]

Delete a deployed site permanently.

```bash
samplex delete <slug>
```

<Callout type="warn">
  This action is permanent. It removes the site files and frees your storage quota.
</Callout>

***

samplex init [#samplex-init]

Initialize or update project configuration.

```bash
samplex init [--slug <slug>] [--name <name>]
```

Creates or updates `.samplex.config.json` in the current directory. See [Project Config](/project-config) for details.

***

Organization Commands [#organization-commands]

Configure organization context [#configure-organization-context]

```bash
samplex init --org <organizationId>
```

Saves the organization ID to `.samplex.config.json` so subsequent commands target the organization automatically.

Deploy to an organization [#deploy-to-an-organization]

```bash
# Using config (after init --org)
samplex deploy ./dist

# Using flag
samplex deploy --org <organizationId> ./dist

# Using org API key (auto-detects org)
SAMPLEX_API_KEY=org_xxx samplex deploy ./dist
```

List organization sites [#list-organization-sites]

```bash
samplex list --org <organizationId>
```

Delete an organization site [#delete-an-organization-site]

```bash
samplex delete <slug> --org <organizationId>
```

<Callout type="info">
  See [Organization Sites](/organizations/organization-sites) for more details on deploying to
  organizations.
</Callout>

***

Global options [#global-options]

<TypeTable
  type="{
  &#x22;-v, --version&#x22;: {
    description: &#x22;Print the CLI version.&#x22;,
    type: &#x22;flag&#x22;,
  },
  &#x22;-h, --help&#x22;: {
    description: &#x22;Show help for any command.&#x22;,
    type: &#x22;flag&#x22;,
  },
}"
/>
