
# Projects

> MCP: wywołaj `read_docs({ operations: [operation] })` i podaj tylko pola ze zwróconego `inputSchema`. Przykłady HTTP poniżej zawierają kopertę zapisu, `requestId` i identyfikatory nadawane przez MCP (`projectId` przy tworzeniu, `documentId` przy tworzeniu dokumentu). Nie dodawaj tych pól do wywołania MCP. Typ rewizji bierze się ze schematu operacji.

All calls require [bearer authentication](authentication.md). Results use `Cache-Control: private, no-store`.

| Endpoint | Response |
| --- | --- |
| `GET /api/v1/me` | `{user:{id,email,name?}}` |
| `GET /api/v1/projects` | `{access,projects}`. Projects include `id`, `name`, `organizationId`, lifecycle and storage fields. |
| `GET /api/v1/projects/{projectId}` | `{project}`. Guest access can return a restricted project projection. |

Use IDs returned by these calls. `access` identifies the personal organization and contains `organizationKind`, `organizationId`, `organizationRole` and `userId`. The list combines accessible projects across organization memberships. Each project identifies its organization.

```sh
curl --fail-with-body "$TARVENA_ORIGIN/api/v1/projects" \
	-H "Authorization: Bearer $TARVENA_TOKEN"
```

Use the selected `projectId` in [document requests](documents.md).

## Create a project

POST `/api/v1/actions/projects/create` with the [contract header](actions.md#write-contract):

```json
{"organizationId":"<access.organizationId>","name":"Parcel survey","type":"operat","requestId":"demo-project-1"}
```

The response is `{"project":{...}}`. Use `project.id` in subsequent requests. This action requires an explicit authorized organization ID and takes no `write` envelope. Keep the same `requestId` and entire body to recover the creation after a timeout. Creation does not connect storage. [Worked example](water-devices.md#project-and-points).

## Project owners

`projects/members/list`, `projects/members/upsert`, and `projects/members/remove` manage explicit organization project owners. Project owners and organization managers may call them. Personal project sharing is denied. The list includes owner directory emails and each owner's `active` or `removed` organization membership state. It excludes organization members whose editing access is inherited.

Read `POST /api/v1/actions/projects/members/list` with `{"projectId":"<projectId>"}`. Use its `revision` as `expectedRevision` for a change. The upsert body is `{"projectId":"<projectId>","email":"next@example.com","role":"owner","expectedRevision":1}`. The existing role enum also accepts `editor` and `viewer` in parsing, but the owner service rejects both with HTTP 400. No general role grants are available here.

Remove an explicit owner with `{"projectId":"<projectId>","userId":"<userId>","expectedRevision":2}`. Self-removal and removal of the last stored owner are forbidden. An owner removed from the project retains inherited organization editor access. This action does not remove organization membership.

Successful writes return the existing membership `change` with `domain`, `projectId`, `revision`, and `updatedAt`. Upsert also returns `member`; removal returns `removed: true`. A stale revision returns HTTP 409 with `error: "conflict"` and `currentProject.revision`. Directory unavailable or inconsistent results return retryable errors. Denied requests do not expose membership details.

After a timeout or lost response, reread `projects/members/list` to determine whether the desired ownership change committed. Do not blindly repeat the mutation. Member writes have no replay envelope or terminal receipt. Repeating an upsert with a fresh revision can advance the revision again.

## Project overview

MCP `overview` combines the reads an agent needs to orient in one project. Over HTTP read them
separately: `projects/get`, `location/get` with `domain:"location_parcels"`, `water-design/query`
with `query:{kind:"tree"}` and `query:{kind:"calculations"}`, and `documents/list`.
