# Projects & environment

Each project gets a permanent slug, which becomes its address: `https://<slug>.harakumo.app`. Creating a project reserves the name; nothing serves until the first deploy succeeds. A project that only holds a database or storage has no website, and that is fine.

A name whose address would start with `hk-` or `harakumo` is kept for Harakumo's own services and refused with 400 `reserved_name`.

## Launch an app

`POST /api/launch { description, kind?, name?, brandColor? }` makes a new app live in about a minute: the project, the database, sign-in and storage its kind needs, the app's own key, its tables, and a first version deployed as one edge program, then waits until its address answers. The dashboard's New project, `hk.launch()` and `harakumo launch` (SDK and CLI 0.5.0 or later) and the AI connector's launch_app all run the same launch, with the caller's own credential on every step.

`description` is one sentence about the app (at most 500 characters). `kind` is one of the kinds `GET /api/launch` lists (store, saas, booking, portfolio, education, community, ai-app, internal-tool or general); left out, it is read from the description. Without a `name`, one is made from the description.

It takes a browser session or a full key for the whole workspace (a key limited to one project is refused: a launch makes a new project), and a verified email, asked for before anything is made (403 `email_unverified`). Past the plan's project count it answers 402 `plan_limit` with `required_plan`.

The answer is 200 with the project, its address and each step timed. `launch.ok` is false when it stopped before going live, and `failed` says why; the project is kept either way, so fix what failed and deploy again rather than launching twice.

**curl**

```bash
curl -X POST https://harakumo.com/api/launch \
  -H "Authorization: Bearer $HARAKUMO_API_KEY" -H "content-type: application/json" \
  -d '{ "description": "A booking site for my yoga studio", "kind": "booking" }'
# 200 → { "project": { "id", "slug", "name" }, "url": "https://<slug>.harakumo.app",
#         "launch": { "ok": true, "kind": "booking", "total_ms": 41200, "goal_ms": 60000, "under_goal": true,
#                     "steps": [{ "key": "project", "label": "Project", "ms": 900, "ok": true }, …] },
#         "services": { "created": […], "reused": […] }, "failed": [], "next": […] }
```

## What a project reports

`GET /api/projects/:id` returns `project` (with `live_url`, null until a deploy is live), `serving` (`state`: live, down, deploying, failed or not_deployed, plus the serving deployment), `deployAction` (what Deploy does: rebuild the latest GitHub commit, or redeploy kept files) and `services` (counts of vectors, memory stores, agents, auth pools and media, and the payment account). The project id is on the project's Overview (Connect your app) and Settings.

`GET /api/projects/:id/context` is the project's memory in one answer: its docs, Roadmap, newest commits and deploys, and `todo`, what is not finished yet (see Repos: project memory). Creating a project answers `nucleus` (its repo and the docs it should hold), `roadmap.instruction` and `todo`: a new project lacks its docs and its Roadmap.

## Environment variables

- Set them in the dashboard (project → Environment) or with `POST /api/projects/:id/env { key, value }`. A key starts with a letter or an underscore and has only letters, digits and underscores (`API_KEY` and `api_key` both work); anything else is refused with 400, so every key that is accepted reaches your code. Setting an existing key replaces it.
- They are copied into sites, server apps and functions when those deploy. Change one, then redeploy (or press Redeploy) for it to take effect. Every answer to a change names the functions still running with the old values (`functions_behind`), and the project's Environment page in the dashboard offers to redeploy them.
- Every server app, build, worker.js program and function also gets `HARAKUMO_PROJECT_ID`, the project's id, set by Harakumo. A project variable of that name never replaces it: the code gets the real id, and a server app's or worker.js program's deploy log says so when the stored value differs.
- Only the production target is used.
- Answers carry names, not values. A write answers what it changed (`changed`: the key, target and `value_length`, or `removed: true`), and any list in it has names only. `GET` answers each variable's name, target and `value_length`; `GET ?values=1` adds the values for a signed-in developer or above and a full-access API key, never for viewers, read-only keys or the AI connector. Those values are secrets: a log, a terminal or an AI chat that prints the answer keeps them. In the dashboard, a value shows when you click it.
- Developers and above can read the values, so do not reuse a value you could not afford a teammate to see.

## Deleting a project

Deleting removes the site, functions, buckets and their files, databases, vector collections, memory stores, media and custom-domain connections. Domains bought in the workspace stay in the workspace and keep renewing.

- Refused with 409 `deletion_blocked` while the project holds unwithdrawn earnings, a pending withdrawal, a checkout link that can still be paid, or a running deploy. `blockers[]` says what to do.
- If something cannot be removed, the answer is 502 `teardown_incomplete`; the project is kept with status teardown_failed, accepts only reads and deletes, and deleting again retries.
- Deleting needs an admin, or a full workspace key. Project keys and read-only keys cannot delete projects.

## Reference

**SDK**

```js
const launched = await hk.launch({ description: 'A booking site for my yoga studio' });   // live in about a minute (SDK 0.5.0 or later)
const { project } = await hk.projects.create({ name: 'my-app' });
const { project: p, serving, services } = await hk.projects.get(project.id);   // p.live_url, serving.state
const { projects } = await hk.projects.list();
await hk.projects.delete(project.id);
```

**CLI**

```bash
harakumo launch "A booking site for my yoga studio"   # live in about a minute (CLI 0.5.0 or later)
harakumo projects
harakumo projects create my-app
harakumo projects delete 12
harakumo env pull 12                                     # the settings this key may read, as .env.local (CLI 0.5.0 or later)
```

**REST**

```http
POST   /api/launch                     { "description", "kind"?, "name"?, "brandColor"? }   # a new app, live
GET    /api/launch                     # the kinds and the five steps
POST   /api/projects                   { "name": "my-app", "repoUrl"? }
GET    /api/projects                   # each with live_url
GET    /api/projects/:id               # live_url, serving, deployAction, services
GET    /api/projects/:id/context       # the project's memory: docs, Roadmap, commits, deploys, todo
PATCH  /api/projects/:id               { "name"?, "repoUrl"?, "repoBranch"?, "mailSenderName"?, "mailFrom"?, "mailReplyTo"? }
DELETE /api/projects/:id               # 409 deletion_blocked · 502 teardown_incomplete
POST   /api/projects/:id/env           { "key": "SHIPPING_API_TOKEN", "value": "…" }   # upsert → changed, names only
GET    /api/projects/:id/env           # developer+: names and value_length · ?values=1 adds values (not the connector)
PATCH  /api/projects/:id/env/:envId · DELETE /api/projects/:id/env/:envId   # → changed, names only
```
