A longer walk through the API with curl and jq. Start at the root and follow links. Sections marked M2 need the lifecycle and events milestone; everything else is M1.
Set a base URL once. The hosted demo and a local docker compose up serve the same routes.
Code
BASE=http://localhost:3000 # or https://cdop.rethinkcarbon.co.ukH='accept: application/hal+json'
1. The root
Code
curl -s -H "$H" "$BASE/v2" | jq
The root has no data of its own, only links: self, curies, service-desc (the OpenAPI document), service-doc (the documentation at /docs), and the cdop: collections (projects, units, issuances, accounts, reference, schemas, state-machines, events, changes, webhooks, feedback, and a templated identifier). The cdop curie is templated: cdop:projects is documented at /rels/projects.
Index rows are compact: id, name, standard, country, lifecycle_stage, registry_status, modified_at, and a self link. Take the next link for the following page; never build a cursor by hand.
Three status words travel together: registry_status.code (the registry's own code, for example PENDING_REVIEW_ACTOR5), status (the current CDOP status record) and lifecycle_stage (the normalised value, for example registered).
The links on a project:
Code
curl -s "$PROJECT" | jq '._links | keys'
Facets are singletons (cdop:stakeholders, cdop:crediting-program, cdop:registry, cdop:cobenefits, cdop:buffer-pool, cdop:labels, cdop:finance); the rest are collections (cdop:validations, cdop:estimations, cdop:documents, cdop:geolocation-files, cdop:issuances, cdop:units, cdop:status-history, and in M2 cdop:verifications, cdop:agreements, cdop:milestones).
A project without financial agreements fails the upstream required list by design (see CDOP-FB-005). Ask for strict mode and read the conformance header:
curl -L follows it. A batch URN (…:B2) resolves to an issuance.
8. Problem details
Errors are application/problem+json with a type you can open in a browser.
Code
curl -s -i "$BASE/v2/projects/prj_00000000000000000000000000" | sed -n '1p;/^{/,$p'
Code
HTTP/1.1 404 Not Found{ "type": "http://localhost:3000/problems/not-found", "title": "Resource not found", "status": 404, "detail": "project prj_00000000000000000000000000 was not found", "instance": "/v2/projects/prj_00000000000000000000000000"}
A bad cursor gives cursor-invalid (400); an unknown pod gives unknown-pod (404); a payload that fails Ajv on a write gives schema-conformance (422) with the errors inlined.
9. Units and templates (M2)
One unit resource is one credit block. Its _templates are the legal actions for its state and your role.
A partial retirement splits the block: the retired part is returned under _embedded.created with a cdop:source-block link back. After the call the templates change: a retired block offers nothing. Repeat the same request with the same Idempotency-Key and you get the same response. Change the body and keep the key: 422 idempotency-key-reused. Send the old ETag: 412 precondition-failed. Retire an already retired block:
Code
{ "type": "http://localhost:3000/problems/illegal-transition", "title": "Transition not allowed in the current state", "status": 409, "detail": "retire is not allowed from state retired", "instance": "/v2/units/unt_01K5N8X2Q7R3V4W5Y6Z7A8B9D1/actions/retire", "allowed_actions": [], "_links": { "cdop:state-machine": { "href": "http://localhost:3000/v2/state-machines/unit" } }}
11. Events (M2)
Open the stream in one shell:
Code
curl -N "$BASE/v2/events?types=org.cdop.unit.*"
Retire a block in another. A CloudEvent arrives within a second: