# Create a child project

Canonical page: https://docs.ovok.com/api/slim/project/create-a-child-project

`POST /v1/slim/project/child`

Creates a child project under your current project and makes you its admin. Use it to set up a new customer or site below your organisation.

**Auth:** Bearer token for a project admin. No other role passes.
**Scope:** The new project becomes a direct child of the caller's project (from the token). A project that is itself a child may create children of its own.

## Behaviour

- Your project must already hold at least one access policy: the child gets a copy of every access policy of your project. Without one the request is refused with 424 and nothing is created.
- A second child with exactly the same `name` under the same parent is refused with 422.
- The whole create is all or nothing. A failure undoes what was written and answers the failure.
- On success Ovok:
  - creates the project with practitioner invitations and practitioner login enabled, and practitioner registration plus all patient registration, invitation and login disabled;
  - gives it its own Signals tenant and its own tenant code;
  - links it to your project;
  - copies your practitioner profile into it and adds you as an admin member;
  - seeds its thresholds from the global defaults, with an out-of-bed window that ends at 09:00 and starts at a time picked once from 18:00 to 20:00 in 5-minute steps, so homes do not all start watching in the same minute. The start is stored and stays until someone saves another window;
  - gives its Signals tenant the derived readings: each resident's daily mean heart rate and breathing rate (local midnight to midnight) and last night's sleep period, scheduled in the project's time zone.
- The organization stored inside the project is built from `name`, `address`, `contact` and `settings`. `settings.timeZone` must be an IANA time zone such as `Europe/Zurich` (any other value is refused with 422) and defaults to `Europe/Berlin`. `id` and `extension` in the body are ignored.
- When Signals cannot take the derived readings, the create is undone and answers 502, 503 when Signals is overloaded, or 504 when it does not answer in time.
- When the platform has it enabled, an Ovok support account is also added as a non-admin member holding the child's System Owner access policy. It is skipped when the child has no single policy of that name. This step never fails the create.
- Child project lists are refreshed right away.
- Returns `{ "projectId": "<new project id>", "success": true }`.


## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/slim/project/child' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "My Medical Project",
    "contact": [{ "telecom": [{ "system": "email", "use": "work", "value": "max.mustermann@example.com" }] }],
    "settings": { "timeZone": "Europe/Berlin" }
  }'
```

```json
{ "projectId": "c3499c27-2973-0a7f-807e-fb8676a92dcb", "success": true }
```
