---
title: "Create EHR with id"
method: PUT
path: "/ehr/{ehr_id}"
tags: ["EHR"]
---

# Create EHR with id

`PUT /ehr/{ehr_id}`

Create a new EHR with the specified `ehr_id` identifier.

The value of the `ehr_id` unique identifier MUST be valid [HIER_OBJECT_ID](https://specifications.openehr.org/releases/BASE/latest/base_types.html#_hier_object_id_class) value. 
It is strongly RECOMMENDED that an UUID always be used for this.

An EHR_STATUS resource needs to be always created and committed in the new EHR.
This resource MAY be also supplied by the client as the request body. 
If not supplied, a default EHR_STATUS will be used by the service with following attributes:
  - `is_queryable`: true
  - `is_modifiable`: true
  - `subject`: a PARTY_SELF object

All other required EHR attributes and resources will be automatically created as needed by the [EHR creation semantics](https://specifications.openehr.org/releases/RM/latest/ehr.html#_ehr_creation_semantics).

## Path parameters

- `ehr_id` string, uuid, required

## Headers

- `Prefer` 'return=representation' | 'return=minimal' | 'return=identifier'
- `Accept` 'application/json' | 'application/xml'
- `Content-Type` 'application/json' | 'application/xml' | 'application/openehr.wt.flat+json' | 'application/openehr.wt.structured+json'

## Request body

- EhrStatus
  - `_type` string

## Response `201`

`201 Created` is returned when the EHR has been successfully created, 
with the full resource in the body when `Prefer` header is `return=representation`, or only its identifiers when `Prefer` header is `return=identifier`.

- union
  - Ehr — An EHR resource
    - `system_id` HierObjectId
      - `_type` string
      - `value` string, required
    - `ehr_id` HierObjectId
      - `_type` string
      - `value` string, required
    - `ehr_status` ObjectRefOfObjectVersionId
      - `namespace` string, required
      - `type` string, required
      - `id` ObjectId, required
        - `_type` string
        - `value` string, required
    - `ehr_access` ObjectRefOfObjectVersionId
      - `namespace` string, required
      - `type` string, required
      - `id` ObjectId, required
        - `_type` string
        - `value` string, required
    - `time_created` DvDateTime
      - `_type` string
  - Identifier
    - `uid` string, required — The (version) resource identifier.

## Other responses

- `400` — `400 Bad Request` is returned when the request could not be parsed or is invalid (e.g. malformed request URL syntax, missing required header or parameter, or syntactically invalid header, parameter or content). The response body MAY contain error details.
- `409` — `409 Conflict` Unable to create a new EHR due to a conflict with an already existing EHR. Can happen when the supplied `ehr_id` is already used by an existing EHR.

---

[API](https://skmtc.net/openehr/apis/ehr-api.md) · [All operations](https://skmtc.net/openehr/apis/ehr-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openehr/ehr-api/versions/a0e37a217524/schema)
