# Hosting

> Deploy a folder, or the files themselves from a chat, to <slug>.vibiz.app. Edit a live site by sending only what changed. Previews, instant promote and rollback.

Every project has an address, `https://<slug>.vibiz.app`, and the `hosting` resource builds and serves the app there. Deploying works by content hash: files the host already has are never uploaded twice, and every deployment keeps its file manifest, so any production deployment can be switched back to instantly.

## Pricing

Hosting is not charged today: builds and live sites are recorded in usage at $0. Pricing is not decided.

## Limits

- 30 builds per project per UTC day (`rate_limited` after that; `GET /v1/usage` shows `builds_today`).
- Files: up to 10,000 per deployment, 50 MB each. Deploying file contents from a chat: 300 files, 3 MiB each and 4 MiB per call.
- Never uploaded by the CLI: `node_modules`, `.git`, `.next`, `dist`, `.vercel`, `.turbo`, `vibiz.json`, `.env*` files, and key or credential files (`*.pem`, `id_rsa`, `.npmrc`…). It refuses to deploy a home or config folder.
- Deleting a project takes the site offline at once; its data is kept for 7 days and `restore` brings it back.

## Deploy

```bash
vibiz deploy               # build and go live
vibiz deploy ./site --preview
vibiz promote dep_…        # a preview is rebuilt as production; a production deployment switches instantly
vibiz rollback             # back to the version before the live one (any version: vibiz rollback dep_…)
vibiz status               # resources and the latest deployments
```

Over HTTP it is three steps: ask which files are missing, upload them, deploy the manifest.

```bash
SHA=$(shasum -a 1 index.html | cut -d' ' -f1)
curl https://thelastapi.dev/v1/files/missing -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H 'content-type: application/json' -d "{\"shas\":[\"$SHA\"]}"
# → { "missing": ["…"] }
curl -X PUT https://thelastapi.dev/v1/files/$SHA -H "Authorization: Bearer $VIBIZ_API_KEY" \
  --data-binary @index.html
# → 204
curl https://thelastapi.dev/v1/projects/$PROJECT/deployments -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H 'content-type: application/json' \
  -d "{\"files\":[{\"path\":\"index.html\",\"sha\":\"$SHA\",\"size\":$(wc -c < index.html)}]}"
# → 202 { "deployment": { "id": "dep_…", "status": "queued", "target": "production" }, "operation": { … } }
```

Poll `GET /v1/deployments/:id` until `status` is `ready` (or `failed`, with `error`). `target: "preview"` builds at a separate URL.

From an agent: `vibiz_deploy { project_id, path, target?, message? }` (waits for the build), `vibiz_promote`, `vibiz_rollback`.

## From a chat, nothing installed

In Claude.ai or ChatGPT (the remote MCP server at `https://thelastapi.dev/mcp`) there is no folder to read, so the agent sends the files themselves. The live deployment's files **are** the project's code: there is no other copy to keep in sync.

1. `vibiz_create_project { name }`, then `vibiz_deploy { project_id, files: [{ path: "index.html", content: "<!doctype html>…" }, …] }` with every file (text as `utf8`, images as `base64`). It's live at `https://<slug>.vibiz.app`.
2. To change it later: `vibiz_code { action: "read", project_id, paths: ["index.html"] }` reads the live files (`list` shows every path), then `vibiz_deploy { project_id, files: [only the changed ones], deleted?: [paths] }`. They're laid over the live deployment (`base: "live"`, the default once something is live; `"none"` or a deployment id otherwise), so everything else stays as it is.
3. Something broke? `vibiz_rollback { project_id }` goes back to the version before, and `vibiz_code { action: "history", project_id }` lists every version to pick another.

One call carries up to 300 files, 3 MiB per file and 4 MiB in all; a bigger app deploys its folder with `npx @vibiz/cli deploy`. The same rules as a folder apply: `.env*`, key files, `node_modules`, `.git`, `vibiz.json` and build output are refused, and so are absolute paths and `..`. A secret never goes in a file: `vibiz_request_secret` gives the person a [link to paste it](https://thelastapi.dev/docs/keys#secrets-by-link). A page without the analytics tag gets the exact tag back in `next_step`.

The same code from a terminal:

```bash
vibiz code ls                  # the live deployment's files
vibiz code cat index.html      # one file (--deployment dep_… for another deployment)
vibiz pull my-site             # write them all into a folder to edit, then vibiz deploy
```

Over HTTP: `GET /v1/deployments/:id/files` lists `{ path, sha, size }`, and `GET /v1/deployments/:id/files/<path>` returns one file's bytes. A deployment of another account answers `404`.

## Version history

Every deploy becomes a version you can browse, compare and go back to, with no git and nothing to set up. From a chat or a terminal, say what changed:

```bash
vibiz deploy -m "Added the pricing page"
vibiz versions                 # newest first: message, who, when, live, files changed
vibiz diff                     # the live version against the one before
vibiz diff dep_abc             # that version against the one before
vibiz diff dep_old dep_new     # one against the other
vibiz rollback dep_abc         # put that version live again
```

From an agent: `vibiz_deploy { …, message }`, `vibiz_code { action: "history", project_id }`, `vibiz_code { action: "diff", project_id, from?, to? }` and `vibiz_rollback { project_id, deployment_id? }`. In the console: **Deployments ▸ Versions**, with a **Go back to this version** button. A deploy with no message shows a summary from its files, such as `3 files changed`.

File counts and diffs are against the newest working version before it. A diff gives each file added, updated or deleted, a unified diff for text, and the sizes for a binary file. Text files up to 512 KB are compared, up to 100 files and 200 KB of changes at a time; past that, `truncated` is true and each file's `note` says what was left out.

**Going back.** A production version switches instantly. A preview, or a build the host no longer keeps, is rebuilt from its stored files, which takes a build. Either way:

- **The database is not rolled back.** Only the site's code goes back: rows and schema changes stay as they are now, so an old version may not fit a newer schema.
- An instant switch runs with the environment variables that version was built with. A rebuild uses the current ones.
- What was live stays in the list, so you can switch back.
- The next edit with `base: "live"` builds on the restored version.
- A deploy that is still building goes live when it finishes, over what you restored. The result warns you when one is running.

A version that never built can't be restored, and the answer says so.

**How long versions last.** Versions are not deleted and have no time limit: they stay listed, with their files, for as long as the project exists. Each file is stored by its content, outside the hosting layer, when it is uploaded, and a file the host held alone is copied when the build ends. The hosting layer keeps old builds for a limited time, which is why an old version can need a rebuild rather than an instant switch.

Some files of deploys made before copies were kept may be gone. Such a version is still listed: a diff names each missing file in `unavailable`, with why, and going back works while the host can still serve that build. Otherwise it is refused with the same reason, and you pick a newer version. When a project's restore window ends and it is deleted, its history goes with it.

Over HTTP: `GET /v1/projects/:id/versions?limit=&cursor=`, `GET /v1/projects/:id/versions/diff?from=&to=` and `POST /v1/projects/:id/versions/:version/restore`, where `:version` is an id or `previous`. Another account gets `404` on all of them.

## Your own domain

Every app keeps its free `<slug>.vibiz.app` address. A domain the business already owns (`shop.example.com`, or `example.com`) can be connected on top of it, with HTTPS that turns on by itself.

```bash
vibiz domains add shop.example.com     # prints the DNS records to add
vibiz domains                          # every domain, its status and records
vibiz domains verify shop.example.com  # check again now
vibiz domains remove shop.example.com
```

Then add the records at the company where you bought the domain. It usually takes a few minutes; HTTPS turns on by itself.

| You connect | Record to add | Name | Value |
| --- | --- | --- | --- |
| a subdomain, `shop.example.com` | `CNAME` | `shop` | `cname.vibiz.app` |
| the domain itself, `example.com` | `A` | `@` | the address `records_to_set` shows |
| …and its `www` | `CNAME` | `www` | `cname.vibiz.app` |

- **`www` comes along.** Connecting `example.com` also connects `www.example.com` as a permanent redirect to it, so both work and search engines see one site. Its record is in the list. To serve `www` as the main address instead, connect `www.example.com` (a subdomain) and leave the apex out.
- **Ownership.** Sometimes (the domain was used on another site before) one more `TXT` record is listed: add it as shown, name and value exactly.
- **Names** in `records_to_set` are relative to `zone`: `@` is the domain itself. Some DNS providers want the full name (`shop.example.com`); both mean the same.
- **Trusted for sign-in.** A domain an owner adds, one our hosting serves, or one [bought through thelastapi](https://thelastapi.dev/docs/domains) is trusted for sign-in. One an agent adds counts analytics and replay at once and shows `trusted_for_sign_in: false` with a `trust_record` until it is proven: add that TXT record where the domain's DNS is managed (`_vibiz.shop.example.com` = `vibiz-verify=…`, name and value exactly), then `vibiz domains verify shop.example.com`. It is also looked up every hour for a week, so nobody has to poll. Or the owner confirms it in the console (Domains ▸ *Trust for sign-in*).
- **Status**: `pending_dns` (add the records), `verifying` (they're in; ownership and HTTPS are being settled), `active` (live with HTTPS), `error` (read `error`). Status is checked when you look, at most every 20 seconds; `verify` checks right away.
- A domain belongs to one project at a time: another project's answers `409 domain_taken`. Removing it frees it; deleting the project frees it after the 7-day restore window.
- **The main address.** Once a domain has been seen live (DNS, ownership and HTTPS), it is the project's `primary_url` and the console shows it first, with `<slug>.vibiz.app` next to it; until then the vibiz.app address stays primary and the domain shows as pending. A project's `custom_domains` lists each one with `live` and `redirects_to`. A domain that redirects (below) is never the main address.
- No domain yet? [Buy one](https://thelastapi.dev/docs/domains) from your credits: it serves on the app at once, with no records to add.

### Moving to a new domain

Changing the business's address (`seoulsim.xyz` → `seoulsim.com`)? Keep the old one and redirect it, so every link and search result still lands and search engines carry the old pages over:

```bash
vibiz domains add seoulsim.com                     # 1. add the new one (and set its records)
vibiz domains verify seoulsim.com                  # 2. wait until it's live (status active)
vibiz domains redirect seoulsim.xyz seoulsim.com   # 3. redirect the old one to it
vibiz domains redirect seoulsim.xyz none           # stops the redirect again
```

- Every URL on the old domain (and its `www`) answers a **permanent redirect (308)** to the same path on the new one: `seoulsim.xyz/pricing?plan=pro` → `seoulsim.com/pricing?plan=pro`. It happens at hosting, before the app: nothing to change in the code.
- The new domain becomes the project's `primary_url` at once; Search, Mission Control and analytics use it. Keep the old domain registered and its DNS records as they are for at least a few months.
- The target must be another domain of the same project, served by thelastapi hosting and already live: one still waiting on DNS or HTTPS is refused (`verify` it first). A domain can't redirect to itself, and redirects never chain: one that already redirects can't be a target, and a domain others redirect to can't redirect itself (move theirs first). Its own `www` is the exception: it is moved for you, straight to the new domain (never two hops), before the domain itself, and moved back when the redirect stops. A domain others redirect to can't be removed until they stop.
- Redirecting is a full-access key's or an owner's (`403 owner_only` for a Limited key), like removing a domain. In the console: the project ▸ Domains ▸ *Redirect*.

Over HTTP: `POST /v1/projects/:id/domains { "domain": "shop.example.com" }` → `201` with `domain.records_to_set`; `GET /v1/projects/:id/domains`; `POST /v1/projects/:id/domains/shop.example.com/verify`; `PATCH /v1/projects/:id/domains/seoulsim.xyz { "redirect_to": "seoulsim.com" }` (or `null` to stop) → the domain, with `redirect_to`. Each domain has a `console_url` that opens the console's Domains page on it. From an agent: `vibiz_domains` (`action: "redirect"`, `redirect_to`). From code: `vibiz.projects.domains.redirect(projectId, 'seoulsim.xyz', 'seoulsim.com')` (`null` stops it).

## Public live page

A project can be shown on thelastapi's public live page, a globe and a live feed of the businesses built on it. It is off until the owner turns it on, in the project's **Settings ▸ Public live page** or over HTTP (full-access keys only; a Limited key gets `403 owner_only` with the console link):

```bash
curl -X PATCH https://thelastapi.dev/v1/projects/prj_… \
  -H "Authorization: Bearer $VIBIZ_API_KEY" -H "content-type: application/json" \
  -d '{ "public_live": true }'
# → the project, with "public_live": true
```

What is shown, and nothing else: the project's name, its address (`primary_url`: a live own domain, else `<slug>.vibiz.app`), when it went live, its visits (pageviews) over 7 days with their countries (ISO codes and counts), its deploys and sales over 30 days as counts, and its latest visits, deploys and sales in the feed, to the minute. Never an email, an amount or currency, a visitor, a page path, an id or a key; development data never counts. Turning it off takes the project off the next answer at once.

The page reads `GET /v1/public/live` (no key, any origin, cached a minute):

```json
{
  "object": "public_live",
  "generated_at": "2026-11-11T12:00:00.000Z",
  "totals": { "businesses": 1, "visits_7d": 42, "deploys_30d": 3, "sales_30d": 2 },
  "businesses": [{
    "name": "Shop", "url": "https://shop.example.com", "live_since": "2026-10-01T09:30:00.000Z",
    "visits_7d": 42, "visits_by_country_7d": [{ "country": "US", "visits": 30 }, { "country": "DE", "visits": 12 }],
    "deploys_30d": 3, "last_deploy_at": "2026-11-10T18:04:00.000Z", "sales_30d": 2
  }],
  "feed": [
    { "type": "visit", "business": "Shop", "url": "https://shop.example.com", "country": "US", "at": "2026-11-11T11:59:00.000Z" },
    { "type": "sale", "business": "Shop", "url": "https://shop.example.com", "at": "2026-11-11T11:40:00.000Z" }
  ]
}
```

## Running somewhere else

A project doesn't need thelastapi hosting: create it with `--resources auth,ai` (sign-in brings the database), add the app's domain (`vibiz domains add app.example.com`: without thelastapi hosting it is only trusted) and give the host its env (connected host or `VIBIZ_APP_KEY`). A project that has thelastapi hosting but also runs on another host at a domain adds it with `--elsewhere` (`hosting: "elsewhere"`): status `external`, no records, sign-in and analytics accept it. See [Keys and environments](https://thelastapi.dev/docs/keys#getting-the-production-env-to-the-app), and [Use one service](https://thelastapi.dev/docs/use-one) for each service on its own.

## What agents can and can't do

Agents may deploy to production or preview, promote, roll back, delete and restore a project, read domain status and check a domain again. Agents may add the app's own domains: analytics and replay count one at once, and sign-in trusts it once it is proven (`trusted_for_sign_in: false` until then). An agent that can edit the domain's DNS adds the TXT record in `trust_record` and calls `verify`; otherwise the owner confirms it in the console. A domain our hosting serves is trusted as soon as its DNS checks out, and one bought through thelastapi (or a name under it) at once. Removing a domain, connecting a host and turning the public live page on or off are the owner's (`403 owner_only`): they decide where the app answers and where production secrets go. An agent gives the person the domain's `console_url` or the command.

## Errors

| Code | Status | When | Next step |
| --- | --- | --- | --- |
| `rate_limited` | 429 | 30 builds today for this project | wait for `details.resets_at` |
| `invalid_request` | 400 | a bad manifest (absolute path, `..`, bad sha) or a file that doesn't match its sha | fix the file list |
| `dependency_not_ready` | 409 | hosting isn't ready yet | poll the project |
| `domain_taken` | 409 | the slug or domain belongs to another project or app | pick another, or remove it there first |
| `not_found` | 404 | no such project or deployment | check the id |
| `deployment_failed` (MCP) | | the build failed | read the deployment's `error`, fix, deploy again |
