---
title: "Create EHR"
method: POST
path: "/ehr"
tags: ["EHR"]
---

# Create EHR

`POST /ehr`

Create a new `EHR` with an auto-generated identifier.

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).

## Headers

- `Prefer` 'return=representation' | 'return=minimal'

## Request body

- EhrStatus
  - `_type` string

## Response `201`

`201 Created` is returned when the EHR has been successfully created. 
The new EHR resource is returned in the body when the request's `Prefer` header value is `return=representation`, otherwise only headers are returned.

- Ehr — An EHR resource
  - `system_id` HierObjectId
    - `_type` string
    - `value` string, required
  - `ehr_id` HierObjectId
    - `_type` string
    - `value` string, required
  - `ehr_status` ObjectRef
    - `namespace` string, required
    - `type` string, required
    - `id` ObjectId, required
      - `_type` string
      - `value` string, required
  - `ehr_access` ObjectRef
    - `namespace` string, required
    - `type` string, required
    - `id` ObjectId, required
      - `_type` string
      - `value` string, required
  - `time_created` DvDateTime
    - `_type` string

## Other responses

- `400` — `400 Bad Request` is returned when the request URL or body (if provided) could not be parsed or has invalid content.
- `409` — `409 Conflict` Unable to create a new EHR due to a conflict with an already existing EHR with the same subject id, namespace pair, whenever EHR_STATUS is supplied.

## Changes

- **2022-11-17** `e344ca2dcbe6` — 2 breaking, 2 warning, 19 info
  - added `#/components/schemas/DvTemporal` to the `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/feeder_system_audit/time` request property `allOf` list
  - added `#/components/schemas/DvTemporal` to the `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/originating_system_audit/time` request property `allOf` list
  - removed `#/components/schemas/DataValue` from the `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/feeder_system_audit/time` request property `allOf` list
  - removed `#/components/schemas/DataValue` from the `allOf[subschema #1: Versionable]/allOf[subschema #1: LOCATABLE]/feeder_audit/originating_system_audit/time` request property `allOf` list
  - …19 more
- …earlier changes not shown

[Full history](https://skmtc.dev/openehr/apis/ehr-api/changes/ehr/post.md)

---

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