# Specification

This document outlines the key elements of the [Contract Negotiation Protocol](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#contract-negotiation-protocol). The used terms are described [here](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology).

* [Contract Negotiation Protocol](#contract-negotiation-protocol)
  * [1 Introduction](#1-introduction)
    * [1.1 States](#11-states)
    * [1.2 State Machine](#12-state-machine)
  * [2 Message Types](#2-message-types)
    * [2.1 Contract Request Message](#21-contract-request-message)
    * [2.2 Contract Offer Message](#22-contract-offer-message)
    * [2.3 Contract Agreement Message](#23-contract-agreement-message)
    * [2.4 Contract Agreement Verification Message](#24-contract-agreement-verification-message)
    * [2.5 Contract Negotiation Event Message](#25-contract-negotiation-event-message)
    * [2.6 Contract Negotiation Termination Message](#26-contract-negotiation-termination-message)
  * [3 Response Types](#3-response-types)
    * [3.1 ACK - Contract Negotiation](#31-ack---contract-negotiation)
    * [3.2 ERROR - Contract Negotiation Error](#32-error---contract-negotiation-error)

## 1 Introduction

A [Contract Negotiation](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#contract-negotiation) (CN) involves two parties, a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) that offers one or more [Datasets](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset) under a usage contract and [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) that requests [Datasets](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset). A CN is uniquely identified through an [IRI](https://www.w3.org/International/articles/idn-and-iri/). Each CN requires a newly generated IRI, which may not be used in a CN after a terminal state has been reached. A CN progresses through a series of states, which are tracked by the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) and [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) using messages. A CN transitions to a state in response to an acknowledged message from the counter-party. Both parties have the same state of the CN. In case the states differ, the CN is terminated and a new CN has to be initiated.

### 1.1 States

The CN states are:

* **REQUESTED**: A contract for a [Dataset](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset) has been requested by the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) based on an [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer) and the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) has sent an ACK response.
* **OFFERED**: The [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) has sent an [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer) to the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) and the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) has sent an ACK response.
* **ACCEPTED**: The [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) has accepted the latest [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer) and the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) has sent an ACK response.
* **AGREED**: The [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) has accepted the latest [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer), sent an [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) to the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer), and the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) has sent an ACK response.
* **VERIFIED**: The [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) has sent an [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) verification to the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) and the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) has sent an ACK response.
* **FINALIZED**: The [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) has sent a finalization message including his own [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) verification to the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) and the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) has sent an ACK response. Data is now available to the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer).
* **TERMINATED**: The [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) or [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) has placed the CN in a terminated state. A termination message has been sent by either of the [Participants](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#participant) and the other has sent an ACK response. This is a terminal state.

### 1.2 State Machine

The CN state machine is represented in the following diagram:

![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-9f1d095135cf4769180c6e049e17953c70df771e%2Fcontract.negotiation.state.machine.png?alt=media)

Transitions marked with `C` indicate a message sent by the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer), transitions marked with `P` indicate a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) message. Terminal states are final; the state machine may not transition to another state. A new CN may be initiated if, for instance, the CN entered the `TERMINATED` state due to a network issue.

## 2 Message Types

The CN state machine is transitioned upon receipt and acknowledgement of a message. This section details those messages as abstract message types.

* Concrete wire formats are defined by the protocol binding, e.g., [Contract Negotiation HTTPS Binding](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/contract-negotiation/contract.negotiation.binding.https)..
* All [Policy](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#policy) types ([Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer), [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement)) must contain an unique identifier in the form of a URI. GUIDs can also be used in the form of URNs, for instance following the pattern <urn:uuid:{GUID}>.
* An [ODRL Agreement](https://www.w3.org/TR/odrl-vocab/#term-Agreement) must have a target property containing the [Dataset](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset) id.

### 2.1 Contract Request Message

|                     |                                                                                                                                                                                                                                                                                                                                       |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**         | [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer)                                                                                                                                                                                                               |
| **Resulting state** | `REQUESTED`, `TERMINATED`                                                                                                                                                                                                                                                                                                             |
| **Response**        | [ACK](#31-ack---contract-negotiation) or [ERROR](#32-error---contract-negotiation-error)                                                                                                                                                                                                                                              |
| **Schema**          | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-request-message-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-request-message-schema.json)   |
| **Example**         | Initiating [Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-request-message_initial.json), [Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-offer-message.json) |
| **Diagram(s)**      | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-19c3aafa77e0313c5408bf1d65d3b5679ab42a94%2Fcontract-request-message.png?alt=media)                                                                                                                |

The Contract Request Message is sent by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) to initiate a CN or to respond to a [Contract Offer Message](#22-contract-offer-message) sent by a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider).

* The [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) must include an `offer` property, which itself must have a `@id` property. If the message includes a `providerPid` property, the request will be associated with an existing CN and a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer) will be created using either the `offer` or `offer.@id` properties. If the message does not include a `providerPid`, a new CN will be created on [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) side using either the `offer` or `offer.@id` properties and the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) selects an appropriate `providerPid`.
* An `offer.@id` will generally refer to an [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer) contained in a [Catalog](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#catalog). If the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) is not aware of the `offer.@id` value, it must respond with an error message.
* The `callbackAddress` is a URL indicating where messages to the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) should be sent in asynchronous settings. If the address is not understood, the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) MUST return an UNRECOVERABLE error.
* Different to a [Catalog](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#catalog) or [Dataset](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset), the [Offer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#offer) inside a [Contract Request Message](#21-contract-request-message) must have an `odrl:target` attribute. However, it's contained Rules must not have any `odrl:target` attributes to prevent inconsistencies with the [ODRL inferencing rules for compact policies](https://www.w3.org/TR/odrl-model/#composition-compact).

### 2.2 Contract Offer Message

|                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**         | [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **Resulting state** | `OFFERED`, `TERMINATED`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| **Response**        | [ACK](#31-ack---contract-negotiation) or [ERROR](#32-error---contract-negotiation-error)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| **Schema**          | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-offer-message-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-offer-message-schema.json)                                                                                                                                                                                                                                                                                                                                                                       |
| **Example**         | [Example Initial Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-offer-message_initial.json), [Example Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-offer-message.json)                                                                                                                                                                                                                                                                                                                                                      |
| **Diagram(s)**      | <p>Initial message (note the missing <code>consumerPid</code>)</p><p><img src="https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-29bac7680f3e8106d7920a247850d27b44b2498f%2Fcontract-offer-message_initial.png?alt=media" alt="" data-size="original"></p><p>Message following a <a href="#21-contract-request-message">Contract Request Message</a>:</p><p><img src="https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-eea70c4f1d8f64e779efae660235b71c28411709%2Fcontract-offer-message.png?alt=media" alt="" data-size="original"></p> |

The Contract Offer Message is sent by a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) to initiate a CN or to respond to a [Contract Request Message](#21-contract-request-message) sent by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer).

* If the message includes a `consumerPid` property, the request will be associated with an existing CN. If the message does not include a `consumerPid`, a new CN will be created on [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) side and the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) selects an appropriate `consumerPid`.
* The [Dataset](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset) id is not required but can be included when the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) initiates a CN.
* Different to a [Dataset](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset) (see [DCAT Vocabulry Mapping](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/catalog/catalog.protocol#11-dcat-vocabulary-mapping)), the Offer inside a ContractOfferMessage must have an `odrl:target` attribute. However, it's contained Rules must not have any `odrl:target` attributes to prevent inconsistencies with the [ODRL inferencing rules for compact policies](https://www.w3.org/TR/odrl-model/#composition-compact).

### 2.3 Contract Agreement Message

|                     |                                                                                                                                                                                                                                                                                                                                         |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**         | [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider)                                                                                                                                                                                                                 |
| **Resulting state** | `AGREED`, `TERMINATED`                                                                                                                                                                                                                                                                                                                  |
| **Response**        | [ACK](#31-ack---contract-negotiation) or [ERROR](#32-error---contract-negotiation-error)                                                                                                                                                                                                                                                |
| **Schema**          | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-agreement-message-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-agreement-message-schema.json) |
| **Example**         | [Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-agreement-message.json)                                                                                                                                                                             |
| **Diagram(s)**      | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-07121f51d3e4ed72ed02946519b0ed8fff66f999%2Fcontract-agreement-message.png?alt=media)                                                                                                                |

The Contract Agreement Message is sent by a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) when it agrees to a contract. It contains the complete [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement).

* The message must contain a `consumerPid` and a `providerPid`.
* The message must contain an [ODRL Agreement](https://www.w3.org/TR/odrl-vocab/#term-Agreement).
* An [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) must contain a `timestamp` property defined as an [XSD DateTime](https://www.w3schools.com/XML/schema_dtypes_date.asp) type.
* An [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) must contain an `assigner` and `assignee`. The contents of these properties are a dataspace-specific unique identifier of the [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) parties. Note that these identifiers are not necessarily the same as the identifiers of the [Participant Agents](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#participant-agent) negotiating the contract (e.g., [Connectors](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#connector--data-service-)).
* An [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) must contain a `odrl:target` property. None of its Rules, however, must have any `odrl:target` attributes to prevent inconsistencies with the [ODRL inferencing rules for compact policies](https://www.w3.org/TR/odrl-model/#composition-compact).

### 2.4 Contract Agreement Verification Message

|                     |                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**         | [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer)                                                                                                                                                                                                                                           |
| **Resulting state** | `VERIFIED`, `TERMINATED`                                                                                                                                                                                                                                                                                                                                          |
| **Response**        | [ACK](#31-ack---contract-negotiation) or [ERROR](#32-error---contract-negotiation-error)                                                                                                                                                                                                                                                                          |
| **Schema**          | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-agreement-verification-message-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-agreement-verification-message-schema.json) |
| **Example**         | [Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-agreement-verification-message.json)                                                                                                                                                                                          |
| **Diagram(s)**      | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-1ff82d1e753600abcbb109dfbbdc47c963b6715f%2Fcontract-agreement-verification-message.png?alt=media)                                                                                                                             |

The Contract Agreement Verification Message is sent by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) to verify the acceptance of an [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement).

* A [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) responds with an error if the contract cannot be validated or is incorrect.
* The message must contain a `consumerPid` and a `providerPid`.

### 2.5 Contract Negotiation Event Message

|                     |                                                                                                                                                                                                                                                                                                                                                         |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**         | [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer), [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider)                                                                                                        |
| **Resulting state** | `FINALIZED`, `ACCEPTED`, `TERMINATED`                                                                                                                                                                                                                                                                                                                   |
| **Response**        | [ACK](#31-ack---contract-negotiation) or [ERROR](#32-error---contract-negotiation-error)                                                                                                                                                                                                                                                                |
| **Schema**          | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-negotiation-event-message-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-negotiation-event-message-schema.json) |
| **Example**         | [Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-negotiation-event-message.json)                                                                                                                                                                                     |
| **Diagram(s)**      | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-321d32fe8c26219135ba37cd722e73b3b7967b38%2Fcontract-negotiation-event-message.png?alt=media)                                                                                                                        |

When the Contract Negotiation Event Message is sent by a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) with an `eventType` property set to `FINALIZED`, an [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) has been finalized and the associated [Dataset](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#dataset) is accessible. The state machine is transitioned to the `FINALIZED` state.

* Other event types may be defined in the future.
* A [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) responds with an error if the contract cannot be validated or is incorrect.
* The message must contain a `consumerPid` and a `providerPid`.
* When the message is sent by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) with an `eventType` set to `ACCEPTED`, the state machine is placed in the `ACCEPTED` state.
* It is an error for a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) to send the message with an event type `FINALIZED` to the [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider).
* It is an error for a [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) to send the message with an event type `ACCEPTED` to the [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer).

Note that CN events are not intended for propagation of an [Agreement](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#agreement) state after a CN has entered a terminal state. It is considered an error for a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) or [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) to send an event after the CN state machine has entered a terminal state.

### 2.6 Contract Negotiation Termination Message

|                     |                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**         | [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer), [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider)                                                                                                                    |
| **Resulting state** | `TERMINATED`                                                                                                                                                                                                                                                                                                                                                        |
| **Response**        | [ACK](#31-ack---contract-negotiation) or [ERROR](#32-error---contract-negotiation-error)                                                                                                                                                                                                                                                                            |
| **Schema**          | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-negotiation-termination-message-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-negotiation-termination-message-schema.json) |
| **Example**         | [Message](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-negotiation-termination-message.json)                                                                                                                                                                                           |
| **Diagram(s)**      | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-24a256a74d206b05533fdbfdc3b6bd7f699dc822%2Fcontract-negotiation-termination-message.png?alt=media)                                                                                                                              |

The Contract Negotiation Termination Message is sent by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) or [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) indicating it has cancelled the CN sequence. The message can be sent at any state of a CN without providing an explanation. Nevertheless, the sender may provide a description to help the receiver.

* The message must contain a `consumerPid` and a `providerPid`.
* If an error is received in response to the message, the sending party may choose to ignore the error.

Note that a CN may be terminated for a variety of reasons, for example, an unrecoverable error was encountered or one of the parties no longer wishes to continue. A [Connector's](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#connector--data-service-) operator may remove terminated CN resources after it has reached the terminated state.

## 3 Response Types

The `ACK` and `ERROR` response types are mapped onto a protocol such as HTTPS. A description of an error might be provided in protocol-dependent forms, e.g., for an HTTPS binding in the request or response body.

### 3.1 ACK - Contract Negotiation

|                |                                                                                                                                                                                                                                                                                                                             |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**    | [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer), [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider)                                                                            |
| **Schema**     | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-negotiation-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-negotiation-schema.json) |
| **Example**    | [Process](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-negotiation.json)                                                                                                                                                                       |
| **Diagram(s)** | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-305028dbe131f232fc0b7b20bf8f8720bd3e6571%2Fcontract-negotiation.png?alt=media)                                                                                                          |

The Contract Negotiation is an object returned by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) or [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) indicating a successful state change happened.

### 3.2 ERROR - Contract Negotiation Error

|                |                                                                                                                                                                                                                                                                                                                                         |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Sent by**    | [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer), [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider)                                                                                        |
| **Schema**     | [TTL Shape](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/shape/contract-negotiation-error-shape.ttl), [JSON Schema](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/schema/contract-negotiation-error-schema.json) |
| **Example**    | [Error](https://github.com/International-Data-Spaces-Association/ids-specification/blob/main/negotiation/message/example/contract-negotiation-error.json)                                                                                                                                                                               |
| **Diagram(s)** | ![](https://377581754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlnGZQUB3A7aTQkUjaEA4%2Fuploads%2Fgit-blob-392aef0f0b41464ef5b59456f4b133023d322355%2Fcontract-negotiation-error.png?alt=media)                                                                                                                |

The Contract Negotiation Error is an object returned by a [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) or [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) indicating an error has occurred. It does not cause a state transition.

| Field         | Type           | Description                                                                                                                                       |
| ------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `consumerPid` | UUID           | The CN unique id on [Consumer](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#consumer) side. |
| `providerPid` | UUID           | The CN unique id on [Provider](https://docs.internationaldataspaces.org/ids-knowledgebase/dataspace-protocol/overview/terminology#provider) side. |
| `code`        | String         | An optional implementation-specific error code.                                                                                                   |
| `reason`      | Array\[object] | An optional array of implementation-specific error objects.                                                                                       |
