Skip to main content
Skip table of contents

Tutorial: back-end user registration

This tutorial describes the API calls a backend can make in order to onboard a user in TrustBuilder.io based on an account maintained in a CRM or another IAM.

The process of onboarding a user in TrustBuilder.io can start when a new contact is created in a CRM, or by going through all existing contacts in a CRM or all accounts in an IAM. At that moment a sequence of API calls will happen to create a new user profile in TrustBuilder.io, or to update an existing user profile.

TrustBuilder.io exposes API endpoints to create/update/delete user profiles and to create/update/delete personas in an existing user profile. The TrustBuilder.io API endpoints are documented on TrustBuilder.IO API.

1.     Obtaining an access token

All TrustBuilder.io API endpoints (except the /authorize for initial user authentication) are protected by OAuth2 access tokens.

Your backend can obtain an access token through the OAuth2 client credentials grant, whereby your backend authenticates itself using its client_id & client_secret. Optionally, you can implement additional authentication protection by using private_key_jwt as documented on Client Credentials grant.

In order to create, update or delete a user profile or persona, the requested scope must include users:read, users:write as well as config:read.

Parameter

Value

Method

POST

URL

https://<YOURTENANT>/idhub/oidc/v1/token

Headers

Content-type : application/x-www-form-urlencode

Authorization : Bearer

Body

grant_type=client_credentials
&scope=users:read users:write config:read &client_id=<CLIENTID>
&client_secret=<CLIENTSECRET>

Response

access token & refresh token

2.    Registering a user profile

To onboard a new user in TrustBuilder.io, your backend calls the POST /identity/users endpoint:

Parameter

Value

Method

POST

URL

https://<YOURTENANT>/identity/users

Headers

Content-type : application/x-www-form-urlencode

Authorization: Bearer {token}

Body

{

  "username": "john.doe",

  "given_name": "John",

  "family_name": "Doe",

  "preferred_email": "john.doe@gmail.com",

  "preferred_phone": "+32412345678",

  "id_at_customer": "SF2F457347",

  "ui_locales": [

      "en-US",

      "nl-BE"

  ],

  "consent_to_process": {

    "current": "ACTIVE"

  }

}

Response

The entire user profile that has been registered, including the unique id referring to the user profile

3.   Adding persona(s)

After the user profile has been created, your backend can one or more personas by taking the following steps:

  1. Obtain the corresponding persona definition(s)

  2. Add the persona(s) to the user profile.

3.1 Obtaining persona definition ids

Personas are defined by a user with an Administrator persona. Your backend can obtain the id of a persona definition by calling GET /config/persona-definitions with the name of the persona.

Parameter

Value

Method

GET

URL

https://<YOURTENANT>/config/persona-definitions/NAME

Headers

Content-type : application/x-www-form-urlencode

Authorization : Bearer token

Body

Empty

Response

The entire persona definition, including the unique id referring to the persona definition

Of course, this step is only needed once to obtain persona definition ids, since these remain fixed once they have been created by one of your Administrators.

3.2 Adding a persona

After the user profile has been created and assuming the set of persona definitions has been obtained, one or more such personas can be added. The user_id is the one returned in the previous step when the user profile was registered.

Parameter

Value

Method

POST

URL

https://<YOURTENANT>/identity/users/USERID/personas

Headers

Content-type : application/x-www-form-urlencode

Authorization : Bearer token

Body

{

  "persona_definition_id": "2E7425562B52417FAB73",

  "email": "john.doe@gmail.com",

  "is_preferred": true,

  "scope": [

    "Degree"

  ],

  "status": {

    "current": "ACTIVE"

  },

  "valid_from": "2023-10-12T07:35:48.490Z",

  "valid_till": "2024-10-12T07:35:48.490Z"

}

Response

The entire persona that has been added, including the unique id referring to the persona instance

4.   Updating a user profile

During its lifecycle, a user profile may be updated from time to time in function of updates in your CRM. Your backend will take the following steps to reflect those changes in TrustBuilder.io:

  1. Obtain the attribute definition(s)

  2. Find the user profile by query & filer with the email address

  3. Query the user profile to obtain the ETag

  4. Update specific attributes of the user profile.

4.1 Obtaining attribute definition ids

A user profile consists of attributes. TrustBuilder.io has a set of predefined attributes, possibly extended with a number of custom attributes. Attributes are addressed by their name, as defined in the documentation for predefined attributes (see Managing User Profiles) or defined by one of your Administrators for custom attributes.

Your backend can obtain the id of an attribute definition by calling GET /identity/config/attribute-definitions with the name of the attribute (and the category in which the attribute is defined).

Parameter

Value

Method

GET

URL

https://<YOURTENANT>/identity/config/attribute-definitions/CATEGORY/NAME

Headers

Content-type : application/x-www-form-urlencode

Authorization : Bearer token

Body

Empty

Response

The entire attribute definition, including the unique id referring to the attribute definition

Of course, this step is only needed once to obtain attribute definition ids, since these remain fixed after creating the attribute definition.

4.2 Find user profile with email

your backend then calls the POST /identity/users/query endpoint of TrustBuilder.io to find the user profile using its email address.

Parameter

Value

Method

POST

URL

https://<YOURTENANT>/identity/users/query

Headers

Content-type : application/json

Authorization : Bearer token

Body

 

                 

{ "criteria": [

  {

    "operation": "EQ",

    "field": "preferred_email",

    "value": [email]

  }

]

}

Response

The entire user profile, including the unique id referring to the user profile

4.3 Obtain Etag

Most TrustBuilder.io API endpoints use ETag headers to support efficient cache validation, to minimise data transfer and to ensure profile integrity when multiple calls arrive in a different order or simultanuously. The ETag (“entity tag”) header, defined by RFC 9110, is a mechanism that HTTP provides for Web cache validation and optimistic concurrency control.

An ETag is an opaque identifier assigned by an API endpoint to a specific version of a resource (such as a user profile, a policy definition or a configuration). The ETag is a hash of the resource content. Whenever the content changes, a new ETag is assigned. Used in this manner, ETags allow the API endpoints to detect whether the calling client (i.c. your backend) has and is assuming the same version of the resource content.

Using the ETag, the TrustBuilder.io platform enables optimistic concurrency control so that simultaneous updates (e.g. multiple API calls, or multiple Administrators doing an update of the same resource) of a resource do not overwrite each other.

This is actually done by the If-Match headers in the PUT and PATCH endpoints, so they can detect mid-air edit collisions and return an error. Note that POST operations do not need an ETag because they always add or replace resource contents in their entirety.

So, if no other call has not yet been made related to this user profile in the same script or procedure, the ETag must first be obtained.

Parameter

Value

Method

GET

URL

https://<YOURTENANT>/identity/users/USERID

Headers

Content-type : application/json

Authorization : Bearer token

Response

ETAG

4.4 Update the user profile

The final call will actually request the update. Depending on the type of update, the following endpoints are available:

  • Update attributes of the user profile using PATCH /identity/users/{user_id}

  • Update attributes in one of the associated personas using PATCH /identity/users/{user_id}/personas/{persona_id}

  • Update custom attributes in one of the associated personas using PATCH /identity/users/{user_id}/personas/{persona_id}/attribute

Parameter

Value

Method

PATCH

URL

https://<YOURTENANT>/identity/users/USERID/personas/PERSONAID

Headers

Content-type : application/merge-patch+json

If-Match : <ETAG>

Authorization : Bearer token

Body

 

                 

[

  {

    "attribute_id": "18f745e3-ed91-4944-829c-b4086842991e ",

    "operation": "UPSERT",

    "values": [

      "Degree

    ]

  },

  {

    "attribute_id": "126f1ee7-8c54-4b21-90e6-c701748f0852",

    "operation": "DELETE"

  }

]

Response

The entire updated user profile

In case of an attribute update inside personas, the attribute could be present in multiple personas. In that case, your backend must foresee logic to loop through all personas and send an update request for each of them.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.