Create a new data subject or update an existing one.

POST https://api.consentgrid.io/v1/subjects/{type}
Authorization: Bearer apiKey
Content-Type: application/json

Create a new subject by generating a unique ID.

POST https://api.consentgrid.io/v1/subjects/{type}/{subjectId}?saveOption=option
Authorization: Bearer apiKey
Content-Type: application/json

Create a new subject with the given ID, or update an existing subject.

PATCH https://api.consentgrid.io/v1/subjects/{type}/{subjectId}?saveOption=option
Authorization: Bearer apiKey
Content-Type: application/json

Update an existing subject.

The request body contains a data subject. type determines the subject type, usually user. If there is already a subject record, the saveOption query parameter determines how the subject record will be stored:

merge or unspecified
Merge the given subject information with the subject information in the database. This will update any field with matching name with the new value, while preserving existing fields that are not specified in the input document.
rewrite
Overwrite the subject information as given in the request body.

If the subject already exists, the existing state of the subject will be stored in the version archive.

Example

Existing subject:

{
  "id": "123e4567-e89b-12d3-a456-426655440000",
  "type": "user",
  "data": {
    "name": "John Doe",
    "birthDate": "1985-04-12"
  }
}

Request:

PATCH https://api.consentgrid.io/v1/subjects/user/123e4567-e89b-12d3-a456-426655440000
Content-Type: application/json
  
{
  "data": {
    "birthDate": "1995-04-12",
    "country": "US"
  }
}

Result:

{
  "id": "123e4567-e89b-12d3-a456-426655440000",
  "type": "user",
  "data": {
    "name": "John Doe",
    "birthDate": "1995-04-12",
    "country": "US"
  }
}

Response

200 Ok

Subject successfully updated. Response contains the new subject record.

201 Created

Subject successfully created. Response contains the new subject record.

400 Bad Request

Malformed request, invalid value, etc. The return value is a JSON error object containing diagnostic information.

403 Forbidden

The authenticated key does not have the privileges for this operation. The return value is a JSON error object containing diagnostic information.