<!-- Generated from apps/site/hosted.html by scripts/agent-docs.mjs. Edit the HTML, then rerun it. -->

# Hosted: getting started

> Haystash DB hosted by Haystash (invite-only): sign up, create a project, connect your app, settings, CLI, prices, pausing, billing, backups, deleting, and what we can and cannot see.

Haystash runs the server; each project gets its own Postgres database. **Status: invite-only, not public yet.** It is an unaudited prototype, so keep production data out, or [self-host](/self-hosting.html).

## Sign up

1. Create an account in the [dashboard](/app/#/signup) with email, password and your invite code (**invite-only for now**; an invite link fills it in).
2. **Confirm your address** from our email. Until then you can sign in but not create a project.

Lost your password? Use **Forgot your password?** on the sign-in page.

## Create a project

Press **New project** and name it. In about a minute you get an **address** like `https://<ref>.<domain>` (`<ref>` is the short project id) and a **backend key** (service key, `hsk_…`), **shown once**.

**Save the backend key now:** we keep only its hash. Keep it in backend secrets, never in a web page or app. It reaches every row; locked columns stay ciphertext. Lost it? Make a new one on **Connect**; the old one stops working at once.

The screens (Overview, Tables, Users, Connect) and [concepts](/docs.html#concepts) match the self-hosted console, including a dry run before each lock. You never need the admin token.

## Connect your app

Pass the address from **Connect** to the [JavaScript client](/docs.html#client):

```
import { createClient } from '@haystash/db'

const db = await createClient('https://<ref>.<domain>', {
  pinned: ['notes.body'],   // refuse to run unless notes.body is locked
})
```

Your backend uses the backend key:

```
import { createServiceClient } from '@haystash/db'

const svc = createServiceClient(process.env.HAYSTASH_URL, process.env.HAYSTASH_SERVICE_KEY)
```

The address serves only `/v1` (data API), `/gate` (Key Gate), `/sdk` (client) and `/health`; manage the project in the dashboard. Locally it may be a path like `http://127.0.0.1:7600/p/<ref>`: use what Connect shows. After idling, the first request waits a few seconds for the database to wake.

## Settings

- **Allowed app addresses:** browser origins that may call the project, e.g. `https://myapp.com` or `http://localhost:5173`, no path. Leave empty if only your backend calls it. (Self-hosted: `HAYSTASH_ORIGINS`.)
- **Password sign-in:** on, users sign in with email and password. Off, for apps with their [own sign-in](/docs.html#own-sign-in): your backend vouches for each user with a ticket and passwords are refused.
- **Pause:** stops the project until you resume it. Nothing is deleted.
- **Delete project:** see [Deleting a project](#deleting).

**Usage** shows this month's compute time and storage against your plan, updated daily.

## The command-line tool

The `haystash` tool imports users and tables and locks columns (see [Migrating](/docs.html#migrating)). Hosted, it uses a **CLI token**: open **CLI tokens**, press **New token**, name it after the computer, and copy it (shown once). Then set:

```
export HAYSTASH_URL=https://app.<domain>/api/cli/<ref>
export HAYSTASH_CLI_TOKEN=<your token>
```

It works for one project, can change tables and users, can't read locked values, and can be revoked there.

**Not finished:** the `haystash` tool still sends only an admin token; CLI tokens need a small change to it.

## Plans and prices

Payments are off for now, so every account is on Free. Planned prices, in US dollars:

|  | Free | Pro: $25 a month per account |
| --- | --- | --- |
| Projects | 2 | 3 included, then $10 a month each (up to 10) |
| Compute time | 20 unit-hours per project a month, then the project pauses until next month | $10 of usage included each month; above it, $0.16 per unit-hour |
| Storage per project | 500 MB | 8 GB included; above it, $0.50 per GB a month |
| Card needed | No | Yes |
| Monthly spending maximum | None needed | $50 above the base fee by default; you can change it |

**Compute time** is time awake multiplied by database size. A project's database is a quarter unit and sleeps, free, after 5 idle minutes. So 20 unit-hours is about 80 hours awake.

## Pausing

A paused project keeps its data; apps get `project_paused` until it resumes. It pauses when:

- **you pause it** in Settings (resume any time);
- **a Free project uses its month's compute or storage** (resumes next month or on upgrade);
- **a Pro account hits its spending maximum** (raise it on Billing);
- **a payment has failed for over 14 days** (Stripe retries meanwhile, and Billing warns you): the account drops to Free limits and projects beyond the first two pause until you update your card;
- **Haystash pauses it**, e.g. for abuse (ask support why).

We email you at 80% and 100% of a limit or the spending maximum; Usage and Billing show it too. Limits never delete anything. An idle project is not paused; it wakes on the next request.

## Billing

- **Upgrade to Pro** on Billing, via Stripe Checkout. We never see your card number.
- **Card, invoices and cancelling:** Stripe's billing portal, linked there.
- **Usage above the included $10** and extra projects go on the monthly invoice.
- **Cancelling:** Pro runs to the end of the paid month, then Free limits apply. Projects beyond two pause, never deleted.

## Backups

A project can be **restored to any moment in the last 7 days**. Data and key store (users, devices, wrapped keys, the signed list of locked columns) share one database, so **both return to the same moment**. Later accounts and changes are gone; later locks must be redone.

No restore button yet: ask support. We also do the step that lets devices which saw a newer list of locked columns accept the restored project.

## Deleting a project

In Settings, press **Delete project** and type its name. It stops at once and its address stops answering. For **7 days** support can bring it back. Then the database, users and keys are erased for good.

## What we can and cannot see

As host, Haystash is the server operator in the [threat model](/docs.html#security).

| We hold | Why |
| --- | --- |
| Your project's Postgres database, at Neon, our database provider | Your tables and the project's key store live there |
| The project's master key, admin token and database address, encrypted under our control key | To run the project's Key Gate and admin actions |
| Your account: email, password hash, plan, usage | To run the dashboard and bill you |

**We can:** read and change unlocked columns; see your users' emails, and their passwords when they use password sign-in; pause, delete and restore projects; swap a locked value for another (locked means private, not tamper-proof); and serve changed client code if your app loads it from the project's `/sdk/`. Bundle the client with your app to prevent that.

**We cannot:** read a locked value. Each user's key needs a part held only on their device, recovery code or passkey, so a database copy, even with our keys, opens nothing locked.

**Neon** sees unlocked columns, locked values only as ciphertext, and the key store encrypted under a master key it lacks. **Stripe** holds card details.

Our admin page logs every action (who, what, when). One program serves all projects, each with its own compartment and database, so a bug in it could hit every project at once. None of this has had an outside review. Details: `docs/db/SECURITY.md` in the repository.
