# Create location in a project (admin)

Canonical page: https://docs.ovok.com/slim-apis/location/create-location-in-a-project-admin

| Method | Path |
| --- | --- |
| `POST` | `/v1/slim/location/admin` |

[Authentication](/authentication) · [Access policies](/access-policies)

Creates a location in a given project. The admin dashboard uses it during device assignment, when the right room does not exist yet.

**Auth:** Bearer token. The caller must be a project admin. Super admins without the admin role, practitioners and System Owner callers are refused. The access-policy check (`Location:create`) is skipped for admins.
**Scope:** The project named by `projectId` in the body. The location is created with Ovok's admin client and stamped with that project.

## Request [#request]

### Body [#body]

The body is strict: a field that is not listed here fails validation.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | `string (uuid)` | Yes | Project to create the location in. |
| `name` | `string` | Yes | Location name. At least 1 character. |
| `floor` | `string` | No | Floor code. |
| `room` | `string` | No | Room code. |
| `bed` | `string` | No | Bed code. |
| `organizationId` | `string (uuid)` | No | Zone the location belongs to. |

## Behaviour [#behaviour]

- `floor`, `room` and `bed` are stored as type codes. `organizationId` sets the zone (`managingOrganization`).
- The location is created with `status: active`.
- Unlike `POST /v1/slim/location`, this route does not check for a duplicate name or a duplicate floor, room and bed.
- A location-created entry is added to the change history of the target project. A failure to write that entry does not fail the request.
- The response is `{ id, name, projectId }` of the created location.

## Example [#example]

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/slim/location/admin' \
  -H "Authorization: Bearer ${OVOK_TOKEN}" \
  -H 'Content-Type: application/json' \
  -d '{
    "projectId": "b7a3d915-6e20-4c8f-9a14-3d5f7b9c1e68",
    "name": "Room 18",
    "floor": "2",
    "room": "18",
    "organizationId": "1e6b8d30-2c4f-4a95-8d7e-b0a2c4e6f918"
  }'
```

## Successful response [#successful-response]

`201` — Location created successfully.

```json
{
  "id": "5d2a9c64-7e1b-4830-b6f5-9a3c1e8d7b02",
  "name": "Room 18",
  "projectId": "b7a3d915-6e20-4c8f-9a14-3d5f7b9c1e68"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string (uuid)` | Id of the created location. |
| `name` | `string` | Name of the created location. |
| `projectId` | `string (uuid)` | Project the location was created in. |

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| [`400`](/errors/malformed-request) | The FHIR backend refuses the location. |
| [`401`](/errors/unauthenticated) | Bearer token is missing, invalid or expired. |
| [`403`](/errors/forbidden) | You are not a project admin. |
| [`422`](/errors/validation-failed) | The body fails validation. |
