Skip to content

Discover and negotiate

A buyer at Lindner Bikes adds Costa Frames as a supplier in the supplier certificate service. Before the service can ask Costa for anything, Lindner needs a contract agreement for Costa’s supplier certificates API. The service obtains it without the buyer noticing, with two requests to Lindner’s own connector.

You need two facts about the counterparty: its DID and the DSP address of its connector. The DID is the stable identifier. Store it with the partner. The address can come from the partner, or from the counterparty’s DID document, which lists the addresses of its dataspace services.

POST /api/management/v5/participants/lindner-bikes/catalog/request HTTP/1.1
Host: danube-cloud.example
Authorization: Bearer <access token>
Content-Type: application/json
{
"@context": ["https://w3id.org/edc/connector/management/v2"],
"@type": "CatalogRequest",
"counterPartyAddress": "https://danube-cloud.example/api/dsp/costa-frames/bike-dataspace",
"counterPartyId": "did:web:identity.danube-cloud.example:costa-frames",
"profile": "bike-dataspace"
}

The call needs the scope management-api:catalog:read. It returns when Lindner’s connector has the answer. In between, the two connectors exchange the catalog request of the Dataspace Protocol, and Costa’s connector verifies Lindner’s membership.

The response is a catalog. The part your application reads looks like this.

{
"@type": "Catalog",
"participantId": "did:web:identity.danube-cloud.example:costa-frames",
"dataset": [
{
"@id": "supplier-certificates-v1-provider",
"@type": "Dataset",
"dct:type": { "@id": "https://bike-dataspace.example/api/supplier-certificates" },
"dct:subject": { "@id": "https://bike-dataspace.example/api/supplier-certificates/provider" },
"dcat:version": "1.0",
"hasPolicy": [
{
"@id": "c3VwcGxpZXItY2VydGlmaWNhdGVzLXYxLXByb3ZpZGVy:c3VwcGxpZXItY2VydGlmaWNhdGVzLXYxLXByb3ZpZGVy:ZjA0ZTI2YjgtM2E1Yy00ZDFlLTliNzItOGMxZDZlNWYwYTMx",
"@type": "Offer",
"permission": [
{
"action": "use",
"constraint": [
{
"leftOperand": "https://bike-dataspace.example/policy/Membership",
"operator": "eq",
"rightOperand": "active"
}
]
}
]
}
],
"distribution": [
{
"@type": "Distribution",
"format": "https://w3id.org/dspace-sig/profile/http-pull"
}
]
}
]
}

Select the dataset by dct:subject and dcat:version, not by its ID or name. Together they say which API is behind the offer, and they are the same for every provider.

Require exactly one dataset with these two values and exactly one offer in hasPolicy. Zero datasets means that the counterparty has not activated the use case or that you are not eligible to see the offer. The catalog does not tell you which. More than one is a configuration error on the provider’s side. Stop and report it, and do not guess.

Check also that distribution lists the transfer type you intend to use.

The contract request contains the offer as the catalog returned it. Copy @id and permission unchanged. Add target with the ID of the dataset and assigner with the DID of the provider.

{
"@context": ["https://w3id.org/edc/connector/management/v2"],
"@type": "ContractRequest",
"counterPartyAddress": "https://danube-cloud.example/api/dsp/costa-frames/bike-dataspace",
"profile": "bike-dataspace",
"policy": {
"@id": "c3VwcGxpZXItY2VydGlmaWNhdGVzLXYxLXByb3ZpZGVy:c3VwcGxpZXItY2VydGlmaWNhdGVzLXYxLXByb3ZpZGVy:ZjA0ZTI2YjgtM2E1Yy00ZDFlLTliNzItOGMxZDZlNWYwYTMx",
"@type": "Offer",
"assigner": "did:web:identity.danube-cloud.example:costa-frames",
"target": "supplier-certificates-v1-provider",
"permission": [
{
"action": "use",
"constraint": [
{
"leftOperand": "https://bike-dataspace.example/policy/Membership",
"operator": "eq",
"rightOperand": "active"
}
]
}
]
}
}

Send it with POST to /contractnegotiations of your participant context, with the scope management-api:negotiations:write. The response contains the ID of a contract negotiation. The negotiation itself has only begun.

A negotiation is asynchronous. It moves through states while the two connectors exchange messages.

  1. REQUESTED
  2. AGREED
  3. VERIFIED
  4. FINALIZED
  • REQUESTEDAGREEDVERIFIED TERMINATED
The states of a contract negotiation that an application waits for. FINALIZED and TERMINATED are final.

Read the state with GET on /contractnegotiations/{id}/state. When it is FINALIZED, read the negotiation with GET on /contractnegotiations/{id} and store its contractAgreementId. This ID is what the next lecture needs. When the state is TERMINATED, the field errorDetail holds the reason.

For an offer like Costa’s the negotiation takes a few seconds. Poll with growing intervals, or react to events as lecture 14 describes. Do not hold a user’s request open while you wait. A provider can keep a contract request for approval by a person, and the negotiation then stays REQUESTED until someone decides.

What you seeLikely causeReaction
The catalog request failsWrong address, the counterparty is unreachable, or your credentials could not be verifiedReport it. Retry later for network errors.
The catalog has no matching datasetThe use case is not active on the other side, or you are not eligibleTell the user. Do not retry in a loop.
The negotiation ends TERMINATEDThe contract policy is not met, or the offer changed since you read the catalogRead errorDetail. Request the catalog again before a new attempt.
The negotiation stays REQUESTEDThe provider holds it for approval, or is slowKeep waiting. Show it as pending.
Your own call timed outUnknown. A negotiation may or may not exist.Do not repeat blindly. Lecture 8 shows what to do.
  • A catalog request goes to one counterparty and needs its DID and DSP address.
  • Select the dataset by subject and version, and require exactly one dataset and one offer.
  • The contract request repeats the offer from the catalog, with target and assigner.
  • A negotiation is asynchronous. FINALIZED yields the agreement ID, and TERMINATED yields a reason.
  • A provider can hold a request for approval, so never block a user on a negotiation.