# Organize work by org and project

> Give each customer a project, let their people in with a team, run and read their work by project or org, and know what deleting a project or an org does.

This guide gives each customer a project, lets their people in with a team, runs and reads their work by project or org, deletes and restores a project, and deletes an org.

A **project** holds runs, conversations, approvals and what they cost: one project per customer, for example. A **team** is a group of the workspace's people, and a team's role on a project reaches everyone in it. An **org** is optional: it groups projects, such as one customer's several projects, so their work can be read together. Every workspace has a default project. A run that names no project runs in its agent's or flow's own project: the one it was published in. For what `kindgi deploy` registers, that's the project the deploy named (`--project`), else the default project. A turn in a conversation stays in the conversation's project.

An agent, flow, tool or set of test cases belongs to the project its first version was published into, and never moves. Publishing a version of it into another project is refused with a `409`, and nothing is written. Its code names the kind, such as `agent-project-mismatch`, `flow-…`, `tool-…` or `test-set-project-mismatch`. The refusal doesn't name the project it belongs to, since you may not be able to read that project. A deploy that includes one is refused whole and deploys nothing, even when that agent or flow is unchanged. Publish new versions in its own project.

Reading an agent, flow, tool, test cases or guardrail says which project it's in: its `projectId`, with the runtime 0.1.6 or later. A pack `kindgi dev` serves from disk has none.

## Before you start

- **A runtime,** such as `kindgi dev`, with Kindgi 0.7's client and CLI.
- **Node 22.12 or later, Python 3.11 or later, or Java 17 or later,** for the client.
- **`KINDGI_API_URL` and `KINDGI_API_TOKEN`** set, or a running `kindgi dev`, which the client finds.
- **An agent,** to run in the customer's project. This guide uses `acme-ops.greeter`.

## Give a customer a project

Create the customer's project once, then run the customer's work there. Ask your coding agent: "I want each of my customers to have a project, and their work to run there." For reference, the script looks like this. It prints the run's status and the project's runs:

- **TypeScript**

  `customer-project.ts`

  ```ts
  import { createClient } from '@kindgi/sdk/client';

  const kindgi = createClient(); // KINDGI_API_URL, KINDGI_API_TOKEN, or the running kindgi dev

  // Once per customer: a project.
  const project = await kindgi.projects.create({
    slug: 'acme-customer-one',
    name: 'Customer one',
    everyoneCanRun: false,
  });

  // The customer's work runs in its project.
  const run = await kindgi.runs.start({
    agent: 'acme-ops.greeter',
    input: { userMessage: 'Echo hello.' },
    projectId: project.id,
  });

  // Everything in the customer's project.
  const runs = await kindgi.runs.list({ scope: { kind: 'project', projectId: project.id } });
  console.log(run.status, runs.data.map((r) => r.id));
  ```

- **Python**

  `customer_project.py`

  ```python
  from kindgi.client import Kindgi

  kindgi = Kindgi()  # KINDGI_API_URL, KINDGI_API_TOKEN, or the running kindgi dev

  # Once per customer: a project.
  project = kindgi.projects.create(
      slug="acme-customer-one", name="Customer one", everyone_can_run=False
  )

  # The customer's work runs in its project.
  run = kindgi.runs.start(
      agent="acme-ops.greeter",
      input={"userMessage": "Echo hello."},
      project_id=project.id,
  )

  # Everything in the customer's project.
  runs = kindgi.runs.list(scope_kind="project", scope_id=str(project.id))
  print(run.status, [str(r.id) for r in runs.data])
  ```

- **Java**

  `src/main/java/com/acme/app/CustomerProject.java`

  ```java
  package com.acme.app;

  import com.kindgi.client.Kindgi;
  import com.kindgi.client.models.CreateResourceResult;
  import com.kindgi.client.models.ProjectSpec;
  import com.kindgi.client.models.Run;
  import com.kindgi.client.models.RunCollectionPage;
  import com.kindgi.client.models.ScopeKind;
  import com.kindgi.client.models.StartRunBody;
  import com.kindgi.client.resources.RunsListParams;
  import java.util.Map;
  import java.util.UUID;

  public final class CustomerProject {
    public static void main(String[] args) {
      Kindgi kindgi = Kindgi.create(); // KINDGI_API_URL, KINDGI_API_TOKEN, or the running kindgi dev

      // Once per customer: a project.
      CreateResourceResult project = kindgi.projects().create(ProjectSpec.builder()
          .slug("acme-customer-one")
          .name("Customer one")
          .everyoneCanRun(false)
          .build());

      // The customer's work runs in its project.
      Run run = kindgi.runs().start(StartRunBody.WithAgent.builder()
          .agent("acme-ops.greeter")
          .input(Map.of("userMessage", "Echo hello."))
          .projectId(UUID.fromString(project.id()))
          .build());

      // Everything in the customer's project.
      RunCollectionPage runs = kindgi.runs().list(
          RunsListParams.builder().scopeKind(ScopeKind.PROJECT).scopeId(project.id()).build());
      System.out.println(run.status() + " " + runs.data().stream().map(RunCollectionPage.DataItem::id).toList());
    }
  }
  ```

  `create` answers the new project's id. A run's `projectId` is a `UUID`.

- **Scala**

  `src/main/scala/acme/app/CustomerProject.scala`

  ```scala
  package acme.app

  import com.kindgi.client.Kindgi
  import com.kindgi.client.models.{ProjectSpec, ScopeKind, StartRunBody}
  import com.kindgi.client.resources.RunsListParams
  import java.util.UUID
  import scala.jdk.CollectionConverters._

  object CustomerProject {
    def main(args: Array[String]): Unit = {
      val kindgi = Kindgi.create() // KINDGI_API_URL, KINDGI_API_TOKEN, or the running kindgi dev

      // Once per customer: a project.
      val project = kindgi.projects().create(ProjectSpec.builder()
        .slug("acme-customer-one")
        .name("Customer one")
        .everyoneCanRun(false)
        .build())

      // The customer's work runs in its project.
      val run = kindgi.runs().start(StartRunBody.WithAgent.builder()
        .agent("acme-ops.greeter")
        .input(Map("userMessage" -> "Echo hello.").asJava)
        .projectId(UUID.fromString(project.id))
        .build())

      // Everything in the customer's project.
      val runs = kindgi.runs().list(RunsListParams.builder().scopeKind(ScopeKind.PROJECT).scopeId(project.id).build())
      println(s"${run.status} ${runs.data.asScala.map(_.id).toList}")
    }
  }
  ```

  `create` answers the new project's id. A run's `projectId` is a `UUID`.

```text
completed [ '68ebe748-4259-4f46-ae21-cf0da3b978c6' ]
```

Keep the project's id on the customer's row in your app. From the CLI:

- `kindgi projects create --name=Support` makes a project and prints it with its id, and `--org=<org-id>` puts it in an org. Its slug is the name as a slug (`support`) unless `--slug` gives one. Everyone in the workspace can run its agents and flows, as its `everyoneCanRun` says. Turn that off with `PATCH /v1/projects/<project-id>` before you add a customer's people ([Everyone can run a project](https://docs.kindgi.com/v0.7.0/deploy/authorization.md#everyone-can-run-a-project)).
- `kindgi projects rename <project-id> --name=<name>` renames one, and `--slug` changes its slug.
- `kindgi projects list` lists the projects with their ids.
- `kindgi runs start … --project=<project-id>` runs in a customer's project.

In the console, a tenant admin makes one with **New project** on the workspace dashboard's **Projects** card: a name, a slug made from the name until you edit it, an org if the workspace has any, and what it's for. The new project then opens. A project's admins (an admin of its org, or a tenant admin, is one) rename it with the pencil button in its **Dashboard**'s header, **Rename the project**. Its slug stays unless you tick **Change its slug too**. The new slug then follows the name until you edit it, and the dialog says what to change before you next use the CLI on the project. Its id stays; what a new slug changes is under **Changing a project's slug**, below.

**The customer's people.** To let the people who work on a customer's project in, put them in a team and give the team a role on the project: `viewer`, `runner`, `editor` or `admin`. Everyone in the team then holds it there. Roles take [authorization](https://docs.kindgi.com/v0.7.0/deploy/authorization.md), which `kindgi dev` runs without. The script makes the project with `everyoneCanRun: false` (`everyone_can_run=False` in Python), so only the people given a role run it. A new project otherwise lets everyone in the workspace run its agents and flows, other customers' people included ([Everyone can run a project](https://docs.kindgi.com/v0.7.0/deploy/authorization.md#everyone-can-run-a-project)). The console makes teams, and the API gives one its role on a project ([Teams](https://docs.kindgi.com/v0.7.0/deploy/authorization.md#teams) and [Team grants](https://docs.kindgi.com/v0.7.0/deploy/authorization.md#team-grants)). When the customer leaves, take the team's role away (`DELETE …/team-grants/<team-id>`), or delete the team.

**An org, where it helps.** A customer with several projects can have an org that groups them: create it with `orgs.create`, and give each project its id as `orgId` (`org_id` in Python, `--org` in the CLI). The lists then read all of the customer's projects at once, as [Read a customer's work](https://docs.kindgi.com/v0.7.0/guides/projects/organize-by-org-and-project.md#read-a-customers-work) shows.

**Slugs.** An org's slug is unique in the workspace. A project's slug is unique in its org, so two orgs can each have a `support` project. A project with no org has a slug unique among the projects with none. A taken slug is refused with `409 slug-conflict`, and so is a slug another project of the workspace had before it was renamed (runtime 0.6.0 or later):

```text
Another org in the workspace has the slug "acme-customers"
Another project in its org has the slug "acme-customer-one" (for a project without an org: another project without one)
The slug "support" was another project's until it was renamed, and it stays that project's. Choose another slug.
```

The refusal's `details.heldAs` says which: `'slug'` for a slug another project has now, `'old-slug'` for one it had before a rename.

**Changing a project's slug.** A rename is one change: a taken slug is refused, as above, and nothing changes. The project's id stays, and the runtime goes by the id, so the project's pages in the console, its runs, keys and triggers, and what's deployed into it keep working, with no redeploy. With the runtime 0.6.0 or later, its old slug stays the project's: no other project in the workspace can take it, in any org. The project's `formerSlugs` (`former_slugs` in Python) lists its old slugs, newest first, and is empty for a project never renamed; an earlier runtime leaves it out. Only the CLI looks a slug up, each time it runs, wherever you name a project by its slug: `kindgi deploy --project`, say, or an environment's `project` in your pack config (`environments.<name>.project`). Every command that names a project that way looks it up: `kindgi deploy`, `kindgi deployments list --project`, `kindgi suggested-changes pull --project`, `kindgi promote` (in a pack, and with `--from` and `--to` outside one), `kindgi environments set`, and `kindgi secrets` and `kindgi env` under a pack environment (`--env`). Given the old slug, each of them is refused, and the refusal names the new slug and where to change it (an earlier CLI says no project has the slug). A project in another org that has the slug too keeps it: a command that names the slug is then refused as naming two projects, and an earlier CLI acts on that other project. A project can take its old slug back, unless another project also had it before a rename. A deleted project keeps its slugs, old and current, so a config that names one never lands in another project (see [Delete and restore a project](https://docs.kindgi.com/v0.7.0/guides/projects/organize-by-org-and-project.md#delete-and-restore-a-project)). Still, name projects by their id in scripts and pack configs that may outlive a rename.

An earlier runtime keeps no old slugs, and a later one doesn't keep those changed before its upgrade. There, the old slug is free for another project to take, and a command that names it then acts on that project: a deploy goes into it without a word, and a secret or value is set on it. So with such a runtime, change the old slug to the new one in scripts and pack configs before anyone runs one of those commands again.

A workspace has one default project. Asking for a second one answers `409 project-default-already-exists`, "The workspace already has a default project".

## Deploy a client's pack into its project

Give each client its own project and its own pack. `kindgi init` makes a pack whose ids all start with its pack id, so two clients' packs never share an id:

```sh
npx --yes @kindgi/cli@0.7 projects create --name="Acme shop"
npx --yes @kindgi/cli@0.7 init acme-shop --template=woocommerce
cd acme-shop
pnpm install
pnpm exec kindgi deploy --project acme-shop
```

`--project` takes the project's id or its slug. A slug is unique within an org, so if two orgs each have a project with that slug, the CLI refuses it and names both ids: pass the id instead. With the runtime 0.6.0 or later, a renamed project's old slug is refused too, and the refusal names its new one. Without `--project`, a deploy is workspace-wide and registers into the default project, as before.

What a deploy into a project does, with the runtime 0.1.8 or later:

- **Its agents, flows, tools and guardrails** are registered in that project, and the deployment records it (`projectId` on `GET /v1/deployments/{deploymentId}`).
- **`kindgi deploy --sync-secrets`** writes the secrets into that project, so one client's credentials stay in its own project. A workspace-wide deploy writes them workspace-wide. A secret a tool names that's set nowhere yet when it's deployed is read where the sync writes it (runtime 0.1.9 or later). So after a deploy into a project, set it later in that project (`kindgi secrets set <name> --env=<env> --scope=project:<project-id>`), not workspace-wide.
- **It needs admin on that project** (a workspace-wide deploy needs admin on the workspace). An API key limited to another project is refused with `403 key-project-mismatch`.
- **A project of another workspace, or none,** is `404 project-not-found`.
- **A suspended project** takes no deploy, where the runtime suspends projects: `409 project-suspended`, before anything is written. No run starts in it either: `POST /v1/runs` answers the same, as do a test run started in it and an Improve run for one of its agents. A test run or an Improve run already going stops at its next case and ends `cancelled`, with `project-suspended` in its `cancelReason`. A delivery to one of its webhook triggers is answered `202` and skipped, with nothing recorded on the trigger's fires.

Deploying the same pack into a second project is refused, because its ids already belong to the first project: `409 tool-project-mismatch` (or `agent-…`, `flow-…`, `guardrail-…`), and nothing is deployed. The message names the fix your runtime has. Where each deployment runs as a service of its own, make a copy of the pack for the new client with `kindgi init`, which gives every id the new pack's id. Where one pack service runs every deployment, the default on any runtime, a copy's code wouldn't run. There, when both projects are in the same org, or neither is in an org, put them in one environment order (`kindgi environments set`), the second right after the first, and `kindgi promote` the build to the second instead of deploying it. A project per client with no org, as this guide sets one up, can do that. Projects in two orgs can't share an order, so a client in an org of its own needs a runtime that runs each deployment as a service of its own.

## What a project's runs can use

A run uses its own project's tools, agents, flows, guardrails, data blocks and test cases, and the tools of an MCP server registered for its project, its org or the workspace. Anything else is refused with `reference-out-of-scope`: a publish, a deploy or a run start that names it answers `400` before anything is written, and a tool call from the run isn't run. [What a project's runs can use](https://docs.kindgi.com/v0.7.0/concepts/projects-packs-values.md#what-a-projects-runs-can-use) has the rule and its messages.

To give several clients' projects one tool, run it as an MCP server and register it for their org or the workspace ([Give some projects its tools](https://docs.kindgi.com/v0.7.0/guides/tools/mcp-servers.md#give-some-projects-its-tools)).

## Read a customer's work

The lists take a `scope`: one project's, or every project's in an org. In TypeScript, it's `{ kind: 'project', projectId }` or `{ kind: 'org', orgId }`. In Python, it's `scope_kind="project", scope_id=…`.

- Runs: [List runs](https://docs.kindgi.com/v0.7.0/guides/runs/list-runs.md).
- Approvals: [Decide an approval](https://docs.kindgi.com/v0.7.0/guides/approvals/decide-an-approval.md).
- Conversations: [Conversations](https://docs.kindgi.com/v0.7.0/guides/agents/conversations.md).
- Where answers came from: [Trace an answer](https://docs.kindgi.com/v0.7.0/guides/observability/trace-an-answer.md).
- What it cost, by month and model: [Cost per run and per customer](https://docs.kindgi.com/v0.7.0/guides/observability/cost-per-run.md).

A record with no project shows only in a list without a scope.

A tool sees the run's project and org, as `ctx.projectId` and `ctx.orgId`. So it can check that a record belongs to the customer the run is for: by `ctx.projectId`, with a project per customer. [Check the run's org](https://docs.kindgi.com/v0.7.0/guides/tools/write-a-tool.md#check-the-runs-org) shows the same check by org.

## Put a project in production

A project is in production when the customer's real work runs in it: serving their customers, or processing their live business data. A run in a project in production is a **production** run, and a run anywhere else is **staging**. A runtime that counts usage (`KINDGI_USAGE_METERING=on`) labels each run with its class for usage counting, so test work is counted apart from real work. A run's own read doesn't show it.

On a runtime you run yourself, with neither usage counting nor the production gate or limit below, being in production is only a label: agents, flows, triggers and approvals work the same in a project in production and out of it. The license key doesn't read it either ([What a key covers](https://docs.kindgi.com/v0.7.0/concepts/licensing.md#what-a-key-covers)). Only a promote-only build tells them apart: it reaches a project in production only by promotion (below).

To switch it from your app, ask your coding agent: "Put a customer's project in production when they go live." For reference, the commands and the code look like this:

- **CLI**

  ```sh
  pnpm exec kindgi projects production <project-id> on
  pnpm exec kindgi projects production <project-id> status
  pnpm exec kindgi projects production <project-id> off
  ```

  In a Python project that's `uv run kindgi …`, and in Java or Scala `./kindgiw …`.

  Each prints one line: whether the project is in production and, if it is, since when. `--json` prints `{ projectId, productionSince }`. A refusal names its code and exits 1.

- **TypeScript**

  ```ts excerpt
  const { productionSince } = await kindgi.projects.setProduction(project.id, true);
  // …and out again: productionSince is null.
  await kindgi.projects.setProduction(project.id, false);
  ```

- **Python**

  ```python
  done = kindgi.projects.production.set(str(project.id), production=True)
  print(done.production_since)
  kindgi.projects.production.set(str(project.id), production=False)
  ```

- **Java**

  ```java excerpt
  // in src/main/java/com/acme/app/CustomerProject.java
  ProjectProduction done = kindgi.projects().production()
      .set(project.id(), ProjectProductionBody.builder().production(true).build());
  System.out.println(done.productionSince());
  // …and out again: productionSince is null.
  kindgi.projects().production()
      .set(project.id(), ProjectProductionBody.builder().production(false).build());
  ```

- **Scala**

  ```scala excerpt
  // in src/main/scala/acme/app/CustomerProject.scala
  val done = kindgi.projects().production()
    .set(project.id, ProjectProductionBody.builder().production(true).build())
  println(done.productionSince)
  // …and out again: productionSince is null.
  kindgi.projects().production()
    .set(project.id, ProjectProductionBody.builder().production(false).build())
  ```

In the console, a project's **Dashboard** says at the top whether it's in production: **Live**, by a green dot, or **Testing mode**, by a gray one. Choosing it says since when it's been live, or "Kindgi counts its runs as testing. Once it's live, they count as live use.", and gives a tenant admin the switch: **Go live**, or **Move back to testing**. While the workspace may not put projects in production, it says "Going live isn't turned on for this workspace yet.", and gives a tenant admin **See how to go live** when the runtime names where to go. A refused switch says why in the console's words: at the workspace's limit of live projects, "Move one back to testing first", with a link to get more when the runtime names one, or "Going live isn't turned on for this workspace yet."

- **Tenant admins only,** both ways: anyone else gets `403 permission-denied`.

- **Setting what's already set changes nothing,** and keeps the first `productionSince`. Reading the project shows it while it's in production.

- **The production gate:** a runtime may require the workspace to be allowed to put projects in production, for example once it has paid (`KINDGI_PRODUCTION_GATE=on`). Until then, putting one in production is refused with `403 production-not-allowed`, and the error's `details.next` says where to go when the runtime names it (`KINDGI_PRODUCTION_NEXT_URL`). A project already in production stays so, and staging keeps working. `GET /v1/tenant` says where the workspace stands: `productionAllowed`, and `productionNext` while it isn't allowed.

  ```json
  {
    "error": {
      "code": "production-not-allowed",
      "message": "This workspace can't put projects in production yet. To be allowed: https://platform.example.com/account/billing. Projects not in production keep working as staging.",
      "details": {
        "projectId": "b3bc8d28-8487-4d90-be57-4e522488f10c",
        "next": "https://platform.example.com/account/billing"
      },
      "requestId": "req-04d7cdca-a8ca-4ff6-87ad-9939387223a0"
    }
  }
  ```

- **A limit on projects in production:** whoever runs the server can set the workspace's `projectsInProduction` limit (`PUT /v1/system/tenants/{tenantId}/limits`). With that many of its projects in production, putting another one in is refused with `403 production-limit-reached`. Its `details` give the limit (`projectsInProduction`), the count (`inProduction`), and `next` when the runtime names it. A project already in production answers its repeat unchanged, and taking one out is never refused. Lowering the limit takes no project out of production: the next one waits until the count is under it. `GET /v1/tenant` shows the limit in `limits`.

  ```json
  {
    "error": {
      "code": "production-limit-reached",
      "message": "This workspace's limit is 3 projects in production, and it has 3. To put another in production: https://platform.example.com/account/billing, or take one out of production first.",
      "details": {
        "projectId": "22792d5f-b8cb-4d57-a785-b1f00a57b38e",
        "limit": "projects-in-production",
        "projectsInProduction": 3,
        "inProduction": 3,
        "next": "https://platform.example.com/account/billing"
      },
      "requestId": "req-b455a4ea-669e-431f-9350-3142a35c991d"
    }
  }
  ```

- **A runtime whose projects can't be put in production** answers `501 production-unsupported`.

- **A promote-only build reaches a project in production only by promotion.** A build is promote-only when its signed envelope says `productionEntry: 'promote-only'`, or when the key that signed it has an id starting with `kindgi-promote-only:`, or the same public key as such a key the workspace has trusted, revoked or not. A deploy of one into a project in production, or into one whose production the runtime can't read, is refused with `409 promote-only-build`, and nothing is deployed. Deploy it into a project that comes before this one in its environment order (a tenant admin makes one when there's none), then promote it from there: the promotion keeps the mark and checks the signature over it again. Turning production on for a project is refused the same way, with `409 promote-only-build` naming the deployment, while a promote-only build was deployed into it rather than promoted there, whether that build still serves or not: one out of service can be brought back. So a project a promote-only build was deployed into never goes into production. Put another project after it in its environment order, turn production on there, and promote into it. A runtime that doesn't know the field checks the signature without it, so a build carrying it deploys only on a runtime that knows it.

## Delete and restore a project

Delete a project when its work is over. A deleted project is kept, so a workspace admin can restore it as it was. Ask your coding agent: "When a customer's project ends, delete it." For reference, the code looks like this, with `kindgi` and `project` from the script:

- **TypeScript**

  ```ts excerpt
  await kindgi.projects.delete(project.id);
  // And back, as it was:
  const restored = await kindgi.projects.restore(project.id);
  ```

- **Python**

  ```python excerpt
  kindgi.projects.delete(str(project.id))
  # And back, as it was:
  restored = kindgi.projects.restore(str(project.id))
  ```

- **Java**

  ```java excerpt
  // in src/main/java/com/acme/app/CustomerProject.java, when the project's work is over
  kindgi.projects().delete(project.id());
  // And back, as it was:
  Project restored = kindgi.projects().restore(project.id());
  ```

- **Scala**

  ```scala excerpt
  // in src/main/scala/acme/app/CustomerProject.scala, when the project's work is over
  kindgi.projects().delete(project.id)
  // And back, as it was:
  val restored = kindgi.projects().restore(project.id)
  ```

Deleting a project:

- **The project is gone:** lists leave it out, and fetching or changing it answers `404 project-not-found`, as for a project that never existed. Deleting it again changes nothing, and keeps the time of the first delete.
- **Nobody can reach what's in it:** its agents, flows, tools, conversations, artifacts and values. Its unfinished runs are cancelled, and new runs, deploys, test runs, Improve runs and pins in it are refused with `404 project-not-found`. A test run or an Improve run already going stops at its next case and ends `cancelled`, with `project-deleted` in its `cancelReason`. Without [authorization](https://docs.kindgi.com/v0.7.0/deploy/people-and-keys.md#without-authorization), roles aren't checked, so the workspace's keys can still read what's in it by id until it's restored. Its runs, deploys, test runs, Improve runs and pins are refused there too.
- **Its triggers and schedules skip their fires,** with `project-deleted` in the fire's `detail`. A skipped fire isn't a failure and doesn't pause the trigger. A webhook delivery to it is answered `202` with `skipped: 'project-deleted'`, and nothing is kept.
- **Its deployments are retired,** with `reason: 'project-deleted'`.
- **The rest stays:** what's in it, its runs' records, its members and team grants, the keys limited to it, and its own account. They reach nothing while it's deleted.
- **Its slugs stay its own,** old and current. Creating a project, or changing one's slug, onto one of them answers `409 slug-conflict` with `details.deletedProject: true`. Restore that project, or choose another slug.
- **It's recorded** in the audit log as `project-deleted`, with who deleted it. Deleting it again records nothing.

Two projects can't be deleted: the workspace's default project (`409 project-is-default`), and a project in an environment order (`409 project-in-environment-order`) until it's taken out of the order.

**Restoring it** (`POST /v1/projects/{projectId}/restore`) brings it back as it was, with its slugs, members, grants, keys and own account, and answers the project. It's recorded in the audit log as `project-restored`, with who restored it. Its cancelled runs stay cancelled, and fires that came due while it was deleted aren't made up: the next ones run. Restoring a project that isn't deleted changes nothing and records nothing. A deleted project doesn't count against the workspace's limit on projects in production, so restoring one that's in production counts it again: at the limit, the restore is refused (`403 production-limit-reached`) until one is taken out of production.

**The deleted projects:** `GET /v1/projects/deleted` lists the workspace's deleted projects, newest first, a page at a time. Each one has its `id`, `name`, `slug`, `formerSlugs`, `deletedAt`, and its `orgId` when it has one. It's where to find the id to restore. The clients call it `listDeleted` (`list_deleted` in Python).

- **Workspace admins only,** to restore and to list: anyone else gets `403`, the project's own admins too.
- **A runtime that can't restore projects** answers both `501 project-restore-unsupported`. Deleting still works there, and erases the project instead: its slugs are free again.

Kindgi keeps a deleted project's record: no [retention policy](https://docs.kindgi.com/v0.7.0/deploy/retention.md) purges one.

## Delete an org

Delete an org you don't need, such as one that groups the projects of a customer who left. Ask your coding agent: "When a customer leaves, delete the org that groups their projects." For reference, the code looks like this, with `kindgi` from the script and the org's id:

- **TypeScript**

  ```ts excerpt
  await kindgi.orgs.delete(orgId);
  ```

- **Python**

  ```python excerpt
  kindgi.orgs.delete(org_id)
  ```

- **Java**

  ```java excerpt
  kindgi.orgs().delete(orgId);
  ```

- **Scala**

  ```scala excerpt
  kindgi.orgs().delete(orgId)
  ```

* **The org is gone:** lists leave it out, and fetching it answers `404 org-not-found`. Its slug is free at once. Deleting it again changes nothing.
* **Its projects and teams stay,** with no org, and so does their work.
* **Its own secrets and their mappings are deleted for good.** Its own environments and MCP endpoints are unregistered.
* **Writes to it are refused:** setting a secret in it, registering an MCP endpoint in it, and creating or moving a project or a team into it. Creating or moving a project or a team there answers `404 org-not-found`, as for an org that never existed: `No org with id "0404cbc2-9612-461d-9997-0cbf1d12341a"`.

Kindgi keeps the deleted org's record until a [retention policy](https://docs.kindgi.com/v0.7.0/deploy/retention.md) on `org` purges it. That comes after its environments' and MCP endpoints' own records are purged.

## Rename your workspace

Your workspace is the tenant your orgs and projects sit in. A tenant admin can rename it (runtime 0.1.10 or later): its name, its slug, or both. Its id stays, so whatever names it by its id keeps working, your keys and the CLI included.

- `kindgi tenant rename --name="Acme Store"` changes its name, and `--slug=acme-store` its slug. It prints the workspace, as `kindgi tenant get` does.
- The TypeScript and Python clients' `tenant.update` does the same: `PATCH /v1/tenant`, which answers `204`.
- In the console, use **Rename** in the header of the workspace's home page.

The console's addresses carry the slug. After a new one, a bookmark or a link with the old slug opens a page that says the address names another workspace, with a link to yours. Another workspace can then take the old slug. Nothing in the CLI or the clients uses it.

A workspace's slug is lowercase letters, digits and single hyphens, at most 63 characters, and unique across the runtime's workspaces. A taken one is refused with `409 tenant-slug-taken`, and a closing workspace with `409 tenant-closing`.

## Next

- [List runs](https://docs.kindgi.com/v0.7.0/guides/runs/list-runs.md)
- [Cost per run and per customer](https://docs.kindgi.com/v0.7.0/guides/observability/cost-per-run.md)
- [Check the run's org](https://docs.kindgi.com/v0.7.0/guides/tools/write-a-tool.md#check-the-runs-org)
