# vgrid login & publish

## login

Authenticate with VisiHub. Required before `publish` and other hub commands.

```bash
vgrid login [options]
```

| Option | Description |
|--------|-------------|
| `--token` | API token for non-interactive auth (also reads `VISIHUB_API_KEY` env var) |
| `--api-base` | API base URL (default: `https://api.visihub.app`) |

```bash
# Interactive login
vgrid login

# Non-interactive (CI)
vgrid login --token vht_abc123

# From environment variable
VISIHUB_API_KEY=vht_abc123 vgrid login
```

---

## publish

Publish a file to VisiHub and verify its integrity. Uploads the file as a new dataset revision. VisiHub runs an integrity check (row count, column names, schema structure, content hash) and computes a structural diff against the previous version.

```bash
vgrid publish <file> --repo <owner/slug> [options]
```

| Option | Description |
|--------|-------------|
| `--repo` | VisiHub repository in `owner/slug` format (required) |
| `--dataset` | Dataset name in VisiHub (defaults to file basename) |
| `--source-type` | Source system type (e.g., `dbt`, `qbo`, `snowflake`, `manual`) |
| `--source-identity` | Source identity (e.g., warehouse table, realm ID) |
| `--query-hash` | Source query hash (for warehouse extracts) |
| `--no-wait` | Don't wait for import to complete. By default `--wait` is true: the CLI polls until the server finishes processing |
| `--no-fail` | Don't fail on integrity check failure. By default `--fail-on-check-failure` is true |
| `--output` | Output format: `json` or `text` (auto-detected: JSON when piped, text when TTY) |
| `--assert-sum` | Assert sum of a numeric column (repeatable). Format: `column:expected[:tolerance]` |
| `--assert-cell` | Assert a computed cell value in a .sheet file (repeatable). Format: `sheet!cell:expected[:tolerance]` |
| `--reset-baseline` | Reset integrity baseline (use when schema changes are intentional) |
| `--row-count-policy` | Check policy for row count changes: `warn` or `fail` |
| `--columns-added-policy` | Check policy for columns added: `warn` or `fail` |
| `--columns-removed-policy` | Check policy for columns removed: `warn` or `fail` |
| `--strict` | Strict mode: all check policies set to `fail` |

### Examples

```bash
# Basic publish
vgrid publish data.csv --repo acme/payments

# With source tracking
vgrid publish data.csv --repo acme/payments --source-type dbt

# With source identity
vgrid publish data.csv --repo acme/analytics --source-identity analytics.monthly_close

# Non-blocking publish
vgrid publish data.csv --repo acme/payments --no-wait

# JSON output for CI
vgrid publish data.csv --repo acme/payments --output json

# Assert column sum for sanity check
vgrid publish data.csv --repo acme/payments --assert-sum amount:12345.67:0.01

# Assert computed cell in .sheet file
vgrid publish model.sheet --repo acme/analytics --assert-cell summary!B7:0:10000

# Strict mode — fail on any schema change
vgrid publish data.csv --repo acme/payments --strict

# Reset baseline after intentional schema change
vgrid publish data.csv --repo acme/payments --reset-baseline
```

### Exit codes

| Code | Meaning |
|------|---------|
| 0 | Check passed (or `--no-fail`) |
| 1 | Integrity check failed |
| 2 | Bad arguments |
| 42 | Network error |
| 43 | Server validation error |
| 44 | Timeout waiting for import |

---

:::tip
`vgrid publish` is the legacy integrity-check publish — it uploads any file and runs server-side assertions. For fingerprint-verified, idempotent publishing with embedded trust metadata, see the [Trust Pipeline](https://docs.visigrid.app/cli/trust-pipeline/) (`vgrid hub publish` and `vgrid pipeline publish`).
:::