# Create a sub tenant

Canonical page: https://docs.ovok.com/api/sub-project/create-a-sub-tenant-3

`POST /v1/sub-project`

Creates a child project (sub-tenant) of your current project. Use it from admin tooling and from headless integrations that hold an admin client token.

**Auth:** bearer token of a project admin (`ProjectMembership.admin`). Setting `parentProjectId` also requires a super admin.
**Scope:** the parent is the caller's project (from the token), or `parentProjectId` for a super admin.

## Behaviour

- Creates, all or nothing: the `Project` (with the standard Ovok project features, `extension` copied as given, and its own Signals tenant), its tenant code, the parent's link to it, a Practitioner and an admin membership in the new project, and the parent-child relationship. If a step fails, the steps already done are undone.
- **User session:** the new project is owned by your user, the Practitioner copies your profile, and the membership is yours. The response is `{ "success": true }`.
- **Client application session** (no user): the new project is owned by the parent project. The response is `{ "success": true, "projectId": "..." }`.
- A concurrent create of the same name under the same parent is refused with 409 and writes nothing. A later create with the same name makes a second project.
- Served at both `/v1/internal/sub-project` and `/sub-project`.

## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/internal/sub-project' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "My Medical Project" }'
```
