---
title: "Update COMPOSITION"
method: PUT
path: "/ehr/{ehr_id}/composition/{uid_based_id}"
tags: ["COMPOSITION"]
---

# Update COMPOSITION

`PUT /ehr/{ehr_id}/composition/{uid_based_id}`

Updates COMPOSITION identified by `uid_based_id` and associated with the EHR identified by `ehr_id`.

The `uid_based_id` can take only a form of an HIER_OBJECT_ID identifier taken from VERSIONED_OBJECT.uid.value (i.e. a `versioned_object_uid`).

If the request body already contains a COMPOSITION.uid.value, it must match the `uid_based_id` in the URL. 

The existing latest `version_uid` of COMPOSITION resource (i.e. the `preceding_version_uid`) must be specified in the `If-Match` header.

A list of ITEM_TAGs can be associated with the updated COMPOSITION, in which case a `openehr-item-tag` or `openehr-version-item-tag` request header can be set as well. 
The corresponding response header(s) will return ITEM_TAGs as they were set by the server - see [item tags headers](overview.html#tag/Requests_and_responses/HTTP-headers/openehr-item-tag-and-openehr-version-item-tag) for more details.

## Path parameters

- `ehr_id` string, uuid, required
- `uid_based_id` string, uuid, required

## Headers

- `If-Match` string, required
- `Prefer` 'return=representation' | 'return=minimal' | 'return=identifier'
- `Accept` 'application/json' | 'application/xml' | 'application/openehr.wt.flat+json' | 'application/openehr.wt.structured+json'
- `Content-Type` 'application/json' | 'application/xml' | 'application/openehr.wt.flat+json' | 'application/openehr.wt.structured+json'
- `openehr-item-tag` UpdateItemTag[]
  - `key` string, required — Tag key (identifier)
  - `value` string — Tag value
  - `target_path` string — An AQL path withing the `target` used to tag a fine-grained element
- `openehr-version-item-tag` UpdateItemTag[]
  - `key` string, required — Tag key (identifier)
  - `value` string — Tag value
  - `target_path` string — An AQL path withing the `target` used to tag a fine-grained element

## Request body

- Composition
  - `_type` string

## Response `200`

`200 OK` is returned when the COMPOSITION is successfully updated, with the full resource in the response body when `Prefer` header is `return=representation`, or only its identifiers when `Prefer` header is `return=identifier`.

- union
  - Composition
    - `_type` string
  - Identifier
    - `uid` string, required — The (version) resource identifier.

## Other responses

- `204` — `204 No Content` is returned when the update operation was successful and the `Prefer` header is missing or is set to `return=minimal`.
- `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.
- `404` — `404 Not Found` is returned when an EHR with `ehr_id` does not exist, or when the `uid_based_id` does not exist.
- `412` — `412 Precondition Failed` is returned when `If-Match` request header doesn't match the latest version on the service side. Returns also latest `version_uid` in the `ETag` header.
- `422` — `422 Unprocessable Entity` is returned when the content type and syntax is correct, could be converted to a resource, but there are semantic validation errors, such as the underlying template is not known or is not validating the supplied resource.

---

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