githubEdit

8 Service APIs

This section provides a reference for APIs that should be implemented by this Building Block.

8 Service APIs

This section provides a reference for APIs that should be implemented by this Building Block. The APIs defined here establish a blueprint for how the Building Block will interact with other Building Blocks. Additional APIs may be implemented by the Building Block, but the listed APIs define a minimal set of functionality that should be provided by any implementation of this Building Block.

The GovStack non-functional requirements documentarrow-up-right provides additional information on how 'adaptors' may be used to translate an existing API to the patterns described here. This section also provides guidance on how candidate products are tested and how GovStack validates a product's API against the API specifications defined here.

The tests for the Consent Building Block can be found in this GitHub repositoryarrow-up-right.

8.1 API specification

The following is an automated rendition of our latest OpenAPI YAML specificationarrow-up-right.

8.1.1 Config APIs

CREATE - Creates a new Policy object and returns the new object and a PolicyRevision

post

CREATE - Creates a new Policy object and returns the new object and a PolicyRevision

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Body
Responses
chevron-right
200

A set consisting of the new Policy object created, together with the initial Revision object.

application/json
or
post
/config/policy/

READ - get a Policy object + latest Revision. If a PolicyFilter is supplied and contains a revision_id, then this specific revision is returned.

get

READ - get a Policy object + latest Revision. If a PolicyFilter is supplied and contains a revision_id, then this specific revision is returned.

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
policyIdstringRequired

Unique ID of an object

Query parameters
revisionIdstringOptional

An object with id revisionId

Responses
chevron-right
200Success
application/json
or
get
/config/policy/{policyId}/

UPDATE - Updates an existing Policy object, returning the updated version and a new revision. Updating a Policy does not affect existing references in Agreement, the new revision should be specified for Agreement.

put

UPDATE - Updates an existing Policy object, returning the updated version and a new revision. Updating a Policy does not affect existing references in Agreement, the new revision should be specified for Agreement.

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
policyIdstringRequired

Unique ID of an object

Body
Responses
chevron-right
200Success
application/json
or
put
/config/policy/{policyId}/

DELETE - Deletes an existing Policy object, returning the updated version and a new revision. Deleting a Policy is not possible if it's associated with active Agreement.

delete

DELETE - Deletes an existing Policy object, returning the updated version and a new revision. Deleting a Policy is not possible if it's associated with active Agreement.

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
policyIdstringRequired

Unique ID of an object

Responses
chevron-right
200Success
application/json

A generic revision model captures the serialized contents of any shema's single row. This is then subject to 1) cryptographic signature and 2) auditing.

Aside from "successor" column, a revision should be considered locked.

idstringRequired
schema_namestringRequired

This was previously called "schema" but for technical reasons should be called "schema_name"

object_idstringRequired

The PK of the object that was serialized.

signed_without_object_idbooleanOptional

Indicates that object_id was left blank in serialized_snapshot when calculating serialized_hash. object_id may be subsequently filled in.

serialized_snapshotstringRequired

Revisioned data (serialized as JSON) as a dict {object_data: {...}, schema_name: ..., object_id: ..., signed_without_object_id: ..., timestamp: ..., authorized_by_individual: ..., authorized_by_other: ...}. It contains all the fields of the schema except id, successor, predessor_hash and predecessor_signature.

serialized_hashstringRequired

Hash of serialized_snapshot (SHA-1)

timestampstringRequired

Timestamp of when revisioning happened

authorized_by_otherstringOptional

Reference to an admin user that has created this revision

predecessor_hashstringOptional

Tamper-resistent artifact from previous record, copied from serialized_hash

predecessor_signaturestringOptional

Tamper-resistent artifact from previous record (we don't know if the previous record was signed or not)

delete
/config/policy/{policyId}/

LIST - returns the current Policy

get

LIST - returns the current Policy

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
policyIdstringRequired

Unique ID of an object

Query parameters
offsetintegerOptional

Requested index for start of resources to be provided in response requested by client

limitintegerOptional

Requested number of resources to be provided in response requested by client

Responses
chevron-right
200Success
application/json

A policy governs data and Agreement in the realm of an organisation that is refered to as "data controller" (GDPR) and owner of referencing Agreements.

idstringRequired
namestringRequired

Name of the policy

versionstringRequired

Version of the policy

urlstringRequired

Permanent URL at which this very version of the Policy can be read, should not be allowed to change over time.

jurisdictionstringOptional
industry_sectorstringOptional
data_retention_period_daysintegerOptional
geographic_restrictionstringOptional
storage_locationstringOptional
get
/config/policy/{policyId}/revisions/

Returns a list of readable Policy objects

get

LIST - Fetches list of readable Policy objects

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Query parameters
revisionIdstringOptional

An object with id revisionId

offsetintegerOptional

Requested index for start of resources to be provided in response requested by client

limitintegerOptional

Requested number of resources to be provided in response requested by client

Responses
chevron-right
200

A list of Policy objects readable for the current session's credentials.

application/json
get
/config/policies/

8.1.2 Service APIs

CREATE - Creates an Individual in the Consent system

post

CREATE - Creates an Individual in the Consent system

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Body
Responses
chevron-right
200Success
application/json

Shallowly models an Individual which may reference some instance in an external system (registration system, functional ID, foundational ID etc). An Individual instance of this model is not to be mistaken with a unique natural individual. It is up to the system owner to decide if this record permits mapping to a natural individual and/or if a single Individual row can map to several consent agreements.

idstringRequired

The unique ID of an Individual row.

external_idstringOptional

Reference to another foundational/functional ID, which is likely PII

external_id_typestringOptional

External id type specifier. A string. For instance "email" or "foundational id". Can be used in later queries.

identity_provider_idstringOptional

This could be an FK, but for now we do not have a mapping of identity providers. IDBB may have more requirements.

post
/service/individual/

READ - Fetch an Individual in the Consent system

get

READ - Fetch an Individual in the Consent system

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
individualIdstringRequired

Unique ID of an object

Responses
chevron-right
200Success
application/json

Shallowly models an Individual which may reference some instance in an external system (registration system, functional ID, foundational ID etc). An Individual instance of this model is not to be mistaken with a unique natural individual. It is up to the system owner to decide if this record permits mapping to a natural individual and/or if a single Individual row can map to several consent agreements.

idstringRequired

The unique ID of an Individual row.

external_idstringOptional

Reference to another foundational/functional ID, which is likely PII

external_id_typestringOptional

External id type specifier. A string. For instance "email" or "foundational id". Can be used in later queries.

identity_provider_idstringOptional

This could be an FK, but for now we do not have a mapping of identity providers. IDBB may have more requirements.

get
/service/individual/{individualId}/

UPDATE - Updates an Individual in the Consent system

put

UPDATE - Updates an Individual in the Consent system

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
individualIdstringRequired

Unique ID of an object

Body
Responses
chevron-right
200Success
application/json

Shallowly models an Individual which may reference some instance in an external system (registration system, functional ID, foundational ID etc). An Individual instance of this model is not to be mistaken with a unique natural individual. It is up to the system owner to decide if this record permits mapping to a natural individual and/or if a single Individual row can map to several consent agreements.

idstringRequired

The unique ID of an Individual row.

external_idstringOptional

Reference to another foundational/functional ID, which is likely PII

external_id_typestringOptional

External id type specifier. A string. For instance "email" or "foundational id". Can be used in later queries.

identity_provider_idstringOptional

This could be an FK, but for now we do not have a mapping of identity providers. IDBB may have more requirements.

put
/service/individual/{individualId}/

LIST - lists individuals in the system

get

LIST - lists individuals in the system

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Query parameters
offsetintegerOptional

Requested index for start of resources to be provided in response requested by client

limitintegerOptional

Requested number of resources to be provided in response requested by client

Responses
chevron-right
200Success
application/json
get
/service/individuals/

READ - fetches the latest version of a Policy and the presented revisionId of an associated Agreement

get

READ - fetches the latest version of a Policy and the presented revisionId of an associated Agreement

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to org operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
policyIdstringRequired

Unique ID of an object

Query parameters
revisionIdstringOptional

An object with id revisionId

Responses
chevron-right
200Success
application/json
or
get
/service/policy/{policyId}/

DELETE - Cascading delete operation for Right To Be Forgotten, deletes all Consent Records that shall not be retained and have a "forgettable" Agreement. May also delete an unsigned Consent Record, for instance in cases where the user exits the signing process. Individual ID supplied as HTTP header.

delete

DELETE - Cascading delete operation for Right To Be Forgotten, deletes all Consent Records that shall not be retained and have a "forgettable" Agreement. May also delete an unsigned Consent Record, for instance in cases where the user exits the signing process. Individual ID supplied as HTTP header.

chevron-right
lockRequired scopes
This endpoint requires the following scopes:
  • : Grants access to specific individual read/write operations
Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Responses
chevron-right
200Success

No content

delete
/service/individual/record/

No content

8.1.3 Audit APIs

READ

get

READ

Authorizations
OAuth2authorizationCodeRequired
Authorization URL: Token URL:
Path parameters
consentRecordIdstringRequired

Unique ID of an object

Responses
chevron-right
200Success
application/json

A Consent Record expresses consent (as defined in this building block's specification) to a single Agreement. There must be a UNIQUE constraint on (agreement_revision, individual)

idstringRequired

Objects may be passed back by some API endpoints without an id (PK), denoting that they are a "draft", i.e. a ConsentRecord that is not yet stored in the database and only exist in transit. Draft ConsentRecords do not have a Revision, but if paired up with a Signature, a valid Revision should be generated.

agreement_revision_hashstringRequired

Copy of the revision hash. The hash is the included in the signature and ensures against tampering with the original agreement.

opt_inbooleanOptional

True: The individual has positively opted in. False: The individual has explicitly said no (or withdrawn a previous consent).

statestringRequired

The state field is used to record state changes after-the-fact. It is maintained by the Consent BB itself. Valid states: unsigned/pending more signatures/signed

get
/audit/consentrecord/{consentRecordId}/

None

Last updated

Was this helpful?