> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clinia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bundle resource and relationship operations to be processed

> Send a bundle of operations, including resource and relationship operations, to be processed atomically by the system.

Notes:
- Order of Processing: Resource operations are executed first, followed by relationship operations.
- Atomicity: The system processes the entire bundle as a single atomic transaction.
  - If all operations succeed, the changes are committed.
  - If any operation fails, all operations are rolled back, ensuring no partial changes.




## OpenAPI

````yaml /api-reference/registry.yml post /sources/{sourceKey}/v1/bundle
openapi: 3.0.1
info:
  title: Registry API
  version: 1.0.0
servers:
  - url: https://api.{workspaceId}.clinia.cloud
    variables:
      workspaceId:
        default: ''
        description: The workspace id.
security:
  - apiKey: []
  - basicHttpAuth: []
  - bearerHttpAuth: []
tags:
  - name: Collections
    description: Management of collections in a registry.
  - name: Relationships
    description: Management of relationships in a registry.
  - name: Resources
    description: Management of resources in a registry.
paths:
  /sources/{sourceKey}/v1/bundle:
    post:
      tags:
        - Bundle
      summary: Bundle resource and relationship operations to be processed
      description: >
        Send a bundle of operations, including resource and relationship
        operations, to be processed atomically by the system.


        Notes:

        - Order of Processing: Resource operations are executed first, followed
        by relationship operations.

        - Atomicity: The system processes the entire bundle as a single atomic
        transaction.
          - If all operations succeed, the changes are committed.
          - If any operation fails, all operations are rolled back, ensuring no partial changes.
      operationId: BundleOperations
      parameters:
        - name: sourceKey
          in: path
          description: The source key.
          required: true
          schema:
            type: string
      requestBody:
        description: >-
          The request body should contain a list of resources and relationships
          operations.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/v1Bundle'
      responses:
        '200':
          description: >-
            The bundle operation is valid and returns the list of persisted
            operations with a status 'PERSISTED'.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1BundleResponse'
        '202':
          description: >-
            The bundle operation is valid and is accepted with a status
            'ACCEPTED'.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1BundleResponse'
        '400':
          description: Returned when the request is malformed or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1RegistryError'
        '404':
          description: Returned when the source key is not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1RegistryError'
        '409':
          description: Returned when more than one operation per id in the bundle.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1RegistryError'
        '413':
          description: The request body exceeds the 500 kB limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1RegistryError'
        '429':
          $ref: '#/components/responses/v1TooManyRequestError'
        '504':
          $ref: '#/components/responses/v1GatewayTimeoutError'
components:
  schemas:
    v1Bundle:
      type: object
      description: >
        Contains a list of resource and relationship operations to be processed
        atomically by the system.

        Note:
          - Multiple unique @rootId token could be defined by suffixing the token with a number. For example, @rootId1, @rootId2, etc...
          - @rootId token could be used in any properties of type `reference` to refer to a created resources in the same bundle.
          - @rootId token could be used in the `from` and `to` fields of the relationship operations to refer to created resources in the same bundle.
      required:
        - resourceOperations
        - relationshipOperations
      properties:
        resourceOperations:
          type: array
          description: List of resource operations for the bundle.
          items:
            $ref: '#/components/schemas/v1ResourceOperation'
        relationshipOperations:
          type: array
          description: List of relationships operations for the bundle.
          items:
            $ref: '#/components/schemas/v1RelationshipOperation'
    v1BundleResponse:
      allOf:
        - $ref: '#/components/schemas/v1BundleAcceptedResponse'
    v1RegistryError:
      allOf:
        - $ref: '#/components/schemas/v1Error'
        - type: object
          properties:
            code:
              $ref: '#/components/schemas/v1ErrorCode'
            applicationErrorCode:
              type: string
              enum:
                - REGISTRY_DUPLICATE_IDENTIFIER
                - REGISTRY_INVALID_COLLECTION_TYPE
                - REGISTRY_INVALID_CONTENT_TYPE
                - REGISTRY_INVALID_PIPELINE_STEP_DEFINITION
                - REGISTRY_INVALID_REQUEST_BODY
                - REGISTRY_INVALID_REVISION_ID
                - REGISTRY_PAYLOAD_PARSE_ERROR
                - REGISTRY_REQUIRED_FIELD_MISSING
                - REGISTRY_RESOURCE_TYPE_NOT_FOUND
                - REGISTRY_UNAVAILABLE_UPSTREAM_SERVICE
                - REGISTRY_BROWSE_SESSION_EXPIRED
                - REGISTRY_BULK_OPERATION_NOT_FOUND
                - REGISTRY_COLLECTION_NOT_FOUND
                - REGISTRY_CONTAINED_DEFINITION_NOT_FOUND
                - REGISTRY_PIPELINE_EXECUTION_NOT_FOUND
                - REGISTRY_PROFILE_NOT_FOUND
                - REGISTRY_PURGE_NOT_FOUND
                - REGISTRY_RELATIONSHIP_COLLECTION_NOT_FOUND
                - REGISTRY_RELATIONSHIP_DEFINITION_NOT_FOUND
                - REGISTRY_RELATIONSHIP_NOT_FOUND
                - REGISTRY_RESOURCE_NOT_FOUND
                - REGISTRY_RESOURCE_COLLECTION_NOT_FOUND
                - REGISTRY_SOURCE_NOT_FOUND
                - REGISTRY_TASK_NOT_FOUND
                - REGISTRY_VERSION_HISTORY_ITEM_NOT_FOUND
                - REGISTRY_REQUEST_CANCELLED
                - REGISTRY_REQUEST_TIMEOUT
                - REGISTRY_COLLECTION_ALREADY_EXISTS
                - REGISTRY_DUPLICATE_OPERATION_IN_BUNDLE
                - REGISTRY_IDENTIFIER_ALREADY_EXISTS
                - REGISTRY_RELATIONSHIP_ALREADY_EXISTS
                - REGISTRY_RELATIONSHIP_FROM_REF_ALREADY_EXISTS
                - REGISTRY_RELATIONSHIP_TO_REF_ALREADY_EXISTS
                - REGISTRY_RESOURCE_ALREADY_EXISTS
    v1ResourceOperation:
      oneOf:
        - $ref: '#/components/schemas/v1ResourceOperationCreate'
        - $ref: '#/components/schemas/v1ResourceOperationUpsert'
        - $ref: '#/components/schemas/v1ResourceOperationDelete'
      discriminator:
        propertyName: action
        mapping:
          CREATE:
            $ref: '#/components/schemas/v1ResourceOperationCreate'
          UPSERT:
            $ref: '#/components/schemas/v1ResourceOperationUpsert'
          DELETE:
            $ref: '#/components/schemas/v1ResourceOperationDelete'
    v1RelationshipOperation:
      oneOf:
        - $ref: '#/components/schemas/v1RelationshipOperationCreate'
        - $ref: '#/components/schemas/v1RelationshipOperationUpsert'
        - $ref: '#/components/schemas/v1RelationshipOperationDelete'
      discriminator:
        propertyName: action
        mapping:
          CREATE:
            $ref: '#/components/schemas/v1RelationshipOperationCreate'
          UPSERT:
            $ref: '#/components/schemas/v1RelationshipOperationUpsert'
          DELETE:
            $ref: '#/components/schemas/v1RelationshipOperationDelete'
    v1BundleAcceptedResponse:
      allOf:
        - $ref: '#/components/schemas/v1TaskSubmissionAcceptedResponse'
    v1Error:
      type: object
      required:
        - code
        - message
        - type
      properties:
        code:
          $ref: '#/components/schemas/v1ErrorCode'
        message:
          type: string
        type:
          $ref: '#/components/schemas/v1ErrorType'
        details:
          description: list of errors that occurred if applicable.
          type: array
          items:
            $ref: '#/components/schemas/v1Error'
        additionalContext:
          type: object
          additionalProperties: true
    v1ErrorCode:
      type: integer
      format: int32
      enum:
        - 400
        - 401
        - 403
        - 404
        - 408
        - 409
        - 413
        - 429
        - 500
        - 501
        - 504
    v1ResourceOperationCreate:
      allOf:
        - $ref: '#/components/schemas/v1ResourceOperationBase'
        - type: object
          required:
            - create
          properties:
            create:
              $ref: '#/components/schemas/v1ResourceOperationCreateContent'
    v1ResourceOperationUpsert:
      allOf:
        - $ref: '#/components/schemas/v1ResourceOperationBase'
        - type: object
          required:
            - upsert
          properties:
            upsert:
              $ref: '#/components/schemas/v1ResourceOperationUpsertContent'
    v1ResourceOperationDelete:
      allOf:
        - $ref: '#/components/schemas/v1ResourceOperationBase'
        - type: object
          required:
            - delete
          properties:
            delete:
              $ref: '#/components/schemas/v1ResourceOperationDeleteContent'
    v1RelationshipOperationCreate:
      allOf:
        - $ref: '#/components/schemas/v1RelationshipOperationBase'
        - type: object
          required:
            - create
          properties:
            create:
              $ref: '#/components/schemas/v1RelationshipOperationCreateContent'
    v1RelationshipOperationUpsert:
      allOf:
        - $ref: '#/components/schemas/v1RelationshipOperationBase'
        - type: object
          required:
            - upsert
          properties:
            upsert:
              $ref: '#/components/schemas/v1RelationshipOperationUpsertContent'
    v1RelationshipOperationDelete:
      allOf:
        - $ref: '#/components/schemas/v1RelationshipOperationBase'
        - type: object
          required:
            - delete
          properties:
            delete:
              $ref: '#/components/schemas/v1RelationshipOperationDeleteContent'
    v1TaskSubmissionAcceptedResponse:
      allOf:
        - $ref: '#/components/schemas/v1BaseTaskSubmissionResponse'
      description: |
        Response when a task has been accepted for asynchronous processing.
        The task will be executed in the background.
    v1ErrorType:
      type: string
      enum:
        - ALREADY_EXISTS
        - FAILED_PRECONDITION
        - INTERNAL
        - INVALID_ARGUMENT
        - NOT_FOUND
        - OUT_OF_RANGE
        - UNIMPLEMENTED
        - PERMISSION_DENIED
        - UNAUTHENTICATED
        - CONTENT_TOO_LARGE
        - REQUEST_TIMEOUT
        - TOO_MANY_REQUEST
        - GATEWAY_TIMEOUT
    v1ResourceOperationBase:
      type: object
      required:
        - action
      properties:
        action:
          $ref: '#/components/schemas/v1OperationAction'
    v1ResourceOperationCreateContent:
      description: The resource to create.
      type: object
      required:
        - type
        - data
      properties:
        id:
          description: >
            Id of the resource to create (optional).

            When not provided or equal to the special `@rootId` token, the id
            will be generated.

            When provided and not equal to `@rootId` token, id must follow
            pattern: `^[a-zA-Z0-9-][\w-]{1,92}$`.


            Note:
              - The `@rootId` token can be used in any properties of type `reference` and, when provided, will be replaced by the actual id of the created resource.
          type: string
        type:
          type: string
          description: The type of resource to create.
        meta:
          $ref: '#/components/schemas/v1Meta'
        data:
          type: object
          x-is-generic: true
          description: Dynamic data attributes, based on the resource type.
        contained:
          description: >-
            Resources contained in this top-level resource. Contained resources
            exists only within the context of this top-level resource.
          type: object
          additionalProperties:
            type: array
            items:
              type: object
              required:
                - type
                - data
              properties:
                id:
                  title: The id of the contained resource.
                  description: >
                    When provided, the id must follow the semantic of contained
                    resource ids (e.g. `clinic/1/healthService/1`).

                    The contained ids can be provided even if the top-level id
                    is not provided (or equal to `@rootId`). In those cases,

                    use the special `@rootId` token to refer to the top-level id
                    (e.g. `clinic/@rootId/healthService/1`).


                    If not provided, the id of the given contained will be
                    generated sequentially per contained key, starting at 1.

                    For instance, if there are 3 contained for the key
                    `healthService`, they will be generated in order as such:

                    [`clinic/1/healthService/1`, `clinic/1/healthService/2`,
                    `clinic/1/healthService/3`]


                    When some contained ids are provided and some are not, the
                    generated ids will still be sequential starting from 1,
                    ignoring collisions with provided ids.

                    For instance, if you insert 5 contained resources under the
                    same key `healthService` and only provide ids like such:

                    [`clinic/1/healthService/3`, <EMPTY>, <EMPTY>
                    `clinic/1/healthService/5`, `clinic/1/healthService/100`],
                    the outcome will be

                    [`clinic/1/healthService/3`, `clinic/1/healthService/1`,
                    `clinic/1/healthService/2`, `clinic/1/healthService/5`,
                    `clinic/1/healthService/100`].
                  type: string
                type:
                  description: Type of the resource.
                  type: string
                meta:
                  $ref: '#/components/schemas/v1Meta'
                data:
                  title: The dynamic attributes based on the resource type
                  type: object
                  x-is-generic: true
              additionalProperties: false
    v1ResourceOperationUpsertContent:
      description: |
        The resource to upsert.
        Note:
          - The `@rootId` token can be used in any properties of type `reference` and, when provided, will be replaced by the actual id of the resource.
      type: object
      required:
        - id
        - type
        - data
      properties:
        id:
          type: string
          description: The ID of the resource to upsert.
        type:
          type: string
          description: The type of resource to upsert.
        data:
          type: object
          x-is-generic: true
          description: Dynamic data attributes, based on the resource type.
        contained:
          description: >-
            Resources contained in this top-level resource. Contained resources
            exists only within the context of this top-level resource.
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/v1Resource'
        meta:
          $ref: '#/components/schemas/v1Meta'
    v1ResourceOperationDeleteContent:
      type: object
      required:
        - id
        - type
      properties:
        id:
          type: string
          description: The ID of the resource to delete.
        type:
          type: string
          description: The type of resource to delete.
    v1RelationshipOperationBase:
      type: object
      required:
        - action
      properties:
        action:
          $ref: '#/components/schemas/v1OperationAction'
    v1RelationshipOperationCreateContent:
      description: The relationship to create.
      type: object
      required:
        - type
        - from
        - to
        - data
      properties:
        type:
          type: string
        from:
          $ref: '#/components/schemas/v1RelationshipRef'
        to:
          $ref: '#/components/schemas/v1RelationshipRef'
        meta:
          $ref: '#/components/schemas/v1Meta'
        data:
          type: object
          x-is-generic: true
      additionalProperties: false
    v1RelationshipOperationUpsertContent:
      description: The relationship to upsert.
      type: object
      required:
        - type
        - from
        - to
        - data
      properties:
        type:
          type: string
        from:
          $ref: '#/components/schemas/v1RelationshipRef'
        to:
          $ref: '#/components/schemas/v1RelationshipRef'
        data:
          type: object
          x-is-generic: true
        meta:
          $ref: '#/components/schemas/v1Meta'
      additionalProperties: false
    v1RelationshipOperationDeleteContent:
      type: object
      required:
        - from
        - to
        - type
      properties:
        from:
          $ref: '#/components/schemas/v1RelationshipRef'
        to:
          $ref: '#/components/schemas/v1RelationshipRef'
        type:
          type: string
          description: The type of relationship to delete.
    v1BaseTaskSubmissionResponse:
      type: object
      required:
        - status
        - taskId
      properties:
        taskId:
          $ref: '#/components/schemas/v1TaskId'
          readOnly: true
        status:
          $ref: '#/components/schemas/v1TaskSubmissionStatus'
          readOnly: true
    v1OperationAction:
      type: string
      enum:
        - CREATE
        - UPSERT
        - DELETE
        - UPDATE
      description: The action to perform.
    v1Meta:
      type: object
      properties:
        createdAt:
          type: string
          description: Instant of creation of the resource.
          format: date-time
        identifier:
          type: array
          description: |
            Identifiers of the resource.
            Note: Combination of `source`, `value` and `use` must be unique.
          items:
            $ref: '#/components/schemas/v1Identifier'
        source:
          type: string
          description: The source of the resource.
          readOnly: true
        updatedAt:
          type: string
          description: Last update of the resource.
          format: date-time
      additionalProperties: false
    v1Resource:
      required:
        - id
        - type
        - data
      type: object
      properties:
        id:
          title: The logical identifier
          type: string
        type:
          description: Type of the resource.
          type: string
        meta:
          $ref: '#/components/schemas/v1Meta'
        data:
          title: The dynamic attributes based on the resource type
          type: object
          x-is-generic: true
      additionalProperties: false
    v1RelationshipRef:
      type: object
      required:
        - id
        - type
      properties:
        id:
          type: string
        type:
          type: string
      additionalProperties: false
    v1TaskId:
      type: string
      description: >
        The task identifier. Used to track an async task in the system. Use the
        task ID to poll for completion status.

        The taskId holds different prefix to represent different tasks.

        - oneOf task: `s_<id>`.

        - bulk task: `bk_<id>` (deprecated: `<id>` only).

        - bundle task: `bd_<id>` (deprecated: `<id>` only).

        - purge task: `pg_<id>` (deprecated: `purge:<id>`).
    v1TaskSubmissionStatus:
      type: string
      description: >
        Status of the task submission.

        * `ACCEPTED`: The task has been accepted for asynchronous processing.
        The task will be executed in the background.

        * `PERSISTED`: The task has been executed synchronously and the results
        are immediately persisted.
      enum:
        - ACCEPTED
        - PERSISTED
    v1Identifier:
      description: >-
        An identifier - identifies some entity uniquely and unambiguously.
        Typically this is used for business identifiers.
      properties:
        id:
          description: >-
            Unique id for the property within a resource (for internal
            references). This may be any string value that does not contain
            spaces.
          allOf:
            - $ref: '#/components/schemas/v1Symbol'
        system:
          description: >-
            Establishes the namespace for the value - that is, a URL that
            describes a set values that are unique.
          allOf:
            - $ref: '#/components/schemas/v1Uri'
        value:
          description: >-
            The portion of the identifier typically relevant to the user and
            which is unique within the context of the system.
          allOf:
            - $ref: '#/components/schemas/v1Symbol'
        use:
          description: The purpose of this identifier.
          allOf:
            - $ref: '#/components/schemas/v1Code'
        period:
          description: Time period when identifier was/is in use.
          allOf:
            - $ref: '#/components/schemas/v1Period'
      additionalProperties: false
    v1Symbol:
      pattern: ^[\s\S]+$
      type: string
      description: A sequence of Unicode characters.
    v1Uri:
      pattern: ^\S*$
      type: string
      description: String of characters used to identify a name or a resource.
    v1Code:
      pattern: ^[^\s]+( [^\s]+)*$
      type: string
      description: >-
        A string which has at least one character and no leading or trailing
        whitespace and where there is no whitespace other than single spaces in
        the contents.
    v1Period:
      type: object
      description: A time period defined by a start and end date and optionally time.
      properties:
        id:
          $ref: '#/components/schemas/v1Symbol'
          description: >-
            Unique id for the property within a resource (for internal
            references). This may be any string value that does not contain
            spaces.
        start:
          $ref: '#/components/schemas/v1DateTime'
          description: The start of the period. The boundary is inclusive.
        end:
          $ref: '#/components/schemas/v1DateTime'
          description: >-
            The end of the period. If the end of the period is missing, it means
            no end was known or planned at the time the instance was created.
            The start may be in the past, and the end date in the future, which
            means that period is expected/planned to end at that time.
      additionalProperties: false
    v1DateTime:
      pattern: >-
        ^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]{1,9})?)?)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)?)?)?$
      type: string
      description: >-
        A date, date-time or partial date (e.g. just year or year + month).  If
        hours and minutes are specified, a time zone SHALL be populated. The
        format is a union of the schema types gYear, gYearMonth, date and
        dateTime. Seconds must be provided due to schema type constraints but
        may be zero-filled and may be ignored. Dates SHALL be valid dates.
  responses:
    v1TooManyRequestError:
      description: Returned when the server starts throttling the requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/v1Error'
    v1GatewayTimeoutError:
      description: Returned when the request exceeds the server timeout window.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/v1Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-Clinia-API-Key
    basicHttpAuth:
      description: Basic HTTP authentication.
      type: http
      scheme: basic
    bearerHttpAuth:
      description: JWT Bearer authentication.
      type: http
      scheme: Bearer
      bearerFormat: JWT

````