---
title: "Create CONTRIBUTION"
method: POST
path: "/ehr/{ehr_id}/contribution"
tags: ["CONTRIBUTION"]
---

# Create CONTRIBUTION

`POST /ehr/{ehr_id}/contribution`

We will use the relaxed CONTRIBUTION with the following optional attributes:
  - `uid`: when provided, it will be accepted in case is not in-use, otherwise error will be returned
  - `audit.time_committed`: server will always set it
  - `audit.system_id`: when provided, it will be validated

The `audit` and each `versions[i].commit_audit` are `UPDATE_AUDIT` objects: structurally an
`AUDIT_DETAILS` minus the server-assigned attributes (`time_committed`, and the optional `system_id`).
Clients SHOULD send `_type: "UPDATE_AUDIT"`; for interoperability servers SHOULD additionally accept
`_type: "AUDIT_DETAILS"` or an omitted `_type` for this attribute. The `audit.change_type` and each
`versions[i].lifecycle_state` are `DV_CODED_TEXT` values coded against the openEHR terminology.

### Simplified Formats (FLAT / STRUCTURED)

The `Content-Type` and `Accept` headers MAY be set to one of the Simplified Formats MIME types - `application/openehr.wt.flat+json` or `application/openehr.wt.structured+json` - in addition to the canonical `application/json` / `application/xml`.

When a Simplified Formats MIME type is used, the **CONTRIBUTION envelope itself remains canonical JSON** (i.e. `uid`, `versions[]` metadata, and `audit` follow the canonical RM serialization). Only the inner versioned payload - each `versions[i].data` (the embedded `COMPOSITION`, `EHR_STATUS`, or `FOLDER`) - is serialized in the chosen FLAT or STRUCTURED form. See [Simplified Formats](../simplified_formats.html) for the rules that apply to that inner payload.

## Path parameters

- `ehr_id` string, uuid, required

## Headers

- `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'

## Request body

- NewContribution — A new (un-committed) CONTRIBUTION resource
  - `uid` HierObjectId
    - `_type` string
    - `value` string, required
  - `versions` UpdateVersion[], required
    - `preceding_version_uid` ObjectVersionId
      - `_type` string
      - `value` string, required
    - `signature` string
    - `lifecycle_state` DvCodedText, required
      - `_type` string
    - `attestations` UpdateAttestation[]
      - `_type` string
      - `system_id` string — Optional identifier of the system where the change was committed. When provided it will be validated; when omitted the server sets its own value.
      - `change_type` DvCodedText, required
        - `_type` string
      - `description` DvText
        - `_type` string
      - `committer` PartyProxy, required
        - `_type` string, required
        - `external_ref` PartyRef
          - `namespace` string, required
          - `type` string, required
          - `id` ObjectId, required
            - `_type` string
            - `value` string, required
    - `data` Versionable, required
      - `_type` string
    - `commit_audit` UpdateAudit, required — The set of attributes required to document the committal of an information item to a repository. `UPDATE_AUDIT` is a REST commit DTO, not an RM class: structurally an `AUDIT_DETAILS` without the server-assigned attributes (`time_committed` is always set by the server; `system_id` is optional on commit). The server uses it to create the persisted `AUDIT_DETAILS` object. Clients SHOULD send `_type: "UPDATE_AUDIT"`. For interoperability with existing implementations, servers SHOULD additionally accept `_type: "AUDIT_DETAILS"` or an omitted `_type` for this attribute.
      - `_type` string
      - `system_id` string — Optional identifier of the system where the change was committed. When provided it will be validated; when omitted the server sets its own value.
      - `change_type` DvCodedText, required
        - `_type` string
      - `description` DvText
        - `_type` string
      - `committer` PartyProxy, required
        - `_type` string, required
        - `external_ref` PartyRef
          - `namespace` string, required
          - `type` string, required
          - `id` ObjectId, required
            - `_type` string
            - `value` string, required
  - `audit` UpdateAudit, required — The set of attributes required to document the committal of an information item to a repository. `UPDATE_AUDIT` is a REST commit DTO, not an RM class: structurally an `AUDIT_DETAILS` without the server-assigned attributes (`time_committed` is always set by the server; `system_id` is optional on commit). The server uses it to create the persisted `AUDIT_DETAILS` object. Clients SHOULD send `_type: "UPDATE_AUDIT"`. For interoperability with existing implementations, servers SHOULD additionally accept `_type: "AUDIT_DETAILS"` or an omitted `_type` for this attribute.
    - `_type` string
    - `system_id` string — Optional identifier of the system where the change was committed. When provided it will be validated; when omitted the server sets its own value.
    - `change_type` DvCodedText, required
      - `_type` string
    - `description` DvText
      - `_type` string
    - `committer` PartyProxy, required
      - `_type` string, required
      - `external_ref` PartyRef
        - `namespace` string, required
        - `type` string, required
        - `id` ObjectId, required
          - `_type` string
          - `value` string, required

## Response `201`

`201 Created` is returned when the CONTRIBUTION is successfully created.
If `Prefer` header is `return=representation`, the full resource is included in the response body; if is `return=identifier`, only its unique identifier is included.
If the `Prefer` header is missing or set to `return=minimal`, the body is empty.

When the request `Accept` header selects a Simplified Formats MIME type (`application/openehr.wt.flat+json` or `application/openehr.wt.structured+json`) and `Prefer: return=representation`, the response body is still a canonical CONTRIBUTION envelope; only each `versions[i].data` payload is serialized in the requested FLAT or STRUCTURED form.

- union
  - Contribution — A CONTRIBUTION resource
    - `uid` HierObjectId, required
      - `_type` string
      - `value` string, required
    - `versions` ObjectRefOfObjectVersionId[], required
      - `namespace` string, required
      - `type` string, required
      - `id` ObjectId, required
        - `_type` string
        - `value` string, required
    - `audit` AuditDetails, required — The set of attributes required to document the committal of an information item to a repository.
      - `_type` string
      - `system_id` string, required
      - `time_committed` DvDateTime, required
        - `_type` string
      - `change_type` DvCodedText, required
        - `_type` string
      - `description` DvText
        - `_type` string
      - `committer` PartyProxy, required
        - `_type` string, required
        - `external_ref` PartyRef
          - `namespace` string, required
          - `type` string, required
          - `id` ObjectId, required
            - `_type` string
            - `value` string, required
  - 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, or the modification type does not match the operation - i.e. first version of a MODIFICATION). The response body MAY contain error details.
- `404` — `404 Not Found` is returned when an EHR with `ehr_id` does not exist.
- `409` — `409 Conflict` is returned when a resource with same identifier(s) already exists.

---

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